Skip to content

Lesson 7 of 9 · 25m

Mutual TLS in Production

mTLS replaces bearer-token ambiguity with cryptographic client identity, but only when authorization, rotation, and failure behavior are designed rather than assumed.

Mutual TLS sounds simple: the server proves its identity, the client proves its identity, both sides encrypt. In production, cryptography is the easy half. The hard part is deciding what the client certificate means, how authorization consumes it, and how rotation happens without turning every service into a snowflake.

mTLS is authentication, not authorization

A valid client certificate proves possession of a private key issued under some trust policy. It does not inherently mean the caller may invoke /admin/delete. Authorization must map certificate identity to permissions.

Identity may come from a SAN URI such as a SPIFFE ID, a DNS SAN, a controlled CN in an internal-only system, or certificate attributes consumed by a proxy:

spiffe://sudosecurity.internal/ns/payments/sa/ledger-writer

The advantage over a bearer token is theft resistance in motion and automatic rotation. The disadvantage is that operators often stop thinking after the handshake succeeds.

Where verification should happen

Terminate mTLS at the layer that can enforce identity semantics consistently:

client --mTLS--> service mesh sidecar --localhost--> application
client --mTLS--> ingress/API gateway --identity headers--> application
client --mTLS--> application directly

If a proxy forwards identity headers, it must strip or overwrite those headers from untrusted clients. Otherwise you have invented an impersonation protocol.

ssl_client_certificate /etc/nginx/pki/services-ca-chain.pem;
ssl_verify_client on;
ssl_verify_depth 2;
proxy_set_header X-Client-Cert-CN $ssl_client_s_dn_cn;
proxy_set_header X-Client-Cert-Verify $ssl_client_verify;

Do not blindly trust a subject CN as the complete identity. Parse and validate according to your naming policy.

Rotation is the normal path

Client certificates should rotate often because they are distributed widely. Automation needs overlap: present the new certificate, verify service acceptance, then retire the old private key. Hard cutovers create synchronized outages.

Decide what happens when the identity control plane is unavailable. Existing connections usually continue; new connections fail if credentials expired; cached credentials keep working until cache expiry. Short lifetimes reduce stolen-key value but increase dependency on issuance availability.

For end users, passkeys, OIDC, or sessions still authenticate the person. A laptop certificate strongly identifies a device, but a device is not a person.

Field notes

  • Reject broad acceptance of any certificate signed by the internal CA; check identity and EKU.
  • Prefer machine-readable SAN identities over display strings in subject fields.
  • Test what happens when a client certificate expires mid-connection.
  • Keep server-verification and client-verification CA bundles separate when trust domains differ.
  • mTLS is not a reason to stop validating input or enforcing application authorization.

Was this lesson helpful?

Sign in to rate