jakeswenson / BitBetter

Modify bit warden to provide my own licensing for self hosting
500 stars 112 forks source link

build.sh failing with 2022.8.3 - outdated dotnet 5.0 - requires upgrade to 6.0 #148

Closed pedake closed 2 years ago

pedake commented 2 years ago

dotnet 5.0 outdated

Fix

Was able to mitgate by

sudo wget https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo rm packages-microsoft-prod.deb

cd BitBetter
sudo su
grep -RiIl '5.0' | xargs sed -i 's/5.0/6.0/g'

needed to run openssl manually.

h44z commented 2 years ago

build is still working with dotnet 5.0 (tested with version 2022.8.4)

Ayitaka commented 2 years ago

build is still working with dotnet 5.0 (tested with version 2022.8.4)

Did you try generating a license? That's were it failed for me.

Ayitaka commented 2 years ago

@h44z Further more, attempting to build BitBetter on a clean updated copy of Debian Bullseye results in the following:

Building with 5.0 fails (Click to expand) ``` root@debian:~# git clone https://github.com/jakeswenson/BitBetter.git Cloning into 'BitBetter'... remote: Enumerating objects: 319, done. remote: Counting objects: 100% (58/58), done. remote: Compressing objects: 100% (43/43), done. remote: Total 319 (delta 27), reused 32 (delta 15), pack-reused 261 Receiving objects: 100% (319/319), 87.85 KiB | 719.00 KiB/s, done. Resolving deltas: 100% (149/149), done. root@debian:~# cd BitBetter/ root@debian:~/BitBetter# ./build.sh Building BitBetter for BitWarden version 2022.8.4 Generating a RSA private key ..............................++++ ...............................................................................++++ writing new private key to '/root/BitBetter/.keys/key.pem' ----- build.sh README.md src update-bitwarden.sh Unable to find image 'mcr.microsoft.com/dotnet/sdk:5.0' locally 5.0: Pulling from dotnet/sdk c1ad9731b2c7: Pull complete 169ba0027942: Pull complete c4c86b92f556: Pull complete e76245086e24: Pull complete 0bf07af7e5b6: Pull complete 85081c9db788: Pull complete 5fdeb3a38fe8: Pull complete d395fb0767b4: Pull complete Digest: sha256:3ff465d940de3e2c727794d92fd7bb649c498d4abd91bc9213ea7831ebf01f1e Status: Downloaded newer image for mcr.microsoft.com/dotnet/sdk:5.0 + dotnet restore Determining projects to restore... Restored /bitBetter/bitBetter.csproj (in 1.08 sec). + dotnet publish Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Copyright (C) Microsoft Corporation. All rights reserved. Determining projects to restore... All projects are up-to-date for restore. bitBetter -> /bitBetter/bin/Debug/netcoreapp5.0/bitBetter.dll bitBetter -> /bitBetter/bin/Debug/netcoreapp5.0/publish/ Sending build context to Docker daemon 1.602MB Step 1/6 : ARG BITWARDEN_TAG Step 2/6 : FROM ${BITWARDEN_TAG} 2022.8.4: Pulling from bitwarden/api 1efc276f4ff9: Pull complete e5aeae5c9ad4: Pull complete 9d8b4edc672a: Pull complete 67bb3a123350: Pull complete 4b31f33ff8ee: Pull complete fc5f0dc37587: Pull complete 5e4413dff652: Pull complete 77b12e7ac5ce: Pull complete 78096bdbfb22: Pull complete 6a7ca2ec4c09: Pull complete Digest: sha256:f62ec31a7be712b1e6816522a3950b4e1ce504106003c867b90e184395a9d49b Status: Downloaded newer image for bitwarden/api:2022.8.4 ---> f780a0e0bfbf Step 3/6 : COPY bin/Debug/netcoreapp5.0/publish/* /bitBetter/ ---> 0ff404afcaa4 Step 4/6 : COPY ./.keys/cert.cert /newLicensing.cer ---> cb08a412c7ff Step 5/6 : 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 ---> Running in 01fd0f1ac7e7 + dotnet /bitBetter/bitBetter.dll You must install or update .NET to run this application. App: /bitBetter/bitBetter.dll Architecture: x64 Framework: 'Microsoft.NETCore.App', version '5.0.0' (x64) .NET location: /usr/share/dotnet/ The following frameworks were found: 6.0.8 at [/usr/share/dotnet/shared/Microsoft.NETCore.App] Learn about framework resolution: https://aka.ms/dotnet/app-launch-failed To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=5.0.0&arch=x64&rid=debian.11-x64 The command '/bin/sh -c 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' returned a non-zero code: 150 Sending build context to Docker daemon 1.602MB Step 1/6 : ARG BITWARDEN_TAG Step 2/6 : FROM ${BITWARDEN_TAG} 2022.8.4: Pulling from bitwarden/identity 1efc276f4ff9: Already exists e5aeae5c9ad4: Already exists 9d8b4edc672a: Already exists 67bb3a123350: Already exists 4b31f33ff8ee: Already exists 08ad26e00294: Pull complete af579ed136a3: Pull complete 2f8763ce8d28: Pull complete e269676657ce: Pull complete e70180799615: Pull complete Digest: sha256:9f6d5b4c3c1f87a02267508d8999fe6a8cd067712dc76fab1c95d42746735c3e Status: Downloaded newer image for bitwarden/identity:2022.8.4 ---> 39342ec67118 Step 3/6 : COPY bin/Debug/netcoreapp5.0/publish/* /bitBetter/ ---> 7f6d915cc72e Step 4/6 : COPY ./.keys/cert.cert /newLicensing.cer ---> 97e8b2f89532 Step 5/6 : 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 ---> Running in 04f06aadef8f + dotnet /bitBetter/bitBetter.dll You must install or update .NET to run this application. App: /bitBetter/bitBetter.dll Architecture: x64 Framework: 'Microsoft.NETCore.App', version '5.0.0' (x64) .NET location: /usr/share/dotnet/ The following frameworks were found: 6.0.8 at [/usr/share/dotnet/shared/Microsoft.NETCore.App] Learn about framework resolution: https://aka.ms/dotnet/app-launch-failed To install missing framework, download: https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=5.0.0&arch=x64&rid=debian.11-x64 The command '/bin/sh -c 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' returned a non-zero code: 150 Error response from daemon: No such image: bitbetter/api:latest Error response from daemon: No such image: bitbetter/identity:latest Error response from daemon: No such image: bitbetter/api:latest Error response from daemon: No such image: bitbetter/identity:latest root@debian:~/BitBetter# lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux 11 (bullseye) Release: 11 Codename: bullseye ```

