-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
QuicListener accepts an invalid connection after it was rejected due to client cert issues #57246
Comments
Tagging subscribers to this area: @dotnet/ncl Issue DetailsScenario:
Workaround: override RemoteCertificateValidationCallback to accept the certificate. Expected: AcceptConnectionAsync should not return connections that have already failed due to client cert validation errors.
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().DefaultTimeout();
var serverConnection = await acceptConnection;
var clientStreamAccept = clientConnection.AcceptStreamAsync();
var serverStream = serverConnection.OpenUnidirectionalStream();
var clientStream = await clientStreamAccept;
static bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
|
@wfurt can you take a look? |
I think there is conceptual issue with the accept logic @geoffkizer. There are several ways how to fix it:
In either case, I will fix the validation handling. For 'ConnectAsync' we hand out the Exception to caller but for the current |
Scenario:
Workaround: override RemoteCertificateValidationCallback to accept the certificate.
Expected: AcceptConnectionAsync should not return connections that have already failed due to client cert validation errors.
The text was updated successfully, but these errors were encountered: