Skip to content

Conversation

@wfurt
Copy link
Member

@wfurt wfurt commented Feb 10, 2020

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.

@wfurt wfurt requested review from a team and stephentoub February 10, 2020 06:18
@wfurt wfurt self-assigned this Feb 10, 2020
@davidsh davidsh added this to the 5.0 milestone Feb 10, 2020
// 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)
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Member

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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// 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.

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

@wfurt
Copy link
Member Author

wfurt commented Feb 13, 2020

OSX failures are unrelated.

@wfurt wfurt merged commit 844618c into dotnet:master Feb 13, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
@wfurt wfurt deleted the sslIO branch January 7, 2026 19:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants