mTLS (mutual TLS) is TLS in which both sides present a certificate: the server proves its identity to the client, as in every HTTPS connection, and the client also proves its identity to the server. In plain TLS only the server is authenticated, and the client stays anonymous at the TLS layer.
The two are not separate protocols. Client authentication is an optional part of TLS itself, and a server turns it on by asking for a certificate. For the basics of TLS versus its predecessor, see SSL vs TLS.
mTLS vs TLS at a glance
| TLS (one-way) | mTLS (mutual) | |
|---|---|---|
| Server presents a certificate | Yes | Yes |
| Client presents a certificate | No | Yes |
Server sends CertificateRequest | No | Yes |
Client sends Certificate and CertificateVerify | No | Yes |
| Who is verified | The server only | Both sides |
| Encryption of the data | Same | Same |
RFC 8446 states the baseline directly: "The server side of the channel is always authenticated; the client side is optionally authenticated." mTLS is that option in use.
What changes in the handshake
In the TLS 1.3 handshake, a server that authenticates with a certificate "MAY optionally request a certificate from the client" (RFC 8446, section 4.3.2). It does that by sending a CertificateRequest message. If the server wants no client authentication, it leaves the message out.
When the request is present, the client's reply grows by two messages:
Certificate: the client's certificate chain.CertificateVerify: a signature over the whole handshake made with the private key that matches the certificate. This proves the client holds the key, not just a copy of the certificate.
A Finished message follows in both cases. The rule in section 4.4.2 is that the client sends a Certificate message "if and only if the server has requested client authentication".
What happens when the client has no certificate
If the server asked and the client has nothing suitable, the client must still answer: it sends a Certificate message containing no certificates, then Finished. The server then has a choice. RFC 8446 says it "MAY at its discretion either continue the handshake without client authentication" or abort. If it aborts, it uses the certificate_required alert.
So whether mTLS is mandatory is a server policy. A server can request a certificate and accept clients without one, or insist on it.
Servers can ask for a certificate later
TLS 1.3 also allows post-handshake authentication. A server may request client authentication "at any time after the handshake has completed", but only if the client signalled support with the post_handshake_auth extension. A client that receives such a request without having sent the extension must close the connection with an unexpected_message alert. A client that declines sends an empty Certificate message followed by Finished.
How to require client certificates in nginx
This is the example from the nginx documentation. The first two certificate lines are the usual server certificate. The last three turn on mTLS:
server {
listen 443 ssl;
server_name example.com;
ssl_certificate example.com.crt;
ssl_certificate_key example.com.key;
ssl_verify_client on;
ssl_client_certificate client-ca.crt;
ssl_verify_depth 2;
}
ssl_verify_clienttakeson,off,optionaloroptional_no_ca. The default isoff, which is plain TLS.onrequires and verifies a client certificate.optionalrequests one and verifies it if the client sends it.ssl_client_certificateis a PEM file of the CA certificates that nginx trusts for client certificates. nginx also sends this list to clients. If you don't want that, the docs point tossl_trusted_certificateinstead.ssl_verify_depthsets how long a client certificate chain may be. The default is 1.
The result of the check is in the variable $ssl_client_verify: SUCCESS, FAILED:reason (the reason text exists since nginx 1.11.7), or NONE if the client presented no certificate. $ssl_client_s_dn holds the subject name of the client certificate. Your application can use these, for example passed on as request headers, to decide what the caller may do.
Verifying the certificate answers "was this issued by a CA I trust". It does not decide what that client is allowed to access. You still need an authorization rule, such as matching the subject name against a list.
How to test mTLS with curl
Give curl the client certificate with --cert and its private key with --key. Use --cacert if the server's certificate comes from a CA that curl does not trust by default:
curl --cert client.crt --key client.key --cacert server-ca.crt https://example.com/
The curl manual says the certificate must be in PEM format for this option, and that if you give only --cert, curl assumes the certificate and private key are in one file. Without --cert against a server that requires a certificate, the request fails at the TLS layer or, depending on server configuration, with an HTTP error from the server. The exact message differs between servers and curl versions, so check the server's log, where nginx records the verification result.
When mTLS is worth using
- Use it when the caller is a program you control or can issue certificates to. The client certificate becomes its identity, and you can revoke access by stopping trust in that certificate.
- Skip it when the callers are the general public. You would have to issue and distribute a certificate to every user, which is the main cost of mTLS.
- Plan for certificate lifecycle. Both sides now have certificates that expire, so issuing, renewing and trusting the right CA are ongoing work, not a one-time setup.
If it still fails
Check the verification result first. In nginx, log $ssl_client_verify to see whether the client sent a certificate at all (NONE) or sent one that failed (FAILED:reason). A NONE result means the client never offered a certificate: check the --cert path and that the key matches. A FAILED result usually means the certificate was not issued by a CA listed in ssl_client_certificate, the chain is longer than ssl_verify_depth, or the certificate has expired.
Frequently asked questions
- Is mTLS a different protocol from TLS?
- No. Mutual TLS is ordinary TLS with the optional client authentication step switched on. The server sends a CertificateRequest message, and the client answers with its own certificate and a signature. RFC 8446 describes this as part of the TLS 1.3 protocol itself, so there is no separate mTLS standard to implement.
- Does mTLS encrypt traffic more strongly than TLS?
- No. The encryption of the data is the same in both cases. What changes is who is authenticated: with mTLS the server also verifies who the client is. If you only need a private channel and a verified server, plain TLS already provides that.
- What happens if a client has no certificate and the server requires one?
- In TLS 1.3 the client sends an empty Certificate message. The server can then either continue without client authentication or abort the handshake with a certificate_required alert. A server configured to require certificates, such as nginx with ssl_verify_client on, rejects the connection.
- Do browsers use mTLS?
- Browsers can present a client certificate when a server asks for one, for example one installed in the operating system or on a smart card. It is uncommon for public websites. Most mTLS traffic is between programs, such as one service calling another's API with a certificate the caller was issued.