A modified version of what @pedake suggested results in the expected successful build: grep -RiIl "5\.0" | xargs sed -i 's/5.0/6.0/g'

Building with 6.0 succeeds (Click to expand) ``` root@debian:~# git clone https://github.com/jakeswenson/BitBetter.git Cloning into 'BitBetter'... remote: Enumerating objects: 319, done. remote: Counting objects: 100% (58/58), done. remote: Compressing objects: 100% (43/43), done. remote: Total 319 (delta 27), reused 32 (delta 15), pack-reused 261 Receiving objects: 100% (319/319), 87.85 KiB | 686.00 KiB/s, done. Resolving deltas: 100% (149/149), done. root@debian:~# cd BitBetter/ root@debian:~/BitBetter# grep -RiIl "5\.0" | xargs sed -i 's/5.0/6.0/g' root@debian:~/BitBetter# ./build.sh Building BitBetter for BitWarden version 2022.8.4 Generating a RSA private key ..............................................................++++ .............++++ writing new private key to '/root/BitBetter/.keys/key.pem' ----- build.sh README.md src update-bitwarden.sh Unable to find image 'mcr.microsoft.com/dotnet/sdk:6.0' locally 6.0: Pulling from dotnet/sdk 1efc276f4ff9: Pull complete e5aeae5c9ad4: Pull complete 9d8b4edc672a: Pull complete 67bb3a123350: Pull complete 4b31f33ff8ee: Pull complete c8d14979ed53: Pull complete 67e9673ecfe7: Pull complete 67d70801a7e7: Pull complete Digest: sha256:dd19f6aa2774de9fde18c78970bc4fdebc695bd824c73371b6faec306a18b230 Status: Downloaded newer image for mcr.microsoft.com/dotnet/sdk:6.0 + dotnet restore Determining projects to restore... Restored /bitBetter/bitBetter.csproj (in 871 ms). + dotnet publish MSBuild version 17.3.0+92e077650 for .NET Determining projects to restore... All projects are up-to-date for restore. bitBetter -> /bitBetter/bin/Debug/netcoreapp6.0/bitBetter.dll bitBetter -> /bitBetter/bin/Debug/netcoreapp6.0/publish/ Sending build context to Docker daemon 1.618MB Step 1/6 : ARG BITWARDEN_TAG Step 2/6 : FROM ${BITWARDEN_TAG} 2022.8.4: Pulling from bitwarden/api 1efc276f4ff9: Already exists e5aeae5c9ad4: Already exists 9d8b4edc672a: Already exists 67bb3a123350: Already exists 4b31f33ff8ee: Already exists fc5f0dc37587: Pull complete 5e4413dff652: Pull complete 77b12e7ac5ce: Pull complete 78096bdbfb22: Pull complete 6a7ca2ec4c09: Pull complete Digest: sha256:f62ec31a7be712b1e6816522a3950b4e1ce504106003c867b90e184395a9d49b Status: Downloaded newer image for bitwarden/api:2022.8.4 ---> f780a0e0bfbf Step 3/6 : COPY bin/Debug/netcoreapp6.0/publish/* /bitBetter/ ---> 3a5d48049deb Step 4/6 : COPY ./.keys/cert.cert /newLicensing.cer ---> 4fbd0c3980cf Step 5/6 : 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 ---> Running in 101cffd98446 + dotnet /bitBetter/bitBetter.dll Bit.Core.licensing.cer Existing Cert Thumbprint: B34876439FCDA2846505B2EFBBA6C4A951313EBE New Cert Thumbprint: F12E78895248AE52ECC7BBF3459E809F7237CC15 + mv /app/Core.dll /app/Core.orig.dll + mv /app/modified.dll /app/Core.dll + rm -rf /bitBetter + rm -rf /newLicensing.cer Removing intermediate container 101cffd98446 ---> adc18be5567d Step 6/6 : LABEL com.bitwarden.product=bitbetter ---> Running in e33d3a0c07a3 Removing intermediate container e33d3a0c07a3 ---> 0ef88cff9cdc Successfully built 0ef88cff9cdc Successfully tagged bitbetter/api:latest Sending build context to Docker daemon 1.618MB Step 1/6 : ARG BITWARDEN_TAG Step 2/6 : FROM ${BITWARDEN_TAG} 2022.8.4: Pulling from bitwarden/identity 1efc276f4ff9: Already exists e5aeae5c9ad4: Already exists 9d8b4edc672a: Already exists 67bb3a123350: Already exists 4b31f33ff8ee: Already exists 08ad26e00294: Pull complete af579ed136a3: Pull complete 2f8763ce8d28: Pull complete e269676657ce: Pull complete e70180799615: Pull complete Digest: sha256:9f6d5b4c3c1f87a02267508d8999fe6a8cd067712dc76fab1c95d42746735c3e Status: Downloaded newer image for bitwarden/identity:2022.8.4 ---> 39342ec67118 Step 3/6 : COPY bin/Debug/netcoreapp6.0/publish/* /bitBetter/ ---> f716264ed6d9 Step 4/6 : COPY ./.keys/cert.cert /newLicensing.cer ---> c310fd062155 Step 5/6 : 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 ---> Running in 2803a396ff9e + dotnet /bitBetter/bitBetter.dll Bit.Core.licensing.cer Existing Cert Thumbprint: B34876439FCDA2846505B2EFBBA6C4A951313EBE New Cert Thumbprint: F12E78895248AE52ECC7BBF3459E809F7237CC15 + mv /app/Core.dll /app/Core.orig.dll + mv /app/modified.dll /app/Core.dll + rm -rf /bitBetter + rm -rf /newLicensing.cer Removing intermediate container 2803a396ff9e ---> 2a55cde11dc9 Step 6/6 : LABEL com.bitwarden.product=bitbetter ---> Running in 0ba44e40bec9 Removing intermediate container 0ba44e40bec9 ---> 24651597236c Successfully built 24651597236c Successfully tagged bitbetter/identity:latest ```
h44z commented 2 years ago

