In a normal HTTPS connection only the server proves who it is: the browser checks the certificate and confirms it reached the right site. The client stays anonymous and is identified later by a login, password or API key. mTLS (mutual TLS) extends this: during the handshake the client also presents a certificate and the server verifies it. A client without a valid certificate never reaches your application at all.
Isn't an API key enough?
An API key is just a string. It can end up in config files, logs or a script on an employee's laptop, and whoever copies it can call your API from anywhere. The key is also checked at the application layer, so anyone can complete a TLS handshake and deliver requests to your app. With mTLS the check happens earlier, in the TLS handshake, and the client's private key never crosses the network. Serious integrations often combine both: mTLS restricts the channel, while a token defines permissions.
Where mTLS fits
mTLS suits a small, known set of clients rather than the public:
- B2B integrations such as order and stock exchange between two companies;
- server-to-server links with payment or banking partners that require it;
- internal microservices running on different servers;
- point-of-sale terminals or IoT devices talking to a central server.
Example: a Samarkand wholesaler and its warehouse partner
A wholesale company in Samarkand runs an orders API at api.example.uz. A partner warehouse in Tashkent pulls new orders every ten minutes and posts shipment updates. IP allowlisting breaks when the partner changes ISP or fails over to a backup link, while mTLS does not care about the source address. The company creates its own internal certificate authority (CA), issues a client certificate to the partner over a secure channel and configures Nginx to accept only certificates signed by that CA. A second partner later gets a separate certificate that can be revoked independently.
Creating an internal CA and a client certificate
Public CAs are the wrong tool here: you want a closed system that trusts only certificates you issued. On the VPS:
mkdir -p /etc/nginx/mtls && cd /etc/nginx/mtls
# 1. Internal CA
openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes \
-keyout ca.key -out ca.crt -subj "/CN=Example API CA"
# 2. Partner key and signing request
openssl req -newkey rsa:2048 -nodes \
-keyout partner.key -out partner.csr -subj "/CN=ombor-hamkor"
# 3. Sign for client authentication only
printf "extendedKeyUsage=clientAuth\n" > client.ext
openssl x509 -req -in partner.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
-out partner.crt -days 365 -sha256 -extfile client.ext
Guard ca.key carefully, ideally away from the API server; the server only needs the public ca.crt. Send partner.crt and partner.key in an encrypted archive rather than plain email.
Enabling mTLS in Nginx
The server certificate stays as usual, for example a free Let's Encrypt one. Add the CA file and turn on client verification:
server {
listen 443 ssl;
server_name api.example.uz;
ssl_certificate /etc/letsencrypt/live/api.example.uz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.example.uz/privkey.pem;
ssl_client_certificate /etc/nginx/mtls/ca.crt;
ssl_verify_client on;
ssl_verify_depth 2;
location / {
proxy_set_header X-Client-DN $ssl_client_s_dn;
proxy_set_header X-Client-Verify $ssl_client_verify;
proxy_pass http://127.0.0.1:8000;
}
}
Nginx passes the verified client's DN to the application in a header. proxy_set_header overwrites any client-supplied header of the same name, but make sure the backend port is not reachable directly, or the header could be forged. Test with nginx -t and apply with systemctl reload nginx.
Testing and revocation
From the partner's server:
curl --cert partner.crt --key partner.key https://api.example.uz/v1/orders
Without a certificate Nginx answers with a 400 error and "No required SSL certificate was sent". To revoke a certificate, publish a certificate revocation list and reference it with ssl_crl. Generating it with openssl ca requires a configured CA database first:
openssl ca -gencrl -keyfile ca.key -cert ca.crt -out ca.crl
A simpler approach for small projects is to issue short-lived certificates, say 90 days, and simply not renew them. Either way, track expiry dates so the integration does not stop without warning.
Can you do this on shared hosting?
mTLS needs web-server-level configuration, which shared hosting does not expose to customers. A VPS is the usual choice. You can order one from the sayt.uz cabinet, install Nginx with the configuration above and use Let's Encrypt for the server certificate. If you are unsure which option fits, ask support through the sayt.uz cabinet.