Mutual TLS

What it is

Mutual TLS is a use of TLS in which both parties authenticate with
certificates during their connection. The client verifies the
server's identity in the ordinary certificate-based handshake. The
server also requests a client certificate and verifies it according
to an explicit policy. Each party proves possession of the
associated private key when required by the handshake. Once the
connection is established, application traffic benefits from the
session's negotiated cryptographic protection.

An internal inventory service illustrates the distinction. Its
callers want assurance that they are speaking to the inventory
service, while the service wants assurance that an incoming client
belongs to the dispatch workload. The deployment can issue distinct
workload certificates from an approved trust chain. The server
checks the client certificate and the application or proxy maps its
verified identity to allowed operations. The trust chain, expected
identity and permitted actions are separate design choices.

Mutual authentication takes place at a connection boundary. A
reverse proxy might verify the client certificate before it sends a
request upstream. The backend then receives the proxy's connection.
If it needs the verified client identity, it should obtain that fact
along an authenticated path where an external request cannot supply
or override it. A system can also use mutual TLS between proxy and
backend to authenticate that separate connection under its own
policy.

The client application also needs a policy for the server name it
connects to. For example, a certificate trusted for a test database
should be irrelevant to the production inventory endpoint if its
identity differs. Supply the intended name in client configuration
and verify a connection to the wrong endpoint in staging. The result
should be obvious to operators who look at the error, while a log
entry should contain only the certificate or endpoint details they
need for diagnosis.

Why it matters

Machine-to-machine services need an identity for access decisions
and for investigation. A controlled certificate issuer can give
individual workloads identities with expiration and rotation. A
server checking those identities can limit a connection to
authorised clients using the accompanying access policy. Design the
process so the identity can be inspected without revealing private
keys or turning readable certificate details into a claim of
permission.

The distinction between chain acceptance and authorisation matters
when several clients use the same certificate authority. A trusted
chain provides a basis for accepting a certificate under the
relevant TLS policy. It does not specify which database a caller may
access or whether it can send a particular type of request. The
service needs a rule binding authenticated identities to privileges.
Where a request represents an end user, that customer's identity and
permissions remain a separate decision.

Certificates introduce a lifecycle. Services must obtain keys, have
certificates issued, renew them before expiry and retire trust when
identities are removed. Short validity reduces the interval during
which a credential remains usable but increases dependence on
reliable issuance. Plan renewal, trust rotation and recovery as
parts of the same interface. Observe failed handshakes, upcoming
expiry and issuance errors. Include connection pooling and
long-lived sessions so operators know when a new certificate or
trust policy actually takes effect.

What it looks like in practice

In a staging environment, give the inventory service a server
certificate with the name clients expect and configure it to require
a client certificate. Prepare one caller with the intended identity,
another valid identity with different privileges, and a caller with
no acceptable certificate. Verify each at the right point. An
unacceptable certificate should be refused according to the
handshake policy, while an authenticated but unauthorised workload
should be rejected by the authorisation rule.

Test trust rotation before it is needed. Introduce the next trusted
issuer or chain under a planned overlap, install renewed credentials
and confirm which identity actually appears on new connections.
Remove the old trust at a defined point and verify that
inappropriate clients can no longer connect. Observe what happens to
pooled sessions. Check both certificate chains and the resulting
application identity rather than inferring success from a process
reload.

Our case study about automated certificate renewal for container
applications describes managing server certificates through ACME. It
illustrates why issuance and renewal need automation. The inventory
example adds certificates for callers and a test for how their
identities map to access. The additional lifecycle work applies
whenever a service depends on trust for both directions of a
connection.

Where it goes wrong

Accepting any valid client certificate from a broad issuer can admit
callers outside the group the service expects. Constrain trust and
authorisation to the deployment's intended identity scheme. Validate
the relevant certificate usage and identity according to the
implementation. Exercise the case of a genuine certificate for a
different workload. That failure test distinguishes a meaningful
access policy from a successful test handshake.

Proxy boundaries can accidentally let clients make identity claims
through ordinary request headers. Strip incoming values for any
internal identity headers at the boundary and bind those values to
verified connection information. Ensure a caller cannot reach the
backend through a less protected path. Verify the configuration in
the route users actually reach, including through load balancers and
any secondary endpoint.

Availability can suffer if an issuer rotates, a clock drifts or an
unattended renewal stops working. Keep expiry and failure alerts
tied to an accountable service owner. Practice issuing replacement
certificates and removing trust in a compromised identity according
to your platform's documented capabilities. Keep diagnostics precise
enough to distinguish missing credentials, verification failure, and
an authorization refusal after authentication.

Further reading

  * TLS 1.3 in RFC 8446 specifies the protocol and certificate
authentication messages.

  * Caddy TLS configuration documents certificate verification and
client authentication options.

  * OpenSSL verification options covers certificate chains, purposes
and trust settings.

hThis page on the web	URL:https://engineer.company/glossary/mutual-tls/	engineer.company	70
