Skip to content

Add TLS channel binding token access to ITlsConnectionFeature - #67436

Merged
DeagleGross merged 14 commits into
dotnet:mainfrom
DeagleGross:dmkorolev/tls-channel-binding
Jul 9, 2026
Merged

Add TLS channel binding token access to ITlsConnectionFeature#67436
DeagleGross merged 14 commits into
dotnet:mainfrom
DeagleGross:dmkorolev/tls-channel-binding

Conversation

@DeagleGross

@DeagleGross DeagleGross commented Jun 26, 2026

Copy link
Copy Markdown
Member

Implements approved API in the #66701. Adds new bool TryGetChannelBindingBytes(ChannelBindingKind kind, out ReadOnlyMemory<byte> channelBindingToken) method to ITlsConnectionFeature. Default implementation returns false.

Supported in Kestrel, HttpSys and IIS, where HttpSys uses HttpAuthenticationHardeningLevel as option to enable/disable it (defaults to Medium which means enabled). Kestrel leverages SslStream to call SslStream.TransportContext.GetChannelBinding(kind). Added code to sample app to try this out.

Closes #66701

@DeagleGross DeagleGross self-assigned this Jun 26, 2026
@DeagleGross DeagleGross added the area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions label Jun 26, 2026
@DeagleGross DeagleGross changed the title Add API to access TLS channel binding tokens Add TLS channel binding token access to ITlsConnectionFeature Jul 7, 2026
@DeagleGross
DeagleGross marked this pull request as ready for review July 7, 2026 16:07
Copilot AI review requested due to automatic review settings July 7, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 adds a new ITlsConnectionFeature.TryGetChannelBindingBytes(ChannelBindingKind, out ReadOnlyMemory<byte>) API to expose RFC 5929 TLS channel binding token (CBT) bytes to apps, with server-specific implementations for Kestrel, HttpSys, and IIS. It also deprecates the abandoned ITlsTokenBindingFeature (RFC 8471) and includes sample/test updates to exercise the new CBT access.

Changes:

  • Add TryGetChannelBindingBytes to ITlsConnectionFeature with a default implementation that returns false.
  • Implement CBT retrieval in Kestrel (via SslStream.TransportContext.GetChannelBinding) and in HttpSys/IIS (via HTTP_REQUEST_CHANNEL_BIND_STATUS).
  • Introduce/configure HttpSys hardening option (HttpAuthenticationHardeningLevel) and update samples/tests + PublicAPI baselines.
Show a summary per file
File Description
src/Shared/Obsoletions.cs Adds deprecation URL/diagnostic/message constants for ITlsTokenBindingFeature.
src/Shared/HttpSys/RequestProcessing/NativeRequestContext.cs Adds safe-ish extraction/copying of CBT bytes from http.sys request info after buffer unpinning.
src/Shared/HttpSys/NativeInterop/HTTP_REQUEST_CHANNEL_BIND_STATUS.cs Adds interop struct for channel bind status returned by http.sys.
src/Servers/Kestrel/test/InMemory.FunctionalTests/HttpsConnectionMiddlewareTests.cs Adds Windows-only test validating endpoint CBT shape/content.
src/Servers/Kestrel/Core/src/Middleware/HttpsConnectionMiddleware.cs Passes logger into TLS feature and adds debug log for CBT read failures.
src/Servers/Kestrel/Core/src/Internal/TlsConnectionFeature.cs Implements TryGetChannelBindingBytes for Kestrel via SslStream.TransportContext.
src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs Implements TryGetChannelBindingBytes (Endpoint-only) and caches per-request bytes.
src/Servers/IIS/IIS/samples/NativeIISSample/Startup.cs Adds sample output showing CBT retrieval / IIS config guidance.
src/Servers/HttpSys/src/SourceBuildStubs.cs Adds source-build stubs for HttpAuthenticationHardeningLevel and options property.
src/Servers/HttpSys/src/RequestProcessing/RequestContext.FeatureCollection.cs Implements TryGetChannelBindingBytes (Endpoint-only) gated by new hardening option.
src/Servers/HttpSys/src/PublicAPI.Unshipped.txt Records new public API surface for HttpSys hardening enum/option.
src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs Sets HttpServerChannelBindProperty to enable per-request CBT delivery via URL group property.
src/Servers/HttpSys/src/HttpSysOptions.cs Adds HttpAuthenticationHardeningLevel option (default Medium) and applies URL group settings.
src/Servers/HttpSys/src/HttpAuthenticationHardeningLevel.cs Adds public enum mirroring Win32 hardening levels + CBT exposure behavior.
src/Servers/HttpSys/samples/TlsFeaturesObserve/TlsFeaturesObserve.csproj Updates sample references (includes a new CORS reference).
src/Servers/HttpSys/samples/TlsFeaturesObserve/Program.cs Adds middleware that reads/parses CBT bytes and prints them.
src/Http/Http.Features/src/PublicAPI.Unshipped.txt Records new ITlsConnectionFeature.TryGetChannelBindingBytes API.
src/Http/Http.Features/src/Microsoft.AspNetCore.Http.Features.csproj Links shared Obsoletions.cs for use by obsoletion attributes.
src/Http/Http.Features/src/ITlsTokenBindingFeature.cs Marks ITlsTokenBindingFeature as obsolete with new diagnostic metadata.
src/Http/Http.Features/src/ITlsConnectionFeature.cs Adds new TryGetChannelBindingBytes method with default interface implementation.

Copilot's findings

  • Files reviewed: 20/20 changed files
  • Comments generated: 7

Comment thread src/Shared/HttpSys/NativeInterop/HTTP_REQUEST_CHANNEL_BIND_STATUS.cs Outdated
Comment thread src/Servers/HttpSys/src/SourceBuildStubs.cs Outdated
Comment thread src/Servers/HttpSys/samples/TlsFeaturesObserve/Program.cs
Comment thread src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs Outdated
Comment thread src/Servers/HttpSys/src/HttpSysOptions.cs Outdated
Comment thread src/Http/Http.Features/src/ITlsConnectionFeature.cs
Comment thread src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs
Comment thread src/Servers/HttpSys/src/RequestProcessing/RequestContext.FeatureCollection.cs Outdated
Comment thread src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs Outdated
Comment thread src/Servers/Kestrel/Core/src/Internal/TlsConnectionFeature.cs Outdated
Comment thread src/Shared/HttpSys/NativeInterop/HTTP_REQUEST_CHANNEL_BIND_STATUS.cs Outdated
Comment thread src/Shared/Obsoletions.cs Outdated
Comment thread src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs Outdated
Comment thread src/Servers/HttpSys/test/FunctionalTests/HttpsTests.cs Outdated
Comment thread src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs Outdated
@DeagleGross
DeagleGross merged commit 1ae00e6 into dotnet:main Jul 9, 2026
25 checks passed
@DeagleGross
DeagleGross deleted the dmkorolev/tls-channel-binding branch July 9, 2026 16:10
Comment thread src/Servers/HttpSys/src/NativeInterop/UrlGroup.cs
DeagleGross added a commit to DeagleGross/aspnetcore that referenced this pull request Jul 10, 2026
When HttpAuthenticationHardeningLevel.Strict is configured, the caller
is asking for a hard security guarantee (reject authenticated requests
that lack a valid channel binding token). Silently degrading to the OS
default hardening on a SetProperty failure is misleading, so throw and
fail startup instead.

Legacy/Medium continue to log-and-continue via SetUrlPropertyError.

Follow-up to dotnet#67436 addressing
dotnet#67436 (comment).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview7 milestone Jul 11, 2026
DeagleGross added a commit that referenced this pull request Jul 13, 2026
When HttpAuthenticationHardeningLevel.Strict is configured, the caller
is asking for a hard security guarantee (reject authenticated requests
that lack a valid channel binding token). Silently degrading to the OS
default hardening on a SetProperty failure is misleading, so throw and
fail startup instead.

Legacy/Medium continue to log-and-continue via SetUrlPropertyError.

Follow-up to #67436 addressing
#67436 (comment).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add HttpSys support for accessing TLS channel binding tokens

5 participants