Free & open · no paywall, ever

IntegrAuth Academy

Identity, security and practical AI — free, from zero. Byte-sized lessons, real diagrams, hands-on labs, zero fluff. Two programs, each with its own exam and certificate.

20 tracks 241 lessons 242 hands-on labs 230+ diagrams 100% free

English is hard? Your browser can translate this page into Tamil, Telugu, Kannada, Malayalam or Hindi. Tech words stay in English so you learn the real names.

How?
  • Chrome on phone: ⋮ menu → Translate
  • Chrome on computer: right-click → Translate to …
  • Edge: the translate icon in the address bar
Identity & API Security Track 6 · API Security
0/166 lessons read
API SECURITY · LESSON 4

TLS and mutual TLS in practice

Every API call in this track travels inside an encrypted tunnel. At 2 a.m. Bot A opens one to the billing API. Your goal: know what TLS proves and what it does not. See how mutual TLS makes the caller prove itself. Spot the proxy mistakes that undo both.

Key points
  • TLS gives secrecy, integrity and server identity. Nothing more.
  • In mutual TLS, the client proves itself with a certificate too.
  • Match a client certificate to a caller by one exact field.
  • A proxy must remove identity headers that come from outside.

What TLS gives you, and what it does not

The server proves who it is with a certificate. Then both sides agree on a fresh shared key. They switch to fast symmetric encryption. This is TLS (Transport Layer Security). It makes three promises:

  • Secrecy. Nobody on the path can read the traffic.
  • Integrity. Nobody can change a byte without being caught.
  • Server identity. The client reached the holder of the certificate for that name.

TLS does not say which user sent a request. That is the job of your credential. It also does not protect data once it lands on the server.

Think of it like…

a sealed courier parcel. Nobody on the road can open it or swap what is inside. That is secrecy and integrity. The shop's registered signboard shows the parcel really came from that shop: server identity. Mutual TLS is a courier who also asks for your ID before handing it over.

The TLS 1.3 handshake

Before any HTTP flows, client and server run a handshake. These are the steps, in order:

  1. ClientHello. The client lists what it supports, names the server it wants, and sends a one-time key share.
  2. ServerHello. The server picks the options and sends its own key share. Both sides now compute the same secret, and it never crossed the wire. The one-time keys are thrown away, which gives forward secrecy. Stealing the server's key later does not unlock recorded traffic. From here on, everything is encrypted, even the certificate.
  3. The server proves itself. It sends its certificate chain, a CertificateVerify signature made with the certificate's private key, and a Finished message.
  4. The client checks. It checks the chain, the dates and the name (see certificates and chains of trust). Then it sends its own Finished.
  5. Application data. Now the HTTP request, with its token, is sent.
Bot A (client)Billing API (server)1 · ClientHello — versions, key share, server name2 · ServerHello — its key share4 · Certificate + CertificateVerify + Finished6 · Finished7 · application data — the HTTP request and its token3 · EncryptedExtensions + CertificateRequest*5 · Certificate* + CertificateVerify*🔒 both sides now share a fresh secret — everything below is encrypted* only in mutual TLS: the server asks for a certificate and the client proves it holds the key
Figure — One round trip, then a private channel. The key shares in steps 1 and 2 make a secret that never crosses the wire. The starred messages appear only in mutual TLS.

Mutual TLS: the caller proves itself too

Mutual TLS (mTLS) adds the starred messages. The server sends a CertificateRequest. The client answers with its own certificate and its own CertificateVerify signature. That proves it holds the private key. With no certificate, the server can end the handshake before it reads a request.

A verified certificate is only half the job. The server must map it to a caller:

  • Which issuers do you trust for clients? Only a CA you run for this purpose. Never "anything the operating system trusts". Otherwise a certificate from any public CA gets in.
  • Which field names the caller? Pick one, such as a SAN URI like spiffe://example.org/billing. Match it exactly. Never use "contains" or "ends with".
  • What may it do? The certificate says who. Your policy still decides what.

End TLS at the gateway, then pass identity on safely

TLS usually ends at a load balancer or API gateway. This is TLS termination. The gateway decrypts, inspects and forwards. It should open a new TLS connection to the backend, best with mTLS.

The gateway checked Sam's client certificate, but the backend never saw it. So the gateway tells the backend who called, in a header. A header is only text, and anybody can type one. Two rules make it safe.

  1. The gateway removes or overwrites any incoming copy of the identity header, then adds its own. Keeping a copy that arrives does not fail safe.
  2. The backend believes the header only from the gateway. Use mTLS between them, or a network path nothing else can reach. If not, an attacker types the header straight into the backend.
Sam's serviceholds a client certAttackertypes any headerGatewayterminates mTLS ✓strips incoming identity headersadds Client-Cert it verifiedre-encrypts to the backendOrders APItrusts identity headersonly from the gateway(mTLS gateway → API)mTLS ✓Client-Certforged header→ stripped ✗skips the gateway → refused ✗
Figure — A header is only as trustworthy as whoever set it. The gateway throws away identity headers that arrive from outside. The backend accepts the header only over its checked link to the gateway.
Go deeper: Where mTLS fits, and public certificates

mTLS works well between services and for partner and device APIs. At an OAuth token endpoint, the same certificate can tie the access token to it (certificate-bound tokens). It is clumsy in browsers.

TLSMutual TLS
Who proves identityServer onlyServer and client
What the client holdsNothing secretA private key and certificate
What the server learnsNothing about the callerA verified caller name
Typical useWebsites and public APIsService-to-service, partners, devices

The standard header for passing a client certificate is Client-Cert (RFC 9440). It makes removing incoming copies a MUST.

Do not plan on public web certificates for mTLS clients. Public CAs are moving to server-only certificates. Chrome's root program says public TLS certificates issued from June 15, 2026 must not carry the client-authentication usage. Older ones work until they expire. Issue client certificates from a private CA.

TLS 1.3 has an optional 0-RTT mode for returning clients. It sends data early, and an attacker can replay it. Use it only for requests that are harmless to run twice. The IETF retired TLS 1.0 and 1.1 in 2021 (RFC 8996).

Go deeper: ACME and shorter certificate lives

An expired certificate breaks the handshake for everyone at once. The cure is to renew by machine. The standard is ACME (RFC 8555). The client proves to the CA that it controls a domain. It serves a token at a well-known web address (http-01) or puts it in DNS (dns-01). Then it gets a certificate and installs it. It repeats this before expiry.

In April 2025 the CA/Browser Forum passed ballot SC-081v3. It cuts the longest life of a public TLS certificate from 398 days to:

  • 200 days from March 15, 2026,
  • 100 days from March 15, 2027,
  • 47 days from March 15, 2029.

Inside your own walls you set the lifetimes, and short is the goal.

🧪 Interactive lab — enable JavaScript to play with this one.

🧪 Try it free

Run openssl s_client -connect integrauth.com:443 -tls1_3 -brief to watch a real handshake. Then grade a certificate with Cert Lint.