0Pricing
OAuth2 & OpenID Connect Deep Dive · 课时

使用 mTLS 的发送方约束令牌

了解双向 TLS 客户端证书绑定如何将持有者令牌转换为发送方约束令牌,阻止攻击者重放窃取的令牌。

使用 mTLS 的发送方约束令牌 是 CoddyKit 上的免费 OAuth2 & OpenID Connect Deep Dive 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 OAuth2 & OpenID Connect Deep Dive 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 OAuth2 & OpenID Connect Deep Dive 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

The Bearer Token Weakness

A plain bearer token works for anyone who holds it. If it leaks via logs, a proxy, or an XSS bug, the thief can use it freely. Sender-constrained tokens fix this by binding the token to the legitimate client.

What Is mTLS?

Mutual TLS means both sides present certificates: the server proves its identity (as usual) and the client also presents a certificate. The authorization server can then bind issued tokens to that client certificate.

RFC 8705

This is standardized in RFC 8705 (OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens). It covers both client authentication via mTLS and certificate binding of access tokens.

The cnf Claim

When the AS issues a certificate-bound token, it records a confirmation (cnf) claim containing the SHA-256 thumbprint of the client certificate under the key x5t#S256.

{
  "sub": "client-app",
  "cnf": {
    "x5t#S256": "bwcK0esc3ACC3DB2Y5_lESsXE8o9ltc05O89jdN-dg2"
  }
}

Resource Server Check

When the client calls an API over mTLS, the resource server computes the thumbprint of the presented certificate and compares it to the token's cnf.x5t#S256. If they differ, the token is rejected.

thumb = sha256(der_of_client_cert)
if base64url(thumb) != token.cnf['x5t#S256']:
    reject('certificate binding mismatch')

Why a Stolen Token Is Useless

Even with the token, an attacker cannot present the client's private key, so they cannot complete the mTLS handshake with the matching certificate. The thumbprint will not match, and the API rejects them.

mTLS Client Authentication

RFC 8705 also lets clients authenticate at the token endpoint with their certificate instead of a shared secret, using methods tls_client_auth (PKI) or self_signed_tls_client_auth.

mTLS Endpoint Aliases

Because mTLS needs a separate TLS configuration, providers publish mtls_endpoint_aliases in discovery so clients hit the certificate-bound versions of the token and other endpoints.

{
  "mtls_endpoint_aliases": {
    "token_endpoint": "https://mtls.op.example.com/token"
  }
}

mTLS vs DPoP

Both achieve sender-constraint:

  • mTLS — relies on TLS-layer certificates, great for server-to-server and infrastructure with PKI.
  • DPoP — application-layer proof JWTs, better for browser/public clients that cannot manage client certs.

Operational Considerations

mTLS requires certificate provisioning, rotation, and a TLS terminator that forwards the client cert to your app. Plan for cert lifecycle and ensure your reverse proxy passes the verified certificate to the resource server.

When to Adopt It

Choose mTLS-bound tokens for high-assurance, regulated, or financial-grade APIs and trusted backend services where certificate management is feasible. It dramatically raises the cost of token theft.

Quick Check

Test your mTLS binding knowledge.

Recap

mTLS sender-constrained tokens (RFC 8705) bind a token to the client's certificate.

  • The token carries a cnf.x5t#S256 certificate thumbprint.
  • Resource servers match the presented cert's thumbprint; a stolen token without the private key fails.
  • mTLS also enables certificate-based client authentication and uses mtls endpoint aliases.
  • Compare with DPoP for public clients.

常见问题解答

「使用 mTLS 的发送方约束令牌」课时是免费的吗?

是的 — 「使用 mTLS 的发送方约束令牌」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 OAuth2 & OpenID Connect Deep Dive 课程的其余内容,请升级到 CoddyKit PRO。 OAuth2 & OpenID Connect Deep Dive 课程共包含 4 节课。

「使用 mTLS 的发送方约束令牌」这节课中我会学到什么?

了解双向 TLS 客户端证书绑定如何将持有者令牌转换为发送方约束令牌,阻止攻击者重放窃取的令牌。 你通过在浏览器中直接运行的动手代码来练习 OAuth2 & OpenID Connect Deep Dive,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 OAuth2 & OpenID Connect Deep Dive 需要有经验吗?

无需任何先前经验。CoddyKit 上的 OAuth2 & OpenID Connect Deep Dive 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。

「使用 mTLS 的发送方约束令牌」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 OAuth2 & OpenID Connect Deep Dive 课中编写并运行代码吗?

能。每节 OAuth2 & OpenID Connect Deep Dive 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 同意与用户体验
  2. 跨源资源共享(CORS)
  3. 前端通道与后端通道注销
  4. 使用 mTLS 的发送方约束令牌
← 返回 OAuth2 & OpenID Connect Deep Dive