fix: integrate mutual TLS scenario with underlying http.sys server #2044
Merged
DeagleGross merged 18 commits intoaspnet:mainfrom Jan 15, 2025
DeagleGross:dmkorolev/tls-httpsys-fixes
Merged
fix: integrate mutual TLS scenario with underlying http.sys server #2044DeagleGross merged 18 commits intoaspnet:mainfrom DeagleGross:dmkorolev/tls-httpsys-fixes
DeagleGross merged 18 commits intoaspnet:mainfrom
DeagleGross:dmkorolev/tls-httpsys-fixes
Conversation
BrennanConroy
approved these changes
Jan 15, 2025
Member
BrennanConroy
left a comment
There was a problem hiding this comment.
Nice, I am slightly worried if netsh fails to delete the configuration and leaves the machine in a setup state.
Contributor
Author
I am as well. I am thinking about 2 approaches:
i will try to do №2 a bit later today - it should be more robust |
Contributor
Author
|
decided to change the port to 8080 so that other tests are not impacted by http.sys configuration changes (if there would be) - just for safety. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
mTLS (mutual TLS) requires a separate setup from the server side. mTLS is valid, when clientCert is negotiated on the connection establishment, meaning when ASP.NET code calls
context.Connection.ClientCertificate: it should be already available and there must not be any need to invokecontext.Connection.GetClientCertificateAsync()in case of Kestrel setup is extremely easy - just set a specific enum value:
however in case of HTTP.SYS the only option is to execute a netsh command
netsh http add sslcert.I have added a code in ASP.NET application, which on start binds the test certificate using netsh command, and then using an applicationLifetime
ApplicationStoppingcallback it deletes the cert binding from the machine. It can be seem from the logs (below).Basically the order is the following:
clientcertnegotiation=enableto enable client cert negotiationoptionally)
netsh http show sslcertcan show the ssl cert bindings on a machine. Important property is "Negotiate Client Certificate : Enabled"netsh http delete sslcert