{"canonical_url":"https://engineer.company/glossary/mutual-tls/","content_markdown":"# Mutual TLS\n\n## What it is\n\nMutual TLS is a use of TLS in which both parties authenticate with certificates\nduring their connection. The client verifies the server's identity in the\nordinary certificate-based handshake. The server also requests a client\ncertificate and verifies it according to an explicit policy. Each party proves\npossession of the associated private key when required by the handshake. Once\nthe connection is established, application traffic benefits from the session's\nnegotiated cryptographic protection.\n\nAn internal inventory service illustrates the distinction. Its callers want\nassurance that they are speaking to the inventory service, while the service\nwants assurance that an incoming client belongs to the dispatch workload. The\ndeployment can issue distinct workload certificates from an approved trust\nchain. The server checks the client certificate and the application or proxy\nmaps its verified identity to allowed operations. The trust chain, expected\nidentity and permitted actions are separate design choices.\n\nMutual authentication takes place at a connection boundary. A reverse proxy\nmight verify the client certificate before it sends a request upstream. The\nbackend then receives the proxy's connection. If it needs the verified client\nidentity, it should obtain that fact along an authenticated path where an\nexternal request cannot supply or override it. A system can also use mutual TLS\nbetween proxy and backend to authenticate that separate connection under its own\npolicy.\n\nThe client application also needs a policy for the server name it connects to.\nFor example, a certificate trusted for a test database should be irrelevant to\nthe production inventory endpoint if its identity differs. Supply the intended\nname in client configuration and verify a connection to the wrong endpoint in\nstaging. The result should be obvious to operators who look at the error, while\na log entry should contain only the certificate or endpoint details they need\nfor diagnosis.\n\n## Why it matters\n\nMachine-to-machine services need an identity for access decisions and for\ninvestigation. A controlled certificate issuer can give individual workloads\nidentities with expiration and rotation. A server checking those identities can\nlimit a connection to authorised clients using the accompanying access policy.\nDesign the process so the identity can be inspected without revealing private\nkeys or turning readable certificate details into a claim of permission.\n\nThe distinction between chain acceptance and authorisation matters when several\nclients use the same certificate authority. A trusted chain provides a basis for\naccepting a certificate under the relevant TLS policy. It does not specify which\ndatabase a caller may access or whether it can send a particular type of\nrequest. The service needs a rule binding authenticated identities to\nprivileges. Where a request represents an end user, that customer's identity and\npermissions remain a separate decision.\n\nCertificates introduce a lifecycle. Services must obtain keys, have certificates\nissued, renew them before expiry and retire trust when identities are removed.\nShort validity reduces the interval during which a credential remains usable but\nincreases dependence on reliable issuance. Plan renewal, trust rotation and\nrecovery as parts of the same interface. Observe failed handshakes, upcoming\nexpiry and issuance errors. Include connection pooling and long-lived sessions\nso operators know when a new certificate or trust policy actually takes effect.\n\n## What it looks like in practice\n\nIn a staging environment, give the inventory service a server certificate with\nthe name clients expect and configure it to require a client certificate.\nPrepare one caller with the intended identity, another valid identity with\ndifferent privileges, and a caller with no acceptable certificate. Verify each\nat the right point. An unacceptable certificate should be refused according to\nthe handshake policy, while an authenticated but unauthorised workload should be\nrejected by the authorisation rule.\n\nTest trust rotation before it is needed. Introduce the next trusted issuer or\nchain under a planned overlap, install renewed credentials and confirm which\nidentity actually appears on new connections. Remove the old trust at a defined\npoint and verify that inappropriate clients can no longer connect. Observe what\nhappens to pooled sessions. Check both certificate chains and the resulting\napplication identity rather than inferring success from a process reload.\n\nOur\n[case study about automated certificate renewal for container applications](/portfolio/automated-ssl-tls-certs-for-100-docker-apps/)\ndescribes managing server certificates through ACME. It illustrates why issuance\nand renewal need automation. The inventory example adds certificates for callers\nand a test for how their identities map to access. The additional lifecycle work\napplies whenever a service depends on trust for both directions of a connection.\n\n## Where it goes wrong\n\nAccepting any valid client certificate from a broad issuer can admit callers\noutside the group the service expects. Constrain trust and authorisation to the\ndeployment's intended identity scheme. Validate the relevant certificate usage\nand identity according to the implementation. Exercise the case of a genuine\ncertificate for a different workload. That failure test distinguishes a\nmeaningful access policy from a successful test handshake.\n\nProxy boundaries can accidentally let clients make identity claims through\nordinary request headers. Strip incoming values for any internal identity\nheaders at the boundary and bind those values to verified connection\ninformation. Ensure a caller cannot reach the backend through a less protected\npath. Verify the configuration in the route users actually reach, including\nthrough load balancers and any secondary endpoint.\n\nAvailability can suffer if an issuer rotates, a clock drifts or an unattended\nrenewal stops working. Keep expiry and failure alerts tied to an accountable\nservice owner. Practice issuing replacement certificates and removing trust in a\ncompromised identity according to your platform's documented capabilities. Keep\ndiagnostics precise enough to distinguish missing credentials, verification\nfailure, and an authorization refusal after authentication.\n\n## Further reading\n\n- [TLS 1.3 in RFC 8446](https://www.rfc-editor.org/rfc/rfc8446) specifies the\n  protocol and certificate authentication messages.\n- [Caddy TLS configuration](https://caddyserver.com/docs/caddyfile/directives/tls)\n  documents certificate verification and client authentication options.\n- [OpenSSL verification options](https://docs.openssl.org/3.5/man1/openssl-verification-options/)\n  covers certificate chains, purposes and trust settings.\n\n\u003chttps://engineer.company/glossary/mutual-tls/\u003e\n","date_modified":"2026-11-24T21:48:58Z","description":"How mutual TLS verifies clients and servers, and how to test access decisions and certificate rotation.","formats":{"gemtext":"https://engineer.company/glossary/mutual-tls/index.gmi","gopher":"https://engineer.company/glossary/mutual-tls/gophermap","html":"https://engineer.company/glossary/mutual-tls/","json":"https://engineer.company/glossary/mutual-tls/index.json","markdown":"https://engineer.company/glossary/mutual-tls/index.md","pdf":"https://engineer.company/glossary/mutual-tls/index.pdf"},"kind":"page","language":"en","title":"What is mutual TLS?","url":"https://engineer.company/glossary/mutual-tls/","version":1}