Skip to content

feat: rework TlsClientHelloBytesCallback as a connection middleware#65808

Merged
DeagleGross merged 13 commits intodotnet:mainfrom
DeagleGross:dmkorolev/tls/tlsclienthellocallback-asconnectionmiddleware
Apr 10, 2026
Merged

feat: rework TlsClientHelloBytesCallback as a connection middleware#65808
DeagleGross merged 13 commits intodotnet:mainfrom
DeagleGross:dmkorolev/tls/tlsclienthellocallback-asconnectionmiddleware

Conversation

@DeagleGross
Copy link
Copy Markdown
Member

@DeagleGross DeagleGross commented Mar 17, 2026

Obsoleted TlsClientHelloBytesCallback on HttpsConnectionAdapterOptions, and reworked that as a connection middleware

Fixes #64860

@github-actions github-actions Bot added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Mar 17, 2026
@DeagleGross DeagleGross force-pushed the dmkorolev/tls/tlsclienthellocallback-asconnectionmiddleware branch from 648e73d to 76e7405 Compare March 20, 2026 16:07
@DeagleGross DeagleGross changed the title [WIP] rework TlsClientHelloBytesCallback as a connection middleware feat: rework TlsClientHelloBytesCallback as a connection middleware Mar 20, 2026
@DeagleGross DeagleGross marked this pull request as ready for review March 20, 2026 17:05
Copilot AI review requested due to automatic review settings March 20, 2026 17:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR obsoletes HttpsConnectionAdapterOptions.TlsClientHelloBytesCallback and introduces a new ListenOptions connection middleware API (UseTlsClientHelloListener) to observe raw TLS ClientHello bytes in a way that also works with TlsHandshakeCallbackOptions scenarios.

Changes:

  • Add ListenOptionsHttpsExtensions.UseTlsClientHelloListener(...) as a connection middleware that sniffs ClientHello bytes before UseHttps().
  • Mark HttpsConnectionAdapterOptions.TlsClientHelloBytesCallback as obsolete and keep back-compat support inside HttpsConnectionMiddleware.
  • Add functional tests and a sample usage demonstrating the new middleware API.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/Servers/Kestrel/test/InMemory.FunctionalTests/TlsListenerTests.cs Adds tests for new UseTlsClientHelloListener behavior and preserves back-compat tests for the obsolete option.
src/Servers/Kestrel/samples/SampleApp/Startup.cs Demonstrates calling UseTlsClientHelloListener before UseHttps().
src/Servers/Kestrel/Core/src/PublicAPI.Unshipped.txt Declares the new public API surface for UseTlsClientHelloListener.
src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs Continues to support the obsolete TlsClientHelloBytesCallback path (pragma-suppressed).
src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs Introduces the new connection middleware extension and its default timeout.
src/Servers/Kestrel/Core/src/HttpsConnectionAdapterOptions.cs Obsoletes TlsClientHelloBytesCallback and updates docs to point to the new API.

Comment thread src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs Outdated
Comment thread src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs Outdated
Comment thread src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs
Comment thread src/Servers/Kestrel/Core/src/HttpsConnectionAdapterOptions.cs Outdated
Comment thread src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs
Comment thread src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs Outdated
@halter73
Copy link
Copy Markdown
Member

halter73 commented Apr 9, 2026

You can just put the fixups for #65807 in this PR

Comment thread src/Servers/Kestrel/Core/src/ListenOptionsHttpsExtensions.cs Outdated
@DeagleGross DeagleGross enabled auto-merge (squash) April 10, 2026 09:29
@DeagleGross DeagleGross merged commit d7f8b2f into dotnet:main Apr 10, 2026
25 checks passed
@dotnet-policy-service dotnet-policy-service Bot added this to the 11.0-preview4 milestone Apr 10, 2026
@DeagleGross DeagleGross deleted the dmkorolev/tls/tlsclienthellocallback-asconnectionmiddleware branch April 10, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TlsClientHelloBytesCallback missing on TlsHandshakeCallbackOptions.

4 participants