Skip to content

SslStream.AuthenticateAsServer with client certificates doesn't allow for ACCEPT #15715

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

Closed
tmds opened this issue Nov 14, 2015 · 11 comments
Closed
Assignees
Milestone

Comments

@tmds
Copy link
Member

tmds commented Nov 14, 2015

I am connecting to a server which has an invalid certificate, using HttpClientHandler (desktop) and WinHttpHandler (CoreCLR). This works fine.

// Desktop Framework
var handler = new HttpClientHandler();
ServicePointManager.ServerCertificateValidationCallback = // return true;

// CoreCLR
var handler = new WinHttpHandler();
handler.ServerCertificateValidationCallback += // return true

When I configure the server to accept client certificates (ssl handshake), but do not provide a client certificate. The HttpClientHandler works as before, but the WinHttpHandler throws a WinHttpException (ERROR_INTERNET_SECURE_FAILURE).

@davidsh
Copy link
Contributor

davidsh commented Nov 14, 2015

I am connecting to a server which has an invalid certificate

Do you mean an invalid SERVER certificate, i.e. one that isn't trusted or perhaps expired etc.?

Also, does the server REQUIRE or just ACCEPT (not required) client ssl certificates?

Can you provide a copy of the server side code? We'll need that to investigate this.

@davidsh davidsh self-assigned this Nov 14, 2015
@tmds
Copy link
Member Author

tmds commented Nov 14, 2015

The test case is in https://github.com/tmds/KestrelHttpServer/tree/client_certificate
kestrelhttpserver\test\microsoft.aspnet.server.kestreltests\httpsconnectionfiltertests.cs
AllowCertificateContinuesWhenNoCertificate

@tmds
Copy link
Member Author

tmds commented Nov 14, 2015

By invalid I mean: self signed, not expired
The server calls AuthenticateAsServerAsync with clientCertificateRequired set to true. The validation callback always returns true.

@davidsh
Copy link
Contributor

davidsh commented Nov 14, 2015

So, the "server" is Kestrel which uses .NET SslStream to implement the server-side of the HTTPS connection for the Kestrel server. I assume the server is also using CoreFx/CoreClr?

And if the server REQUIRES client certificates and the client is not sending any, then getting an error back would be expected, wouldn't it? The default settings for WinHttpHandler client certificate selection is manual and it looks at the .ClientCertificates property to find the certs. And since that property by default is an empty collection, there are no certs.

@tmds
Copy link
Member Author

tmds commented Nov 14, 2015

It looks like on the coreclr, clientCertificateRequired means Required and on the desktop frame it means Accept.
If clientCertificateRequired really means required, there is no way to specify Accept. If it means Accept, Require can be implemented in the validation callback.
That is the way it is used today (e.g.: http://stackoverflow.com/questions/26930398/sslstream-authenticateasserver-with-optional-clientcertificate)

@davidsh
Copy link
Contributor

davidsh commented Nov 14, 2015

Ok. So, this looks like a bug/app-compat-difference for System.Net.Security.SslStream API surface.

I wil re-title the bug and assign to the right people.

@davidsh davidsh changed the title WinHttpHandler gives security error when (invalid) server accepts client certificate SslStream.AuthenticateAsServer with client certificates doesn't allow for ACCEPT Nov 14, 2015
@davidsh davidsh assigned CIPop and unassigned davidsh Nov 14, 2015
@davidsh
Copy link
Contributor

davidsh commented Nov 14, 2015

@tmds
Copy link
Member Author

tmds commented Nov 14, 2015

Thanks @davidsh

@CIPop
Copy link
Contributor

CIPop commented Nov 16, 2015

@tmds / @davidsh Please provide a smple repro project or FunctionalTest for this issue with SslStream in CoreFX.

@tmds
Copy link
Member Author

tmds commented Nov 16, 2015

@CIPop @davidsh This isn't an issue. I forgot to pass the handler to the HttpClient. On the desktop framework this didn't cause an issue because the validation was done by the ServicePointManager. Sorry for the inconvenience.

@tmds tmds closed this as completed Nov 16, 2015
@CIPop
Copy link
Contributor

CIPop commented Nov 16, 2015

Not a problem. Thanks for following-up @tmds!

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-rtm milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants