-
Notifications
You must be signed in to change notification settings - Fork 5.3k
use proper IO in ssl handshake #32013
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
Conversation
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.Adapters.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Security/src/System/Net/Security/SslStream.Implementation.Adapters.cs
Show resolved
Hide resolved
| // This method assumes that a SSPI context is already in a good shape. | ||
| // For example it is either a fresh context or already authenticated context that needs renegotiation. | ||
| // | ||
| private Task ProcessAuthentication(bool isAsync = false, bool isApm = false, CancellationToken cancellationToken = default) |
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.
Nit: can we rename this to ProcessAuthenticationAsync?
| } | ||
|
|
||
| await ForceAuthenticationAsync(false, buffer, cancellationToken).ConfigureAwait(false); | ||
| await ForceAuthenticationAsync(adapter, false, buffer).ConfigureAwait(false); |
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.
| await ForceAuthenticationAsync(adapter, false, buffer).ConfigureAwait(false); | |
| await ForceAuthenticationAsync(adapter, receiveFirst: false, buffer).ConfigureAwait(false); |
| // This is used to reply on re-handshake when received SEC_I_RENEGOTIATE on Read(). | ||
| // | ||
| private async Task ReplyOnReAuthenticationAsync(byte[] buffer, CancellationToken cancellationToken) | ||
| private async Task ReplyOnReAuthenticationAsync<TReadAdapter>(TReadAdapter adapter, byte[] buffer) |
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.
Nit: Now that we've combined the read/write adapters, can we rename TReadAdapter to something that's not read specific, e.g. just TAdapter or TIOAdapter or something like that?
| ReceiveBlob(buffer); | ||
| } | ||
| else | ||
| // prevent nesting ionly when authentication functions are called explicitly. e.g. handle renegotiation tansparently. |
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.
| // prevent nesting ionly when authentication functions are called explicitly. e.g. handle renegotiation tansparently. | |
| // prevent nesting only when authentication functions are called explicitly. e.g. handle renegotiation transparently. |
stephentoub
left a comment
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.
|
OSX failures are unrelated. |
This is a fragment of deprecated #1949 and fixes for regression caused by #453.
When renegotiation is triggered in synchronous AuthenticateAs*(), we would hit asserts added by dotnet/corefx#42331
To fix that, we use the Adapter to do all the IO for ssl handshake. Because handshake needs to read AND write, I combined Read and Write adapter to one.
Note that the locking can be probably simplified but I did not want to do that in this change.
With that, the old synchronous path seems to be no longer needed. So this change also deletes lot of old synchronous functions.
That uncovered unused _CachedSession and _securityStatus. I did check corefx release/3.1 branch and both variables are only assigned to but never used for anything else.