-
Notifications
You must be signed in to change notification settings - Fork 10.3k
feat: support tls client hello bytes callback in Kestrel #61631
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
base: main
Are you sure you want to change the base?
Conversation
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM -- just a small comment.
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/test/InMemory.FunctionalTests/TlsListenerMiddlewareTests.cs
Show resolved
Hide resolved
src/Servers/Kestrel/test/InMemory.FunctionalTests/TlsListenerMiddlewareTests.Units.cs
Outdated
Show resolved
Hide resolved
@@ -197,6 +198,15 @@ public static ListenOptions UseHttps(this ListenOptions listenOptions, HttpsConn | |||
listenOptions.IsTls = true; | |||
listenOptions.HttpsOptions = httpsOptions; | |||
|
|||
if (httpsOptions.TlsClientHelloBytesCallback is not null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add this for the other UseHttps overload at the bottom of the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it has a different use case (allows setup via TlsHandshakeCallbackOptions
), but I added a check if (listenOptions.HttpsOptions?.TlsClientHelloBytesCallback is not null)
Configure Kestrel to use HTTPS. This does not use default certificates or other defaults specified via config or
KestrelServerOptions.ConfigureHttpsDefaults(Action)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not use default certificates or other defaults specified via config or
KestrelServerOptions.ConfigureHttpsDefaults(Action)
Probably shouldn't add it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it does raise the question about client hello in that case. It also shows we have a client hello API already (although not very good) https://source.dot.net/#Microsoft.AspNetCore.Server.Kestrel.Core/TlsHandshakeCallbackContext.cs,97120719b6888c33,references
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to move the callback to TlsHandshakeCallbackOptions
, but it requires setting OnConnection, and I dont think it should be required for TLS client hello.
I personally would leave it where we designed it - in HttpsConnectionAdapterOptions
. Let me know what you think!
(talked with @halter73 about it as well)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I removed registration from overload using TlsHandshakeCallbackOptions
, because it can result in 2 registrations of the middleware
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/Core/src/Middleware/TlsListenerMiddleware.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/test/InMemory.FunctionalTests/TlsListenerMiddlewareTests.Units.cs
Outdated
Show resolved
Hide resolved
src/Servers/Kestrel/test/InMemory.FunctionalTests/TlsListenerMiddlewareTests.Units.cs
Outdated
Show resolved
Hide resolved
… duplicate registration
add tests for SSL 2.0 and SSL 3.0 |
done |
Supporting TLS Client Hello callback in Kestrel
HTTP.SYS contribution was done in this PR
Description
Adding a new property to
HttpsConnectionAdapterOptions
-TlsClientHelloBytesCallback
(added to public API).It allows to subscribe to the TLS client hello message parsed from the
ConnectionContext.Transport.Input
:If property
HttpsConnectionAdapterOptions.TlsClientHelloBytesCallback
is set (not null), then new middleware is added beforeHttpsConnectionMiddleware
.The implementation is doing the following:
Fixes #60805