Skip to content
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

Enable SslStream server options per-hostname (in callback) #31097

Closed
avparuch opened this issue Oct 7, 2019 · 7 comments
Closed

Enable SslStream server options per-hostname (in callback) #31097

avparuch opened this issue Oct 7, 2019 · 7 comments
Labels
area-System.Net.Security enhancement Product code improvement that does NOT require public API changes/additions
Milestone

Comments

@avparuch
Copy link

avparuch commented Oct 7, 2019

Hello,

Our service is a reverse proxy running on IIS (on top of HttpSys). We are moving to .NET core and while running on Kestrel, ran into a scenario blocker with client certificates.

In our current application, we use HttpSys APIs to configure client certificate negotiation per hostname and also to set up CTL stores.

The specific API we use is : https://docs.microsoft.com/en-us/windows/win32/http/add-sslcert

Examples of usage:

  1. netsh http add sslcert hostnameport=a.b.microsoftonline.com:443
    certhash=EC9CA6E0E645AAB24F8AD890DF75A448824D2C37 appid='{4dc3e181-e14b-4a21-b022-59fc669b0914}' certstorename=MY
    verifyclientcertrevocation=disable

  2. netsh http add sslcert hostnameport=c.windows.net:443
    certhash=EB3C3B94F10E948463929BCF4C7000C1E7BD0AC1 appid='{4dc3e181-e14b-4a21-b022-59fc669b0914}' certstorename=MY
    clientcertnegotiation=enable verifyclientcertrevocation=disable

  3. netsh http add sslcert hostnameport=device.a.b.microsoftonline.com:443
    certhash=963B55D3E94101B70F1654FBF90D6006BAFAD513 appid='{4dc3e181-e14b-4a21-b022-59fc669b0914}' certstorename=MY
    clientcertnegotiation=enable verifyclientcertrevocation=disable sslctlstorename=DeviceLoginCTLStore

We want the ability to perform these operations in the Kestrel webserver. (The workaround of using the HttpSysServer does not work for us, I will not go into the reasons in this issue, I will create a separate one for that).

Kestrel already provides SNI support (ability to select server certificate on a per hostname basis). However, the problem is that the client certificate negotiation (and CTL store) support is application wide and not per hostname.

https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.server.kestrel.https.clientcertificatemode?view=aspnetcore-2.2#Microsoft_AspNetCore_Server_Kestrel_Https_ClientCertificateMode_NoCertificate.

To be specific:

  1. When a SNI binding is set up in Kestrel, provide the ability to enable/disable client certificate negotiation. (an equivalent to the "clientcertnegotiation" property in HttpSys.)
  2. When a SNI binding is set up in Kestrel, provide the ability to select the exact CTL store for this binding. (an equivalent to the "sslctlstorename" property in HttpSys)
  3. When a SNI binding is set up in Kestrel, provide the ability to turn on or off the verification of revocation of client certificates.
    (an equivalent to the "verifyclientcertrevocation" property in HttpSys.)

This is a major blocker for us to migrate to .NET core.

@davidsh
Copy link
Contributor

davidsh commented Oct 7, 2019

@Tratcher This issue should be moved to aspnetcore repo.

@davidfowl
Copy link
Member

@davidsh Seems like this would require an SSLStream change?

@Tratcher
Copy link
Member

Tratcher commented Oct 7, 2019

@davidsh they're asking to be able to reconfigure the SslServerAuthenticationOptions from inside the ServerCertificateSelectionCallback based on the given SNI host name.

I've heard a similar request asking to be able to enable/disable TLS versions based on the SNI data.

@davidsh
Copy link
Contributor

davidsh commented Oct 8, 2019

@davidsh they're asking to be able to reconfigure the SslServerAuthenticationOptions from inside the ServerCertificateSelectionCallback based on the given SNI host name.
I've heard a similar request asking to be able to enable/disable TLS versions based on the SNI data.

Thanks for clarifying. Would this be an API change to SslServerAuthenticationOptions or perhaps just a behavior change of some kind, triggered by an perhaps a new opt-in SslStream-related property?

This needs some design work.

@Tratcher
Copy link
Member

Tratcher commented Oct 8, 2019

We'd have to experiment. ServerCertificateSelectionCallback passes in the SslStream as an object, casting that isn't too hard. From there I anticipate adding an API to surface the SslServerAuthenticationOptions, as well as some behavioral changes to delay reading as many of the settings from the options until after the callback. E.g. TLS version, client certs, etc..

@karelz karelz changed the title Kestrel support for Client negotiation on a per hostname basis. Enable SslStream server options per-hostname (in callback) Oct 9, 2019
@karelz
Copy link
Member

karelz commented Oct 9, 2019

Triage: Sounds like reasonable request. It may need new API.

@wfurt
Copy link
Member

wfurt commented Jul 15, 2020

should be fixed by #38760.

@wfurt wfurt closed this as completed Jul 15, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 12, 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

No branches or pull requests

7 participants