Use the cancellation token in AuthenticateAsServerAsync - #15426
Conversation
| _options.OnAuthenticate?.Invoke(context, sslOptions); | ||
|
|
||
| await sslStream.AuthenticateAsServerAsync(sslOptions, CancellationToken.None); | ||
| await sslStream.AuthenticateAsServerAsync(sslOptions, cancellationTokeSource.Token); |
There was a problem hiding this comment.
Didn't we remove this because it didn't work well?
There was a problem hiding this comment.
Yep in .net Framework and early versions of core. It was fixed in 2.1 or so but we never tried to use it
There was a problem hiding this comment.
Yeah. It didn't work at all perviously. It does make me nervous that we're not explicitly aborting the underlying connection at all anymore with this PR. This means if there's any point in the handshake where SslStream isn't correctly observing the cancellation token, the handshake could hang indefinitely.
@stephentoub Do you think it's safe to rely on cancelling AuthenticateAsServerAsync with a token, or should we continue to abort the underlying connection as well?
There was a problem hiding this comment.
Do you think it's safe to rely on cancelling AuthenticateAsServerAsync with a token, or should we continue to abort the underlying connection as well?
It should work reliably (as of dotnet/corefx#37259 in 3.0). If you find problems I'd like us to fix it asap.
Instead of aborting the connection, just handle the OCE (which already happens)