-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Closed
Labels
area-System.Net.QuicenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionstracking-external-issueThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directlyThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly
Milestone
Description
Description
SslServerAuthenticationOptions.ClientCertificateRequired = true
is needed to prompt the client to send a certificate. SslStream will invoke RemoteCertificateValidationCallback with the result, even if it's null, and the server can choose if it wants to accept the connection. QuicListener however will terminate the connection without invoking RemoteCertificateValidationCallback. This is feature gap for quic that should be filled if possible.
var listenerOptions = new QuicListenerOptions()
{
MaxBidirectionalStreams = 100,
MaxUnidirectionalStreams = 100,
ServerAuthenticationOptions = new SslServerAuthenticationOptions()
{
ServerCertificate = TestResources.GetTestCertificate(),
ApplicationProtocols = new List<SslApplicationProtocol>() { new SslApplicationProtocol("h3") },
ClientCertificateRequired = true,
RemoteCertificateValidationCallback = RemoteCertificateValidationCallback,
},
ListenEndPoint = new IPEndPoint(IPAddress.Loopback, 0),
};
var listener = new QuicListener(listenerOptions);
var acceptConnection = listener.AcceptConnectionAsync();
var clientOptions = new QuicClientConnectionOptions
{
MaxBidirectionalStreams = 200,
MaxUnidirectionalStreams = 200,
RemoteEndPoint = listener.ListenEndPoint,
ClientAuthenticationOptions = new SslClientAuthenticationOptions
{
ApplicationProtocols = new List<SslApplicationProtocol>
{
new SslApplicationProtocol("h3")
},
RemoteCertificateValidationCallback = RemoteCertificateValidationCallback
}
};
var testCert = TestResources.GetTestCertificate();
// clientOptions.ClientAuthenticationOptions.ClientCertificates = new X509CertificateCollection { testCert };
using var clientConnection = new QuicConnection(clientOptions);
await clientConnection.ConnectAsync();
var serverConnection = await acceptConnection;
var clientStreamAccept = clientConnection.AcceptStreamAsync();
var serverStream = serverConnection.OpenUnidirectionalStream();
await serverStream.WriteAsync(TestData);
var clientStream = await clientStreamAccept;
static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
The client's call to ConnectAsync fails with:
| System.Net.Quic.QuicException: Connection has been shutdown by transport. Error Code: 0x80410100
| at System.Net.Quic.Implementations.MsQuic.MsQuicConnection.HandleEventShutdownInitiatedByTransport(State state, ConnectionEvent& connectionEvent)
| at System.Net.Quic.Implementations.MsQuic.MsQuicConnection.NativeCallbackHandler(IntPtr connection, IntPtr context, ConnectionEvent& connectionEvent)
I can't tell if the termination is happening on the client or server. The server logs show it did accept the connection before failing (see #57246).
Recommendation: .NET 7
Metadata
Metadata
Assignees
Labels
area-System.Net.QuicenhancementProduct code improvement that does NOT require public API changes/additionsProduct code improvement that does NOT require public API changes/additionstracking-external-issueThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directlyThe issue is caused by external problem (e.g. OS) - nothing we can do to fix it directly