Skip to content

[QUIC] Application layer protocol negotiation error was encountered #85412

Description

@dynamiquel

Description

I have spent the past few months trying to .NET's Quic working, and so far I have gotten it to work on localhost but nothing else.

When I attempt to connect to a Quic socket that isn't on the local machine, I get this exception every time:

System.Security.Authentication.AuthenticationException: Application layer protocol negotiation error was encountered.
   at System.Net.Quic.QuicConnection.HandleEventShutdownInitiatedByTransport

Reproduction Steps

Quic server:

        var cert = new X509Certificate2("Certs/LocalCert.pfx", "password");
        
        var serverOptions = new QuicServerConnectionOptions
        {
            DefaultStreamErrorCode = 0x0A,
            DefaultCloseErrorCode = 0x0B,
            ServerAuthenticationOptions = new SslServerAuthenticationOptions
            {
                ServerCertificate = cert, 
                ApplicationProtocols = new List<SslApplicationProtocol>
                    { new("AuroraTest") }
            },
        };

        _listener = await QuicListener.ListenAsync(new QuicListenerOptions
        {
            ListenEndPoint = new IPEndPoint(IPAddress.Loopback, ipEndpoint.Port),
            ApplicationProtocols = new List<SslApplicationProtocol>
                { new("AuroraTest") },
            ConnectionOptionsCallback = (_, _, _) => ValueTask.FromResult(serverOptions),
        }, CancelToken!.Token).ConfigureAwait(false);

Quic client:

        var clientOptions = new QuicClientConnectionOptions
        {
            RemoteEndPoint = ipEndpoint,
            DefaultStreamErrorCode = 0x0A,
            DefaultCloseErrorCode = 0x0B,
            MaxInboundBidirectionalStreams = 10,
            MaxInboundUnidirectionalStreams = 10,
            ClientAuthenticationOptions = new SslClientAuthenticationOptions
            {
                ApplicationProtocols = new List<SslApplicationProtocol>
                    { new("AuroraTest") }
            }
        };

Expected behavior

The client connects to the server.

Actual behavior

The client throws a 'Application layer protocol negotiation error was encountered' message.

Regression?

No response

Known Workarounds

No response

Configuration

.NET 7.0.2
Windows 11 22621.1413 x64

Other information

The PFX certificate was self-created and is installed in the Local Machine's Trusted Root store on all devices.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions