Description
Description
System.TypeInitializationException: The type initializer for 'Crypto' threw an exception.
---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception.
---> System.DllNotFoundException: libSystem.Security.Cryptography.Native.OpenSsl
at Interop.CryptoInitializer..cctor()
--- End of inner exception stack trace ---
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties(X509Chain chain, X509Certificate2 remoteCertificate, Boolean checkCertName, Boolean _, String hostName)
at System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties(X509Chain chain, X509Certificate2 remoteCertificate, Boolean checkCertName, Boolean isServer, String hostName, Span`1 certificateBuffer)
at System.Net.Quic.QuicConnection.SslConnectionOptions.ValidateCertificate(X509Certificate2 certificate, Span`1 certData, Span`1 chainData)
at System.Net.Quic.QuicConnection.SslConnectionOptions.StartAsyncCertificateValidation(IntPtr certificatePtr, IntPtr chainPtr)
at System.Net.Quic.ValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Quic.QuicConnection.FinishConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)
at System.Net.Quic.QuicConnection.<ConnectAsync>g__StartConnectAsync|2_0(QuicClientConnectionOptions options, CancellationToken cancellationToken)
at System.Net.Quic.QuicConnection.<ConnectAsync>g__StartConnectAsync|2_0(QuicClientConnectionOptions options, CancellationToken cancellationToken)
at QuicTest.ViewModels.MainViewModel.<.ctor>b__1_0() in D:\CSs\QuicTest\QuicTest\QuicTest\ViewModels\MainViewModel.cs:line 25
I noticed that there is a special Native implementation of Crypto on Android, but System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties
seems to ignore this implementation, still calling libSystem.Security.Cryptography.Native.OpenSsl instead of libSystem.Security.Cryptography.Native.Android
.
Moreover, in one version, the Android implementation of libSystem.Security.Cryptography.Native.OpenSsl
was renamed to libSystem.Security.Cryptography.Native.Android
, and I am not sure if this is what caused the error.
Reproduction Steps
Git clone https://github.com/MakesYT/Android_Quic/tree/master
- unpack
QuicTest/QuicTest.Android/android/.lib/arm64-v8a.7z
- run QuicServer
- run
QuicTest/QuicTest.Android/QuicTest.Android.csproj
Expected behavior
A normal connection receives data
Actual behavior
If both the server and the client are in WIndows, it will work fine
System.TypeInitializationException: The type initializer for 'Crypto' threw an exception.
---> System.TypeInitializationException: The type initializer for 'CryptoInitializer' threw an exception.
---> System.DllNotFoundException: libSystem.Security.Cryptography.Native.OpenSsl
at Interop.CryptoInitializer..cctor()
--- End of inner exception stack trace ---
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties(X509Chain chain, X509Certificate2 remoteCertificate, Boolean checkCertName, Boolean _, String hostName)
at System.Net.Security.CertificateValidation.BuildChainAndVerifyProperties(X509Chain chain, X509Certificate2 remoteCertificate, Boolean checkCertName, Boolean isServer, String hostName, Span`1 certificateBuffer)
at System.Net.Quic.QuicConnection.SslConnectionOptions.ValidateCertificate(X509Certificate2 certificate, Span`1 certData, Span`1 chainData)
at System.Net.Quic.QuicConnection.SslConnectionOptions.StartAsyncCertificateValidation(IntPtr certificatePtr, IntPtr chainPtr)
at System.Net.Quic.ValueTaskSource.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token)
at System.Net.Quic.QuicConnection.FinishConnectAsync(QuicClientConnectionOptions options, CancellationToken cancellationToken)
at System.Net.Quic.QuicConnection.<ConnectAsync>g__StartConnectAsync|2_0(QuicClientConnectionOptions options, CancellationToken cancellationToken)
at System.Net.Quic.QuicConnection.<ConnectAsync>g__StartConnectAsync|2_0(QuicClientConnectionOptions options, CancellationToken cancellationToken)
at QuicTest.ViewModels.MainViewModel.<.ctor>b__1_0() in D:\CSs\QuicTest\QuicTest\QuicTest\ViewModels\MainViewModel.cs:line 25
Regression?
No response
Known Workarounds
No response
Configuration
.NET10 Pr3
- QuicServer On Windows11 24h2 x64 normal work
- QuicTest/QuicTest.Android/QuicTest.Android.csproj Android 15 arm64v8
Other information
Moreover, in one version, the Android implementation of libSystem.Security.Cryptography.Native.OpenSsl was renamed to libSystem.Security.Cryptography.Native.Android, and I am not sure if this is what caused the error.