From 1a2073cf35e01656bafafa1f01b3d441cf95379e Mon Sep 17 00:00:00 2001 From: Genva Date: Sat, 14 Jun 2025 15:43:31 +0200 Subject: [PATCH 01/10] Build image from source --- build.sh | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index 6577c82..611d484 100755 --- a/build.sh +++ b/build.sh @@ -1,5 +1,5 @@ #!/bin/sh - +set -e DIR=`dirname "$0"` DIR=`exec 2>/dev/null;(cd -- "$DIR") && cd -- "$DIR"|| cd "$DIR"; unset PWD; /usr/bin/pwd || /bin/pwd || pwd` BW_VERSION=$(curl -sL https://go.btwrdn.co/bw-sh-versions | grep '^ *"'coreVersion'":' | awk -F\: '{ print $2 }' | sed -e 's/,$//' -e 's/^"//' -e 's/"$//') @@ -9,14 +9,20 @@ echo "Building BitBetter for BitWarden version $BW_VERSION" # If there aren't any keys, generate them first. [ -e "$DIR/.keys/cert.cert" ] || "$DIR/.keys/generate-keys.sh" -[ -e "$DIR/src/bitBetter/.keys" ] || mkdir "$DIR/src/bitBetter/.keys" +# Prepare Bitwarden repository +rm -rf $DIR/server +git clone https://github.com/bitwarden/server.git +git -C $DIR/server checkout tags/v${BW_VERSION} +old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':') +new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':') +cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer +# Optional, has actually no effect +sed -i -e "s/$old_thumbprint/$new_thumbprint/g" $DIR/server/src/Core/Services/Implementations/LicensingService.cs +# Enable loose files for API, so Core.dll is accessible +sed -i -e 's/PublishSingleFile=true/PublishSingleFile=false/g' $DIR/server/src/Api/Dockerfile -cp "$DIR/.keys/cert.cert" "$DIR/src/bitBetter/.keys" - -docker run --rm -v "$DIR/src/bitBetter:/bitBetter" -w=/bitBetter mcr.microsoft.com/dotnet/sdk:8.0 sh build.sh - -docker build --no-cache --build-arg BITWARDEN_TAG=ghcr.io/bitwarden/api:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/api "$DIR/src/bitBetter" # --squash -docker build --no-cache --build-arg BITWARDEN_TAG=ghcr.io/bitwarden/identity:$BW_VERSION --label com.bitwarden.product="bitbetter" -t bitbetter/identity "$DIR/src/bitBetter" # --squash +docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Api/Dockerfile -t bitbetter/api +docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Identity/Dockerfile -t bitbetter/identity docker tag bitbetter/api bitbetter/api:latest docker tag bitbetter/identity bitbetter/identity:latest From 317af2994bbc73fb971434f006e9eb56d2c99161 Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 10:16:27 +0200 Subject: [PATCH 02/10] Clone only current version tag --- build.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 611d484..53db51c 100755 --- a/build.sh +++ b/build.sh @@ -11,8 +11,7 @@ echo "Building BitBetter for BitWarden version $BW_VERSION" # Prepare Bitwarden repository rm -rf $DIR/server -git clone https://github.com/bitwarden/server.git -git -C $DIR/server checkout tags/v${BW_VERSION} +git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':') new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':') cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer From 5b5d1301c96f27cf550717006e7394366121205c Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 10:21:24 +0200 Subject: [PATCH 03/10] remove obsolete project --- src/bitBetter/Dockerfile | 11 ---- src/bitBetter/Program.cs | 93 ---------------------------------- src/bitBetter/bitBetter.csproj | 12 ----- src/bitBetter/build.sh | 7 --- 4 files changed, 123 deletions(-) delete mode 100644 src/bitBetter/Dockerfile delete mode 100644 src/bitBetter/Program.cs delete mode 100644 src/bitBetter/bitBetter.csproj delete mode 100755 src/bitBetter/build.sh diff --git a/src/bitBetter/Dockerfile b/src/bitBetter/Dockerfile deleted file mode 100644 index d66b1df..0000000 --- a/src/bitBetter/Dockerfile +++ /dev/null @@ -1,11 +0,0 @@ -ARG BITWARDEN_TAG -FROM ${BITWARDEN_TAG} - -COPY bin/Release/net8.0/publish/* /bitBetter/ -COPY ./.keys/cert.cert /newLicensing.cer - -RUN set -e; set -x; \ - dotnet /bitBetter/bitBetter.dll && \ - mv /app/Core.dll /app/Core.orig.dll && \ - mv /app/modified.dll /app/Core.dll && \ - rm -rf /bitBetter && rm -rf /newLicensing.cer diff --git a/src/bitBetter/Program.cs b/src/bitBetter/Program.cs deleted file mode 100644 index 0c7b93e..0000000 --- a/src/bitBetter/Program.cs +++ /dev/null @@ -1,93 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Security.Cryptography.X509Certificates; -using Mono.Cecil; -using Mono.Cecil.Cil; -using Mono.Cecil.Rocks; - -namespace bitwardenSelfLicensor -{ - class Program - { - static int Main(string[] args) - { - string cerFile; - string corePath; - - if(args.Length >= 2) { - cerFile = args[0]; - corePath = args[1]; - } else if (args.Length == 1) { - cerFile = args[0]; - corePath = "/app/Core.dll"; - } - else { - cerFile = "/newLicensing.cer"; - corePath = "/app/Core.dll"; - } - - - var module = ModuleDefinition.ReadModule(new MemoryStream(File.ReadAllBytes(corePath))); - var cert = File.ReadAllBytes(cerFile); - - var x = module.Resources.OfType() - .Where(r => r.Name.Equals("Bit.Core.licensing.cer")) - .First(); - - Console.WriteLine(x.Name); - - var e = new EmbeddedResource("Bit.Core.licensing.cer", x.Attributes, cert); - - module.Resources.Add(e); - module.Resources.Remove(x); - - var services = module.Types.Where(t => t.Namespace == "Bit.Core.Services"); - - - var type = services.First(t => t.Name == "LicensingService"); - - var licensingType = type.Resolve(); - - var existingCert = new X509Certificate2(x.GetResourceData()); - - Console.WriteLine($"Existing Cert Thumbprint: {existingCert.Thumbprint}"); - X509Certificate2 certificate = new X509Certificate2(cert); - - Console.WriteLine($"New Cert Thumbprint: {certificate.Thumbprint}"); - - var ctor = licensingType.GetConstructors().Single(); - - - var rewriter = ctor.Body.GetILProcessor(); - - var instToReplace = - ctor.Body.Instructions.Where(i => i.OpCode == OpCodes.Ldstr - && string.Equals((string)i.Operand, existingCert.Thumbprint, StringComparison.InvariantCultureIgnoreCase)) - .FirstOrDefault(); - - if(instToReplace != null) { - rewriter.Replace(instToReplace, Instruction.Create(OpCodes.Ldstr, certificate.Thumbprint)); - } - else { - Console.WriteLine("Cant find inst"); - } - - // foreach (var inst in ctor.Body.Instructions) - // { - // Console.Write(inst.OpCode.Name + " " + inst.Operand?.GetType() + " = "); - // if(inst.OpCode.FlowControl == FlowControl.Call) { - // Console.WriteLine(inst.Operand); - // } - // else if(inst.OpCode == OpCodes.Ldstr) { - // Console.WriteLine(inst.Operand); - // } - // else {Console.WriteLine();} - // } - - module.Write("modified.dll"); - - return 0; - } - } -} diff --git a/src/bitBetter/bitBetter.csproj b/src/bitBetter/bitBetter.csproj deleted file mode 100644 index faa5594..0000000 --- a/src/bitBetter/bitBetter.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - - Exe - net8.0 - - - - - - - diff --git a/src/bitBetter/build.sh b/src/bitBetter/build.sh deleted file mode 100755 index ea95081..0000000 --- a/src/bitBetter/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e -set -x - -dotnet restore -dotnet publish From 936059785ad599432089e4f5469739531c6e0d93 Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 14:23:04 +0200 Subject: [PATCH 04/10] support loading Core.dll from single file application --- src/licenseGen/Program.cs | 127 ++++++++++++++----------------- src/licenseGen/licenseGen.csproj | 5 +- 2 files changed, 60 insertions(+), 72 deletions(-) diff --git a/src/licenseGen/Program.cs b/src/licenseGen/Program.cs index 37e6145..e58024d 100644 --- a/src/licenseGen/Program.cs +++ b/src/licenseGen/Program.cs @@ -1,38 +1,40 @@ -using System; -using System.IO; -using System.Linq; -using System.Runtime.Loader; -using System.Security.Cryptography.X509Certificates; -using Microsoft.Extensions.CommandLineUtils; -using Newtonsoft.Json; - -namespace bitwardenSelfLicensor +namespace BitwardenSelfLicensor { - class Program + using Microsoft.Extensions.CommandLineUtils; + using Newtonsoft.Json; + using SingleFileExtractor.Core; + using System; + using System.IO; + using System.Runtime.Loader; + using System.Security.Cryptography.X509Certificates; + + public static class Program { - static int Main(string[] args) + public static int Main(string[] args) { - var app = new Microsoft.Extensions.CommandLineUtils.CommandLineApplication(); + var app = new CommandLineApplication(); var cert = app.Option("--cert", "cert file", CommandOptionType.SingleValue); var coreDll = app.Option("--core", "path to core dll", CommandOptionType.SingleValue); + var exec = app.Option("--executable", "path to Bitwarden single file executable", CommandOptionType.SingleValue); - bool certExists() + bool ExecExists() => File.Exists(exec.Value()); + bool CertExists() => File.Exists(cert.Value()); + bool CoreExists() => File.Exists(coreDll.Value()); + bool VerifyTopOptions() => + !string.IsNullOrWhiteSpace(cert.Value()) && + (!string.IsNullOrWhiteSpace(coreDll.Value()) || !string.IsNullOrWhiteSpace(exec.Value())) && + CertExists() && + (CoreExists() || ExecExists()); + string GetExtractedDll() { - return File.Exists(cert.Value()); + var coreDllPath = Path.Combine("extract", "Core.dll"); + var reader = new ExecutableReader(exec.Value()); + reader.ExtractToDirectory("extract"); + var fileInfo = new FileInfo(coreDllPath); + return fileInfo.FullName; } - - bool coreExists() - { - return File.Exists(coreDll.Value()); - } - - bool verifyTopOptions() - { - return !string.IsNullOrWhiteSpace(cert.Value()) && - !string.IsNullOrWhiteSpace(coreDll.Value()) && - certExists() && coreExists(); - } - + string GetCoreDllPath() => CoreExists() ? coreDll.Value() : GetExtractedDll(); + app.Command("interactive", config => { string buff="", licensetype="", name="", email="", businessname=""; @@ -43,11 +45,11 @@ namespace bitwardenSelfLicensor config.OnExecute(() => { - if (!verifyTopOptions()) + if (!VerifyTopOptions()) { - if (!coreExists()) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}"); - if (!certExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}"); - + if (!ExecExists() && !string.IsNullOrWhiteSpace(exec.Value())) config.Error.WriteLine($"Cant find single file executable at: {exec.Value()}"); + if (!CoreExists() && !string.IsNullOrWhiteSpace(coreDll.Value())) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}"); + if (!CertExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}"); config.ShowHelp(); return 1; } @@ -92,7 +94,7 @@ namespace bitwardenSelfLicensor WriteLineOver("Please enter a business name, default is BitBetter. [Business Name]:"); buff = Console.ReadLine(); if (buff == "") businessname = "BitBetter"; - else if (checkBusinessName(buff)) businessname = buff; + else if (CheckBusinessName(buff)) businessname = buff; } } else @@ -105,14 +107,14 @@ namespace bitwardenSelfLicensor { WriteLineOver("Please provide the username this license will be registered to. [username]:"); buff = Console.ReadLine(); - if ( checkUsername(buff) ) name = buff; + if ( CheckUsername(buff) ) name = buff; } while (email == "") { WriteLineOver("Please provide the email address for the user " + name + ". [email]"); buff = Console.ReadLine(); - if ( checkEmail(buff) ) email = buff; + if ( CheckEmail(buff) ) email = buff; } while (storage == 0) @@ -125,7 +127,7 @@ namespace bitwardenSelfLicensor } else { - if (checkStorage(buff)) storage = short.Parse(buff); + if (CheckStorage(buff)) storage = short.Parse(buff); } } @@ -135,7 +137,7 @@ namespace bitwardenSelfLicensor buff = Console.ReadLine(); if ( buff == "" || buff == "y" || buff == "Y" ) { - GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name, email, storage, guid, null); + GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name, email, storage, guid, null); } else { @@ -149,7 +151,7 @@ namespace bitwardenSelfLicensor buff = Console.ReadLine(); if ( buff == "" || buff == "y" || buff == "Y" ) { - GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name, email, storage, installid, businessname, null); + GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name, email, storage, installid, businessname, null); } else { @@ -173,17 +175,11 @@ namespace bitwardenSelfLicensor config.OnExecute(() => { - if (!verifyTopOptions()) + if (!VerifyTopOptions()) { - if (!coreExists()) - { - config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}"); - } - if (!certExists()) - { - config.Error.WriteLine($"Cant find certificate at: {cert.Value()}"); - } - + if (!ExecExists() && !string.IsNullOrWhiteSpace(exec.Value())) config.Error.WriteLine($"Cant find single file executable at: {exec.Value()}"); + if (!CoreExists() && !string.IsNullOrWhiteSpace(coreDll.Value())) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}"); + if (!CertExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}"); config.ShowHelp(); return 1; } @@ -214,7 +210,7 @@ namespace bitwardenSelfLicensor storageShort = (short) parsedStorage; } - GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, storageShort, userId, key.Value); + GenerateUserLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name.Value, email.Value, storageShort, userId, key.Value); return 0; }); @@ -231,17 +227,11 @@ namespace bitwardenSelfLicensor config.OnExecute(() => { - if (!verifyTopOptions()) + if (!VerifyTopOptions()) { - if (!coreExists()) - { - config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}"); - } - if (!certExists()) - { - config.Error.WriteLine($"Cant find certificate at: {cert.Value()}"); - } - + if (!ExecExists() && !string.IsNullOrWhiteSpace(exec.Value())) config.Error.WriteLine($"Cant find single file executable at: {exec.Value()}"); + if (!CoreExists() && !string.IsNullOrWhiteSpace(coreDll.Value())) config.Error.WriteLine($"Cant find core dll at: {coreDll.Value()}"); + if (!CertExists()) config.Error.WriteLine($"Cant find certificate at: {cert.Value()}"); config.ShowHelp(); return 1; } @@ -275,7 +265,7 @@ namespace bitwardenSelfLicensor storageShort = (short) parsedStorage; } - GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), coreDll.Value(), name.Value, email.Value, storageShort, installationId, businessName.Value, key.Value); + GenerateOrgLicense(new X509Certificate2(cert.Value(), "test"), GetCoreDllPath(), name.Value, email.Value, storageShort, installationId, businessName.Value, key.Value); return 0; }); @@ -301,7 +291,7 @@ namespace bitwardenSelfLicensor } // checkUsername Checks that the username is a valid username - static bool checkUsername(string s) + private static bool CheckUsername(string s) { if ( string.IsNullOrWhiteSpace(s) ) { WriteLineOver("The username provided doesn't appear to be valid.\n"); @@ -311,7 +301,7 @@ namespace bitwardenSelfLicensor } // checkBusinessName Checks that the Business Name is a valid username - static bool checkBusinessName(string s) + private static bool CheckBusinessName(string s) { if ( string.IsNullOrWhiteSpace(s) ) { WriteLineOver("The Business Name provided doesn't appear to be valid.\n"); @@ -321,7 +311,7 @@ namespace bitwardenSelfLicensor } // checkEmail Checks that the email address is a valid email address - static bool checkEmail(string s) + private static bool CheckEmail(string s) { if ( string.IsNullOrWhiteSpace(s) ) { WriteLineOver("The email provided doesn't appear to be valid.\n"); @@ -331,7 +321,7 @@ namespace bitwardenSelfLicensor } // checkStorage Checks that the storage is in a valid range - static bool checkStorage(string s) + private static bool CheckStorage(string s) { if (string.IsNullOrWhiteSpace(s)) { @@ -347,19 +337,16 @@ namespace bitwardenSelfLicensor } // WriteLineOver Writes a new line to console over last line. - static void WriteLineOver(string s) + private static void WriteLineOver(string s) { Console.SetCursorPosition(0, Console.CursorTop -1); Console.WriteLine(s); } // WriteLine This wrapper is just here so that console writes all look similar. - static void WriteLine(string s) - { - Console.WriteLine(s); - } + private static void WriteLine(string s) => Console.WriteLine(s); - static void GenerateUserLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid userId, string key) + private static void GenerateUserLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid userId, string key) { var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath); @@ -392,7 +379,7 @@ namespace bitwardenSelfLicensor Console.WriteLine(JsonConvert.SerializeObject(license, Formatting.Indented)); } - static void GenerateOrgLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid instalId, string businessName, string key) + private static void GenerateOrgLicense(X509Certificate2 cert, string corePath, string userName, string email, short storage, Guid instalId, string businessName, string key) { var core = AssemblyLoadContext.Default.LoadFromAssemblyPath(corePath); diff --git a/src/licenseGen/licenseGen.csproj b/src/licenseGen/licenseGen.csproj index 95fdf29..2bff89f 100644 --- a/src/licenseGen/licenseGen.csproj +++ b/src/licenseGen/licenseGen.csproj @@ -1,4 +1,4 @@ - + Exe @@ -7,7 +7,8 @@ - + + From 3f5910c6169b990112fd750ac06b0894dfc4ecdf Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 14:29:22 +0200 Subject: [PATCH 05/10] pass single file application to license gen --- src/licenseGen/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/licenseGen/Dockerfile b/src/licenseGen/Dockerfile index a1fcfa1..8e9e3de 100644 --- a/src/licenseGen/Dockerfile +++ b/src/licenseGen/Dockerfile @@ -14,4 +14,4 @@ FROM bitbetter/api COPY --from=build /licenseGen/bin/Release/net8.0/publish/* /app/ -ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--cert", "/cert.pfx" ] +ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--executable /app/Api", "--cert", "/cert.pfx" ] From eaca0f047efb27d21ae4aaf97add3e1f359df269 Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 14:29:49 +0200 Subject: [PATCH 06/10] remove loose file parameter --- build.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build.sh b/build.sh index 53db51c..36a2ead 100755 --- a/build.sh +++ b/build.sh @@ -9,16 +9,17 @@ echo "Building BitBetter for BitWarden version $BW_VERSION" # If there aren't any keys, generate them first. [ -e "$DIR/.keys/cert.cert" ] || "$DIR/.keys/generate-keys.sh" -# Prepare Bitwarden repository +# Prepare Bitwarden server repository rm -rf $DIR/server git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server + +# Optional, replacing the thumbprint in code has no actual effect old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':') new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':') -cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer -# Optional, has actually no effect sed -i -e "s/$old_thumbprint/$new_thumbprint/g" $DIR/server/src/Core/Services/Implementations/LicensingService.cs -# Enable loose files for API, so Core.dll is accessible -sed -i -e 's/PublishSingleFile=true/PublishSingleFile=false/g' $DIR/server/src/Api/Dockerfile + +# Replace certificate file +cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Api/Dockerfile -t bitbetter/api docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Identity/Dockerfile -t bitbetter/identity From a3a65647766bf8da2af1238913f31a0f28be5f2c Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 16:34:12 +0200 Subject: [PATCH 07/10] fix executable parameter --- src/licenseGen/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/licenseGen/Dockerfile b/src/licenseGen/Dockerfile index 8e9e3de..527ccde 100644 --- a/src/licenseGen/Dockerfile +++ b/src/licenseGen/Dockerfile @@ -14,4 +14,4 @@ FROM bitbetter/api COPY --from=build /licenseGen/bin/Release/net8.0/publish/* /app/ -ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--executable /app/Api", "--cert", "/cert.pfx" ] +ENTRYPOINT [ "dotnet", "/app/licenseGen.dll", "--core", "/app/Core.dll", "--executable", "/app/Api", "--cert", "/cert.pfx" ] From d8465e1aecf308ce8b009594d2b58544041fb80a Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 16:37:32 +0200 Subject: [PATCH 08/10] Remove unnecessary changes in LicensingService.cs --- build.sh | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/build.sh b/build.sh index 36a2ead..da2b6d5 100755 --- a/build.sh +++ b/build.sh @@ -12,15 +12,9 @@ echo "Building BitBetter for BitWarden version $BW_VERSION" # Prepare Bitwarden server repository rm -rf $DIR/server git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server - -# Optional, replacing the thumbprint in code has no actual effect -old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':') -new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':') -sed -i -e "s/$old_thumbprint/$new_thumbprint/g" $DIR/server/src/Core/Services/Implementations/LicensingService.cs - -# Replace certificate file cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer +# Build docker images docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Api/Dockerfile -t bitbetter/api docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Identity/Dockerfile -t bitbetter/identity From ae20e6da9d5afd69d8d05c187f3ee69663d1fa56 Mon Sep 17 00:00:00 2001 From: Genva Date: Mon, 16 Jun 2025 20:34:14 +0200 Subject: [PATCH 09/10] Revert "Remove unnecessary changes in LicensingService.cs" This reverts commit d8465e1aecf308ce8b009594d2b58544041fb80a. --- build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index da2b6d5..36a2ead 100755 --- a/build.sh +++ b/build.sh @@ -12,9 +12,15 @@ echo "Building BitBetter for BitWarden version $BW_VERSION" # Prepare Bitwarden server repository rm -rf $DIR/server git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server + +# Optional, replacing the thumbprint in code has no actual effect +old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':') +new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':') +sed -i -e "s/$old_thumbprint/$new_thumbprint/g" $DIR/server/src/Core/Services/Implementations/LicensingService.cs + +# Replace certificate file cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer -# Build docker images docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Api/Dockerfile -t bitbetter/api docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Identity/Dockerfile -t bitbetter/identity From 1c9fe4253baece94271a0fd244d3067dec238e7e Mon Sep 17 00:00:00 2001 From: Genva Date: Tue, 17 Jun 2025 09:05:59 +0200 Subject: [PATCH 10/10] Changed comment --- build.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.sh b/build.sh index 36a2ead..0003551 100755 --- a/build.sh +++ b/build.sh @@ -13,12 +13,10 @@ echo "Building BitBetter for BitWarden version $BW_VERSION" rm -rf $DIR/server git clone --branch "v${BW_VERSION}" --depth 1 https://github.com/bitwarden/server.git $DIR/server -# Optional, replacing the thumbprint in code has no actual effect +# Replace certificate file and thumbprint old_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/server/src/Core/licensing.cer | cut -d= -f2 | tr -d ':') new_thumbprint=$(openssl x509 -fingerprint -noout -in $DIR/.keys/cert.cert | cut -d= -f2 | tr -d ':') sed -i -e "s/$old_thumbprint/$new_thumbprint/g" $DIR/server/src/Core/Services/Implementations/LicensingService.cs - -# Replace certificate file cp $DIR/.keys/cert.cert $DIR/server/src/Core/licensing.cer docker build --no-cache --label com.bitwarden.product="bitbetter" $DIR/server -f $DIR/server/src/Api/Dockerfile -t bitbetter/api