Mutual TLS (mTLS) Explained: Authenticating Both Client and Server

How mTLS works, how it differs from regular TLS, certificate authorities and rotation, using mTLS between services, with NGINX, curl and service mesh example...

Published December 6, 2026

In regular HTTPS, only the server proves its identity with a certificate; the client stays anonymous at the TLS layer and authenticates later with passwords or tokens. Mutual TLS adds the reverse: the client also presents a certificate, and the server verifies it during the handshake. That gives strong, cryptographic identity for machines talking to machines.

The concept

During an mTLS handshake, the server sends its certificate and a CertificateRequest. The client responds with its own certificate and proves it holds the matching private key. Each side validates the other's certificate against a trusted certificate authority (CA), checks validity dates and possibly revocation, and can authorise based on fields such as the subject or SAN (for example a SPIFFE ID).

The hard part is operations: issuing certificates to every service, rotating them frequently, and distributing trust bundles. Service meshes and tools like SPIRE, cert-manager or cloud private CAs automate this. mTLS is common for internal service-to-service traffic, partner APIs, IoT devices and zero trust architectures.

The mTLS handshake

Client serviceServer serviceClientHelloServerHello + server cert + CertificateRequestclient cert + CertificateVerifyverify client cert against CAencrypted requestencrypted response
Both sides present and verify certificates.

TLS vs mTLS

TLSmTLS
Server authenticatedYesYes
Client authenticated at TLS layerNoYes, with a certificate
Typical useBrowsers to websitesService-to-service, partners, devices
Operational costServer certs onlyCertificates for every client too

Certificate lifecycle

signdeliverhandshakePrivate CASPIRE / cert-manager / cloud CAIssue short-lived certshours to daysServicesauto-rotateVerify peerstrust bundle
Automation makes mTLS manageable.

Practical examples

Require client certificates in NGINX

Verify against your internal CA and pass identity upstream.

server {
    listen 443 ssl;
    ssl_certificate     /etc/nginx/tls/server.crt;
    ssl_certificate_key /etc/nginx/tls/server.key;
    ssl_client_certificate /etc/nginx/tls/internal-ca.crt;
    ssl_verify_client on;
    location / {
        proxy_set_header X-Client-Cert-Subject $ssl_client_s_dn;
        proxy_pass http://app;
    }
}

Call an mTLS endpoint with curl

Present a client certificate and key.

curl --cert client.crt --key client.key --cacert internal-ca.crt https://payments.internal/health

Create a test CA and client cert with OpenSSL

For local experiments only.

openssl req -x509 -newkey rsa:2048 -nodes -keyout ca.key -out ca.crt -days 30 -subj "/CN=test-ca"
openssl req -newkey rsa:2048 -nodes -keyout client.key -out client.csr -subj "/CN=orders-service"
openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out client.crt -days 7

Common mistakes

  • Long-lived client certificates that are never rotated.
  • Accepting any certificate from the CA without authorising the specific identity.
  • Terminating mTLS at a proxy and not protecting the hop behind it.
  • Manual certificate distribution that does not scale.

Key takeaways

  • mTLS authenticates both client and server with certificates.
  • Authorise based on certificate identity, not just validity.
  • Automate issuance and short-lived rotation.
  • Service meshes and SPIRE make mTLS practical at scale.

FAQ

Does mTLS replace API tokens?

For service-to-service identity it can; many systems still add tokens for user context or fine-grained authorization.

Can browsers use mTLS?

Yes, with client certificates installed, but the user experience is poor, so it is mainly used for machines and managed devices.

How do I revoke a client certificate?

Short lifetimes are the most practical revocation; CRLs or OCSP can be used for longer-lived certificates.

More Security articles