-
Notifications
You must be signed in to change notification settings - Fork 10.4k
follow-up: kestrel tls listener callback #62266
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
follow-up: kestrel tls listener callback #62266
Conversation
@@ -122,7 +122,7 @@ public async Task RunTlsClientHelloCallbackTest_WithPendingCancellation() | |||
await writer.WriteAsync(new byte[2] { 0x03, 0x01 }); | |||
cts.Cancel(); | |||
|
|||
await Assert.ThrowsAsync<OperationCanceledException>(async () => await listenerTask); | |||
await VerifyThrowsAnyAsync(() => listenerTask, typeof(OperationCanceledException), typeof(TaskCanceledException)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Normally we just use Assert.ThrowsAnyAsync<OperationCanceledException>(...);
for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, i did not see that API before. refactored
@@ -66,4 +67,60 @@ await sslStream.AuthenticateAsClientAsync(new SslClientAuthenticationOptions | |||
|
|||
Assert.True(tlsClientHelloCallbackInvoked); | |||
} | |||
|
|||
[Fact] | |||
public async Task TlsClientHelloBytesCallback_PreCanceledToken() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There still isn't a test using the HandshakeTimeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
{ | ||
using (var connection = server.CreateConnection()) | ||
{ | ||
using (var sslStream = new SslStream(connection.Stream, false, (sender, cert, chain, errors) => true, null)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these tests should actually send any bytes over the connection. That creates a race where the timeout doesn't actually occur by the time the tls client hello is received and parsed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpsConnectionMiddleware does catch the exception, so i am only seeing if the connection is closed after the timeout. I changed to
await connection.TransportConnection.Input.WriteAsync(new byte[] { 0x16 });
var readResult = await connection.TransportConnection.Output.ReadAsync();
// HttpsConnectionMiddleware catches the exception, so we can only check the effects of the timeout here
Assert.True(readResult.IsCompleted);
Adds a test discussed here and fixes the check limits in other test which is failing in helix.
Fixes #62172