-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
fix LocalCertificateSelectionCallback on unix #63200
Conversation
Tagging subscribers to this area: @dotnet/ncl, @vcsjones Issue DetailsAs noted in #52499, on Windows LocalCertificateSelectionCallback can be called twice (or more). Since both Linux(OpenSSL) and macOS was mechanism how to do it this change brings both to parity with Windows. Unlike Windows where this is done via new credentials, both OSes needs to set the certificate on the Ssl session itself. While we still cannot set and test the CA list on Unix, I added test to verify that the callback is called with real certificate e.g. in middle of SSL handshake. fixes #52499
|
…nto certSelect_52499
I did more testing and it seems like the Conflicts resolved, this should be good for review. |
As noted in #52499, on Windows LocalCertificateSelectionCallback can be called twice (or more).
First it is called before handshake with certificate and trustedCA list empty. If server asks for client certificate, handshake will stop with 'CredentialsNeeded' and we would call the callback once again with certificate provided by the server and possibly CA list. All that logic is missing on Linux and that is main reason why the remote certificates and CA list is always empty. We already had fragments of code to deal with the CA list but they were never invoked e.g. it was just dead baggage.
Since both Linux(OpenSSL) and macOS was mechanism how to do it this change brings both to parity with Windows.
I'm not sure if the first invocation before handshake make sense but I decided to keep it for compatibility.
We may improve documentation with note about multiple invocation on single SSL session.
Unlike Windows where this is done via new credentials, both OSes needs to set the certificate on the Ssl session itself.
With OpenSSL we use
SSL_set_cert_cb
andSslSetBreakOnCertRequested
on macOS. That will make the handshake stop with particular error. We call the callback and set certificate on the session if provided by the user.While we still cannot set and test the CA list on Unix, I added test to verify that the callback is called with real certificate e.g. in middle of SSL handshake.
fixes #52499
contributes to #55802