Skip to content

allow access to crypto props from RemoteCertificateValidationCallback #37580

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

Merged
merged 1 commit into from
Jun 9, 2020

Conversation

wfurt
Copy link
Member

@wfurt wfurt commented Jun 8, 2020

The information is already ready. It is set by ProcessHandshakeSuccess() in CompleteHandshake() prior to calling VerifyRemoteCertificate(). The problem is that _handshakeCompleted is not yet set to true so attempt to access the properties from callback will throw.

I did not want to touch _handshakeCompleted as that would change external behavior and set IsAutneticated prematurely. Instead, I added new helper function to allow access also if ConnectionInfo is available e.g. we progressed far enough in the handshake.

fixes #919

@wfurt wfurt added enhancement Product code improvement that does NOT require public API changes/additions area-System.Net.Security labels Jun 8, 2020
@wfurt wfurt requested a review from a team June 8, 2020 07:29
@wfurt wfurt self-assigned this Jun 8, 2020
@ghost
Copy link

ghost commented Jun 8, 2020

Tagging subscribers to this area: @dotnet/ncl
Notify danmosemsft if you want to be subscribed.

@@ -863,6 +863,17 @@ private void ThrowIfExceptionalOrNotAuthenticated()
}
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Copy link
Member

Choose a reason for hiding this comment

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

Are the call sites very hot paths? Wondering if it's really beneficial to force inline it like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I can try to measure it. For now, I just followed pattern from other helper methods.
Generally I would not expect them on hot path. The properties would either never be used or used once for logging after handshake is completed.

@wfurt wfurt merged commit ecc310b into dotnet:master Jun 9, 2020
@wfurt wfurt deleted the sslInfo_919 branch June 9, 2020 06:56
@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 8, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Security enhancement Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SslStream RemoteCertificateValidationCallback cannot access protocol/cipher info
3 participants