I will check that later. On my debian 11 installation it works with dotnet 5, not a fresh installation though...

echel0n commented 2 years ago

I can confirm this as well, updating to use .Net 6.0 resolved the build issues.

Ayitaka commented 2 years ago

Perhaps @h44z downloaded the 5.0 framework, as mentioned in the OP and suggested by the failed build, at some point and so his builds do not fail. Either way, I believe that, perhaps, this issue should be reopened until fully resolved either by adding instructions to the README about installing 5.0 framework or updating the project to use 6.0.

I am honestly curious, is there a reason we wouldn't want to utilize 6.0?

oliverjnash commented 2 years ago

I'm having the same problem on Ubuntu 20.04.4 (existing installation). Managed to get the build to complete successfully by using the helpful workaround from @pedake above.

24 hours later though and I'm getting an error relating to invalid license. Have tried re-running the license generator but it's not working. Have also tried rebuilding the licencegen but still having the same issue. It looks like it's not generating the cert.

Need to nip out now but will try creating the cert manually and report back with my findings.

Ayitaka commented 2 years ago

24 hours later though and I'm getting an error relating to invalid license. Have tried re-running the license generator but it's not working. Have also tried rebuilding the licencegen but still having the same issue. It looks like it's not generating the cert.

@oliverjnash I used a modified version of what @pedake suggested because the original one erroneously changed 36500 to 366.00 in ~/BitBetter/.keys/generate-keys,sh, which results in keys not being generated.

Either go into that file and change 366.00 to 36500 and rebuild, or start over and use: grep -RiIl "5\.0" | xargs sed -i 's/5.0/6.0/g'

Edit: Also, I did not require downloading any additional framework files. I simply ran the above command on a newly installed BitBetter and it all worked.

oliverjnash commented 2 years ago

@Ayitaka I think you read my mind. Literally in the process of doing that now. Thanks so much for commenting! Will report back shortly 👍

oliverjnash commented 2 years ago

Thanks @Ayitaka, that's worked perfectly.

The only oddity I noticed when generating a new licence is that just running: ./run.sh interactive doesn't seem to work, even when the keys are in the default directory.

I had to run: ./run.sh /BitBetter/.keys/cert.pfx interactive in order for it to complete. It appears to have worked as expected when including the absolute path to the .pfx.

Ayitaka commented 2 years ago

The only oddity I noticed when generating a new licence is that just running: ./run.sh interactive doesn't seem to work, even when the keys are in the default directory.

I had to run: ./run.sh /BitBetter/.keys/cert.pfx interactive in order for it to complete. It appears to have worked as expected when including the absolute path to the .pfx.

That is because the run.sh script, checks for 2 arguments or more.

Should probably be: if [ "${1,,}" != "interactive" ] && [ "$#" -lt "2" ]; then

Actually, scratch that. To make it work properly, defaulting to the usual cert path, and using just one argument for "interactive" requires a bit more reworking than what I suggested, unfortunately.

TheSp1der commented 2 years ago

@h44z Further more, attempting to build BitBetter on a clean updated copy of Debian Bullseye results in the following:

Building with 5.0 fails (Click to expand) A modified version of what @pedake suggested results in the expected successful build: grep -RiIl "5\.0" | xargs sed -i 's/5.0/6.0/g'

Building with 6.0 succeeds (Click to expand)

I just wanted to confirm this identical result and solution.

bootsie123 commented 2 years ago

Can confirm @Ayitaka's solution solved the issue for me

h44z commented 2 years ago

BitBetter now uses dotnet 6.0.