Authenticating a client with a certificate
A client can prove who it is with a TLS client certificateA signed statement that a public key belongs to a name, such as a website's hostname, for stated purposes and a limited period. A certificate authority signs it, so software that trusts the authority can connect the key to the name. and the private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. behind it, so the tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. request itself carries no credential. This lesson follows the printer's order service as the print lab moves it off its client secretA shared secret that a confidential client uses to prove itself to the authorization server, much like a password for an application. It belongs on a backend, never in code sent to browsers or phones., compares the two certificate methods RFC 8705 defines, and explains why mutual TLS gets endpoint addresses of its own.
A certificate on both sides
Every evening the printer's order service, registered at the print lab as printer-orders, gets a token with the client credentials grant and submits the day's photo books, as Client credentials followed. It proved itself with a client secret in a Basic header. The print lab now wants its partners off shared secrets. It already runs a small certificate authority of its own for partner systems, and it would like each partner to prove itself the way servers already do on every HTTPSHTTP protected by TLS, so traffic is encrypted and checked for changes while it travels. It protects the connection, but does not prove that the site at the other end is honest. connection: with a certificate and the private key behind it.
OAuth 2.0A framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. Mutual-TLS Client Authentication and Certificate-Bound Access Tokens, published as RFC 8705, describes how. It defines two ways to use a TLS client certificate as an OAuth client's credential, and a way to bind tokens to that certificate, which Certificate-bound access tokens follows.
In an ordinary HTTPS connection, only the server presents a certificate and proves during the TLS handshake that it holds the matching private key. Validating a certificate followed the client's side of those checks. In mutual TLS, often shortened to mTLS, which Service-to-service access mentioned for internal calls, the server also asks the client for a certificate. The client sends one and signs part of the handshake with its private key, and the server checks both before any HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. request is exchanged.
All domains, identifiers, and tokens in these examples are fictional. The print lab issued the order service this certificate, shown in the same simplified decoding as What a certificate says:
Certificate:
Serial Number: 5c:1a:7e:22:09:d4
Signature Algorithm: ecdsa-with-SHA256
Issuer: O=Printlab, CN=Printlab Partner CA 1
Validity
Not Before: Sep 15 00:00:00 2026 GMT
Not After : Dec 14 23:59:59 2026 GMT
Subject: O=Photo Printer, CN=orders.printer.example
Subject Public Key Info:
Public Key Algorithm: id-ecPublicKey
Public-Key: (256 bit), curve P-256
X509v3 extensions:
Subject Alternative Name:
DNS:orders.printer.example
Key Usage: critical
Digital Signature
Extended Key Usage:
TLS Web Client Authentication
Basic Constraints: critical
CA:FALSEThree details matter here. The issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts. is the print lab's own partner CA, a private PKIPublic key infrastructure: certificates, the certificate authorities that issue them, and the rules and systems that manage them, which together let software trust that a public key belongs to a name. that only the print lab's systems trust, as Certificate authorities and chains described. The extended key usage allows TLS client authentication, not server authentication, so this certificate identifies a caller rather than a website. And the subject alternative name, orders.printer.example, is the name the print lab will look for.
As with private_key_jwt in Secrets and signed assertions, the private key never travels. The difference is where the proof happens. A client assertion is a signed JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing. inside the HTTP request. Mutual TLS proves possession of the key in the connection underneath, so the token request itself carries no credential at all.
Matching the certificate to a client
Over that connection, the order service sends its token request:
POST /token HTTP/1.1
Host: mtls.auth.printlab.example
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
&client_id=printer-orders
&scope=print-jobs.writeThere is no Authorization header and no secret in the body. The client_id is required, though: it tells the authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. which registration to check the certificate against, instead of leaving it to guess the client from the certificate's contents.
The print lab registered the order service for the first of the two methods:
{
"client_id": "printer-orders",
"token_endpoint_auth_method": "tls_client_auth",
"tls_client_auth_san_dns": "orders.printer.example",
"grant_types": ["client_credentials"],
"scope": "print-jobs.write"
}With tls_client_auth, the server relies on a certificate authority. The TLS handshake has already shown that the client holds the private key and that the certificate chains to a CA the server trusts for this purpose. The server then compares the certificate with the one subject value the registration expects. A registration names exactly one: the subject distinguished name, or a single subject alternative name of type DNSThe Domain Name System, the internet's lookup service that turns a domain such as photos.example into the address of the computer serving it. Whoever controls a name's DNS records controls where that name points., URI, IP address or email. Here the certificate's DNS name matches orders.printer.example, so the order service is authenticated as printer-orders.
Both conditions must hold. A certificate for reports.printer.example from the same partner CA is refused because the name is not the one registered, and a certificate naming orders.printer.example from a CA the print lab never chose to trust is refused because nobody it trusts vouches for it.
The order service's certificate
- Issuer
- Printlab Partner CA 1
- DNS name
- orders.printer.example
- Trusted CA
- Yes
- Name registered
- Yes
Authenticated as printer-orders
Same CA, another name
- Issuer
- Printlab Partner CA 1
- DNS name
- reports.printer.example
- Trusted CA
- Yes
- Name registered
- No
invalid_client
Right name, untrusted CA
- Issuer
- A CA never chosen
- DNS name
- orders.printer.example
- Trusted CA
- No
- Name registered
- Yes
invalid_client
Both conditions must hold.
The second method, self_signed_tls_client_auth, needs no CA at all. The client creates its own self-signed certificate and registers the certificate itself, either in the registration's jwks value or in a key set published at its jwks_uri, the same key set formats JWKS, key sets, and key IDs described. Each entry is a JWK whose x5c member holds the certificate:
{
"keys": [
{
"kty": "EC",
"crv": "P-256",
"x": "...",
"y": "...",
"x5c": ["MIIB..."]
}
]
}The values are shortened here. The server builds no chain for this method. It authenticates the client when the certificate presented in the handshake is exactly one of the certificates registered for that client.
| Question | tls_client_auth | self_signed_tls_client_auth |
|---|---|---|
| Who vouches for the certificate? | A CA the server trusts for client certificates | No one. The registration itself is the trust |
| What does the registration hold? | One expected subject value | The certificates, or the address of a key set holding them |
| What does a renewal need? | A new certificate with the same subject. The registration does not change | The new certificate added to the registered set before it is used |
| Fits best when | An organization or ecosystem already runs a PKI | There is no PKI and clients are few |
Either way, a missing certificate or one that does not match the registration produces the same response as any other failed client authentication: invalid_client, with no hint about which part was wrong.
Separate addresses for mutual TLS
The request above went to mtls.auth.printlab.example, not to auth.printlab.example. The reason lies in how TLS works. A server must ask for a client certificate during the handshake, before it sees the HTTP request, so it cannot ask only the clients that intend to use one. Browsers react badly to being asked: they often show a certificate selection window to the person in front of them. The print lab's authorization server also serves sign-in and consent pages to browsers, and it does not want them disturbed.
So it offers separate addresses for clients that use mutual TLS and lists them in its metadata document, the published description of the server that Reading provider metadata read for an OpenID provider:
{
"issuer": "https://auth.printlab.example",
"token_endpoint": "https://auth.printlab.example/token",
"token_endpoint_auth_methods_supported": [
"client_secret_basic",
"tls_client_auth",
"self_signed_tls_client_auth"
],
"mtls_endpoint_aliases": {
"token_endpoint": "https://mtls.auth.printlab.example/token"
}
}mtls_endpoint_aliases holds alternative addresses for endpoints that clients call directly, such as the token, revocation and introspection endpoints. A client that uses mutual TLS must use the alias when one is listed, and the ordinary address for any endpoint that has none. The authorization endpoint has no place there: the client never calls it directly, and the browsers that do visit it are never asked for a certificate.
Current security guidance recommends asymmetric client authentication, with mutual TLS and private_key_jwt as its examples, because the server then stores nothing that could be used to impersonate the client. Mutual TLS asks more of the infrastructure, certificates to issue and renew and network equipment that has to pass certificate details along, and in return the same certificate can do a second job: binding the print lab's access tokens to the order service.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Authenticate the order service with a client certificateRun a small partner CA, trust it in Lab Photos, and get tokens with tls_client_auth and then self_signed_tls_client_auth, with no secret in the request.