Skip to content

android libmsquic ConnectAsync Throw exception #4728

Open
@xlievo

Description

@xlievo

Describe the bug

In simple terms, I compiled the OpenSSL3 version of libsquic for Android ARM64-v8a based on the documentation, and utilized it within a .NET 8.0 Android project to establish a QUIC connection to the server.
https://github.com/microsoft/msquic/blob/main/docs/BUILD.md

pwsh ./scripts/build.ps1 -Platform android -Arch arm64 -Config Release

Additionally, OpenSSL for msquic was compiled according to the documentation.
https://github.com/quictls/openssl

So far, three native libraries have been obtained: libcrypto.so, libssl.so, and libmsquic.so.

Here are the exceptions thrown during usage on the Android 14 system. I'm not sure if this is related to OpenSSL?
It's important to note that the same code connects successfully on Windows x64.

Affected OS

  • Windows
  • Linux
  • macOS
  • Other (specify below)

Additional OS information

android arm64-v8a

MsQuic version

main

Steps taken to reproduce bug

var con = await QuicConnection.ConnectAsync(new QuicClientConnectionOptions
{
    IdleTimeout = TimeSpan.MaxValue,
    RemoteEndPoint = new IPEndPoint(endPoint.Address.MapToIPv4(), 9000),
    DefaultCloseErrorCode = 0x0A,
    DefaultStreamErrorCode = 0x0B,
    ClientAuthenticationOptions = new SslClientAuthenticationOptions
    {
        ApplicationProtocols = [SslApplicationProtocol.Http3],
        RemoteCertificateValidationCallback = (sender, certificate, chain, errors) => true,
        TargetHost = "localhost"
    }
});

Expected behavior

proper connection.

Actual outcome

The type initializer for 'Crypto' threw an exception.

   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, IntPtr certificateBuffer, Int32 bufferLength)
   at System.Net.Quic.QuicConnection.SslConnectionOptions.ValidateCertificate(QUIC_BUFFER* certificatePtr, QUIC_BUFFER* chainPtr, X509Certificate2& certificate)
   at System.Net.Quic.QuicConnection.HandleEventPeerCertificateReceived(_PEER_CERTIFICATE_RECEIVED_e__Struct& data)
--- End of stack trace from previous location ---
   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)

Additional details

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions