garnet icon indicating copy to clipboard operation
garnet copied to clipboard

Build failed on both main and v1.0.0 (AlmaLinux)

Open nining opened this issue 1 year ago • 11 comments

I followed the guide from "getting started" (https://microsoft.github.io/garnet/docs/getting-started). When I run "dotnet build -c Release", I got "Build FAILED." prompt as following messages.

OS: AlmaLinux release 9.3 Kernel: Linux devhost1 5.14.0-362.18.1.el9_3.x86_64

 dotnet build -c Release

MSBuild version 17.8.5+b5265ef37 for .NET
  Determining projects to restore...
  Restored /home/mike/src/garnet/libs/common/Garnet.common.csproj (in 573 ms).
  Restored /home/mike/src/garnet/libs/storage/Tsavorite/cs/src/core/Tsavorite.core.csproj (in 573 ms).
  Restored /home/mike/src/garnet/playground/Bitmap/Bitmap.csproj (in 573 ms).
  Restored /home/mike/src/garnet/playground/GarnetClientStress/GarnetClientStress.csproj (in 573 ms).
  Restored /home/mike/src/garnet/libs/client/Garnet.client.csproj (in 573 ms).
  Restored /home/mike/src/garnet/benchmark/Resp.benchmark/Resp.benchmark.csproj (in 573 ms).
  Restored /home/mike/src/garnet/libs/cluster/Garnet.cluster.csproj (in 573 ms).
  Restored /home/mike/src/garnet/libs/server/Garnet.server.csproj (in 573 ms).
  Restored /home/mike/src/garnet/samples/GarnetClientSample/GarnetClientSample.csproj (in 488 ms).
  Restored /home/mike/src/garnet/libs/storage/Tsavorite/cs/src/devices/AzureStorageDevice/Tsavorite.devices.AzureStorageDevice.csproj (in 573 ms).
  Restored /home/mike/src/garnet/main/GarnetServer/GarnetServer.csproj (in 573 ms).
  Restored /home/mike/src/garnet/libs/host/Garnet.host.csproj (in 573 ms).
  Restored /home/mike/src/garnet/playground/Embedded.perftest/Embedded.perftest.csproj (in 578 ms).
  Restored /home/mike/src/garnet/playground/TstRunner/TstRunner.csproj (in 592 ms).
  Restored /home/mike/src/garnet/samples/MetricsMonitor/MetricsMonitor.csproj (in 16 ms).
  Restored /home/mike/src/garnet/test/Garnet.test.cluster/Garnet.test.cluster.csproj (in 614 ms).
  Restored /home/mike/src/garnet/playground/ClusterStress/ClusterStress.csproj (in 40 ms).
  Restored /home/mike/src/garnet/test/Garnet.test/Garnet.test.csproj (in 619 ms).
  1 of 19 projects are up-to-date for restore.
/usr/lib64/dotnet/sdk/8.0.103/Roslyn/Microsoft.CSharp.Core.targets(84,5): error : Unhandled exception. Interop+Crypto+OpenSslCryptographicException: error:03000098:digital envelope routines::invalid digest [/home/mike/src/garnet/metrics/HdrHistogram/HdrHistogram.csproj::TargetFramework=net6.0]
/usr/lib64/dotnet/sdk/8.0.103/Roslyn/Microsoft.CSharp.Core.targets(84,5): error :    at Interop.Crypto.RsaSignHash(SafeEvpPKeyHandle pkey, RSASignaturePaddingMode paddingMode, IntPtr digestAlgorithm, ReadOnlySpan`1 hash, Span`1 destination) [/home/mike/src/garnet/metrics/HdrHistogram/HdrHistogram.csproj::TargetFramework=net6.0]
/usr/lib64/dotnet/sdk/8.0.103/Roslyn/Microsoft.CSharp.Core.targets(84,5): error :    at System.Security.Cryptography.RSAOpenSsl.TrySignHash(ReadOnlySpan`1 hash, Span`1 destination, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding, Boolean allocateSignature, Int32& bytesWritten, Byte[]& signature) [/home/mike/src/garnet/metrics/HdrHistogram/HdrHistogram.csproj::TargetFramework=net6.0]
/usr/lib64/dotnet/sdk/8.0.103/Roslyn/Microsoft.CSharp.Core.targets(84,5): error :    at System.Security.Cryptography.RSAOpenSsl.SignHash(Byte[] hash, HashAlgorithmName hashAlgorithm, RSASignaturePadding padding) [/home/mike/src/garnet/metrics/HdrHistog

nining avatar Mar 20 '24 05:03 nining

Seems that it failed while signing the assembly (possibly there's something wrong with your openssl installation). Try changing SignAssembly to false in csproj.

hez2010 avatar Mar 21 '24 02:03 hez2010

We haven't seen this happen on our Linux machines. Can you try a fresh VM in addition to the above suggestion?

badrishc avatar Mar 21 '24 04:03 badrishc

We haven't seen this happen on our Linux machines. Can you try a fresh VM in addition to the above suggestion?

This is a fresh AlmaLinux release 9.3 kvm virtual machine.

nining avatar Mar 21 '24 04:03 nining

Sounds like a .NET incompatibility with this version of Linux, perhaps due to an SSL issue there? @EgorBo anyone on .NET team care to take a look?

badrishc avatar Mar 21 '24 14:03 badrishc

@nining Can you try changing all these SignAssembly to false and build again? https://github.com/search?q=repo%3Amicrosoft%2Fgarnet%20SignAssembly&type=code

hez2010 avatar Mar 21 '24 15:03 hez2010

Sounds like a .NET incompatibility with this version of Linux, perhaps due to an SSL issue there? @EgorBo anyone on .NET team care to take a look?

the dotnet version:

$ dotnet --version
8.0.103

the openssl related packages are:

openssl-libs-3.0.7-25.el9_3.x86_64
openssl-devel-3.0.7-25.el9_3.x86_64
openssl-3.0.7-25.el9_3.x86_64

nining avatar Mar 21 '24 15:03 nining

@nining Can you try changing all these SignAssembly to false and build again? https://github.com/search?q=repo%3Amicrosoft%2Fgarnet%20SignAssembly&type=code

changed to false and now here's the new issues:

$ find . -type f -exec grep -l "<SignAssembly>true</SignAssembly>" {} + | xargs sed -i 's/<SignAssembly>true<\/SignAssembly>/<SignAssembly>false<\/SignAssembly>/g'
$ ag SignAssembly
libs/client/Garnet.client.csproj
8:    <SignAssembly>false</SignAssembly>

libs/cluster/Garnet.cluster.csproj
8:              <SignAssembly>false</SignAssembly>
...
dotnet build -c Release
MSBuild version 17.8.5+b5265ef37 for .NET
  Determining projects to restore...
  All projects are up-to-date for restore.
  HdrHistogram -> /home/mike/src/garnet/metrics/HdrHistogram/bin/AnyCPU/Release/net8.0/HdrHistogram.dll
...
  Garnet.host -> /home/mike/src/garnet/libs/host/bin/AnyCPU/Release/net6.0/Garnet.host.dll
/home/mike/src/garnet/playground/Embedded.perftest/EmbeddedRespServer.cs(30,18): error CS0281: Friend access was granted by 'Garnet.server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly. [/home/mike/src/garnet/playground/Embedded.perftest/Embedded.perftest.csproj::TargetFramework=net7.0]
...
  Garnet.server -> /home/mike/src/garnet/libs/server/bin/AnyCPU/Release/net8.0/Garnet.server.dll
/home/mike/src/garnet/playground/Embedded.perftest/EmbeddedRespServer.cs(30,18): error CS0281: Friend access was granted by 'Garnet.server, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly. [/home/mike/src/garnet/playground/Embedded.perftest/Embedded.perftest.csproj::TargetFramework=net6.0]
  Garnet.test.cluster -> /home/mike/src/garnet/test/Garnet.test.cluster/bin/AnyCPU/Release/net7.0/Garnet.test.cluster.dll
/home/mike/src/garnet/test/Garnet.test/CacheSizeTrackerTests.cs(26,31): error CS0281: Friend access was granted by 'Garnet.host, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly. [/home/mike/src/garnet/test/Garnet.test/Garnet.test.csproj::TargetFramework=net6.0]
/home/mike/src/garnet/test/Garnet.test/CacheSizeTrackerTests.cs(27,39): error CS0281: Friend access was granted by 'Garnet.host, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null', but the public key of the output assembly ('') does not match that specified by the InternalsVisibleTo attribute in the granting assembly. [/home/mike/src/garnet/test/Garnet.test/Garnet.test.csproj::TargetFramework=net6.0]
...
    0 Warning(s)
    321 Error(s)

Time Elapsed 00:00:04.69

nining avatar Mar 21 '24 15:03 nining

@nining I forgot to mention that you need to clear the Key attribute in InternalsVisibleTo after turning off assembly signing. eg. in libs/host/Garnet.host.csproj, changing <InternalsVisibleTo Include="Garnet.test" Key="0024000004800000940000000602000000240000525341310004000001000100011b1661238d3d3c76232193c8aa2de8c05b8930d6dfe8cd88797a8f5624fdf14a1643141f31da05c0f67961b0e3a64c7120001d2f8579f01ac788b0ff545790d44854abe02f42bfe36a056166a75c6a694db8c5b6609cff8a2dbb429855a1d9f79d4d8ec3e145c74bfdd903274b7344beea93eab86b422652f8dd8eecf530d2" /> to just <InternalsVisibleTo Include="Garnet.test" />

hez2010 avatar Mar 21 '24 15:03 hez2010

@nining I forgot to mention that you need to clear the Key attribute in InternalsVisibleTo after turning off assembly signing. eg. in libs/host/Garnet.host.csproj, changing <InternalsVisibleTo Include="Garnet.test" Key="0024000004800000940000000602000000240000525341310004000001000100011b1661238d3d3c76232193c8aa2de8c05b8930d6dfe8cd88797a8f5624fdf14a1643141f31da05c0f67961b0e3a64c7120001d2f8579f01ac788b0ff545790d44854abe02f42bfe36a056166a75c6a694db8c5b6609cff8a2dbb429855a1d9f79d4d8ec3e145c74bfdd903274b7344beea93eab86b422652f8dd8eecf530d2" /> to just <InternalsVisibleTo Include="Garnet.test" />

After doing these changes, I can build successfully !

$ ./main/GarnetServer/bin/AnyCPU/Release/net8.0/GarnetServer
    _________
   /_||___||_\      Garnet 1.0.0 64 bit; standalone mode
   '. \   / .'      Port: 3278
     '.\ /.'        https://aka.ms/GetGarnet
       '.'

* Ready to accept connections

nining avatar Mar 21 '24 15:03 nining

Sounds like a .NET incompatibility with this version of Linux, perhaps due to an SSL issue there? @EgorBo anyone on .NET team care to take a look?

@bartonjs @vcsjones

EgorBo avatar Mar 21 '24 15:03 EgorBo

It looks like Alma Linux is part of the greater Red Hat family; and Red Hat inspired distros by default prohibit RSA+SHA-1 signing (and that's the best algorithm assembly signing supports, IIRC).

You'll either have to change your crypto policy to allow it, or not sign on Alma/CentOS/Fedora/RHEL.

https://serverfault.com/questions/1095898/how-can-i-use-a-legacy-ssh-rsa-key-on-centos-9-stream might be relevant here.

bartonjs avatar Mar 21 '24 16:03 bartonjs