Skip to content

Preserve TLS channel binding when forwarding client certificates - #69982

Open
GrantTotinov wants to merge 1 commit into
dotnet:mainfrom
GrantTotinov:preserve-tls-channel-binding-69649
Open

GrantTotinov wants to merge 1 commit into
dotnet:mainfrom
GrantTotinov:preserve-tls-channel-binding-69649

Conversation

@GrantTotinov

Copy link
Copy Markdown
Contributor

Preserve TLS channel binding when forwarding client certificates

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Keep TLS channel binding when the client cert feature is replaced

Description

When a client certificate header is present, CertificateForwardingMiddleware and IISMiddleware swap in their own ITlsConnectionFeature. Neither replacement implemented TryGetChannelBindingBytes, so the default interface method returned false and Negotiate quietly ran without channel binding on HTTPS requests that did have one.

Changes:

  • CertificateForwardingFeature and ForwardedTlsConnectionFeature now keep the feature they replace and delegate TryGetChannelBindingBytes to it. With no original feature they return false and an empty token. Both types are internal, so there's no public API change.
  • The Kestrel ClientCertBufferingFeature sample delegates the method as well.
  • The XML docs on ITlsConnectionFeature.TryGetChannelBindingBytes now say that wrappers/replacements must delegate.
  • NegotiateHandler logs at debug level (ChannelBindingUnavailable) when an HTTPS request has no channel binding, so the degraded mode is visible.

Tests:

  • CertificateForwardingTests and IISMiddlewareTests: delegation to a fake original feature, plus the no-original-feature case.
  • NegotiateHandlerTests: UseCertificateForwarding() before authentication with the header present, asserting the state gets the connection's binding (fails without the fix). The existing no-binding theory now also checks the new log.

About proxies that present a different certificate

The only case that behaves differently is when the app server itself terminates TLS behind a proxy that uses a different certificate, and the cert header is present. Those setups already fail Negotiate with channel binding today for any request without the header, because the client binds to the proxy's certificate. They only "worked" when the header happened to be there and the binding got dropped. After this change the result no longer depends on the header. When the proxy forwards plain HTTP to the app (including IIS out-of-process), there's no original TLS feature and nothing changes.

I didn't add an opt-out since it would be new public API whose only job is to turn the protection off. A short docs note that channel binding needs the app server to terminate the client's TLS (or share the proxy's certificate) seems like enough to me, especially since this is all new in 11.0 and hasn't shipped in GA yet. Happy to add a breaking-change note instead if you think it's warranted.

Fixes #69649

CertificateForwardingMiddleware and IISMiddleware replace the request's
ITlsConnectionFeature when a client certificate header is present. The
replacement features did not implement TryGetChannelBindingBytes, so the
default interface implementation returned false and Negotiate silently
ran without channel binding on HTTPS requests.

The replacement features now delegate TryGetChannelBindingBytes to the
server's original feature. The Kestrel ClientCertBufferingFeature sample
delegates too, the ITlsConnectionFeature docs state the delegation
requirement, and NegotiateHandler logs at debug level when an HTTPS
request has no channel binding.

Fixes dotnet#69649
Copilot AI balanced review requested due to automatic review settings October 23, 2026 01:55

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added area-auth Includes: authentication, authorization, OAuth, OIDC, and access token validation area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions labels Oct 23, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 23, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Thanks for your PR, @GrantTotinov. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Looks like this PR hasn't been active for some time and the codebase could have been changed in the meantime.
To make sure no conflicting changes have occurred, please rerun validation before merging. You can do this by leaving an /azp run comment here (requires commit rights), or by simply closing and reopening.

@dotnet-policy-service dotnet-policy-service Bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Oct 30, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — e2d9a46a Deployed Oct 23, 2026 by dotnet-policy-service[bot] via pat_pool #1929
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-auth Includes: authentication, authorization, OAuth, OIDC, and access token validation area-middleware Includes: URL rewrite, redirect, response cache/compression, session, and other general middlewares area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions community-contribution Indicates that the PR has been added by a community member 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.

Certificate forwarding replaces ITlsConnectionFeature without preserving TLS channel binding

2 participants