mTLS
Use mTLS profiles when partners authenticate with a client certificate. The certificate is checked where TLS ends, at your ingress (nginx, Nginx Proxy Manager, Kubernetes ingress, a cloud load balancer), and the ingress tells Zerq which client and profile the certificate belongs to.
How it works
- The partner connects to a dedicated mTLS hostname with their client certificate.
- The ingress verifies the certificate against your CA and rejects anything else.
- The ingress sets
X-Client-ID,X-Profile-IDandAuthorizationfrom the verified certificate, replacing anything the caller sent. - Zerq matches the client and profile, then applies the profile's IP and method restrictions, collection access and policy limits.
For profiles with auth type mtls, Zerq does not read the certificate itself. The ingress is the authentication step, so the security of these profiles rests on the ingress requirements below.
Recommended pattern: put the Zerq IDs in the certificate
Issue each partner's client certificate from your own CA with:
CN= the partner's Zerq client IDOU= the partner's Zerq profile ID
These are the 24-character IDs Zerq shows when you create the client and the mTLS profile, not their display names. The gateway rejects any other value with 401 Invalid Client ID format or Invalid Profile ID format.
With the IDs in the certificate, one ingress configuration serves every partner:
| Task | What you do |
|---|---|
| Onboard a partner | Create the client and an mTLS profile in Zerq, then sign the partner's CSR with those IDs in CN and OU. No ingress change. |
| Renew | Issue a new certificate with the same CN and OU. |
| Revoke | Deactivate the profile (or client) in Zerq: every request then gets 401 Profile is inactive. Add the certificate to your CRL as well if the ingress checks one. |
Signing a partner CSR with the IDs set:
# The partner sends client.csr; you sign it with the Zerq IDs in the subject
openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key -CAcreateserial \
-subj "/CN=6650a1f2c3d4e5f6a7b8c9d0/OU=6650a2b4c3d4e5f6a7b8c9d1/O=Acme Payments/C=GB" \
-out client.crt -days 365 -sha256
For a test certificate you generate yourself:
openssl genrsa -out client.key 2048
openssl req -new -key client.key -out client.csr \
-subj "/CN=6650a1f2c3d4e5f6a7b8c9d0/OU=6650a2b4c3d4e5f6a7b8c9d1/O=ExampleCorp/C=US"
openssl x509 -req -in client.csr -CA ca.crt -CAkey ca.key \
-CAcreateserial -out client.crt -days 365 -sha256
Ingress configuration (nginx)
# http {} level: nginx has no per-field certificate variables, so take CN and OU
# from the verified subject ($ssl_client_s_dn, e.g. "CN=<client id>,OU=<profile id>,O=...")
map $ssl_client_s_dn $mtls_client_id { default ""; "~(^|,)CN=(?<cn>[^,]+)" $cn; }
map $ssl_client_s_dn $mtls_profile_id { default ""; "~(^|,)OU=(?<ou>[^,]+)" $ou; }
server {
listen 443 ssl;
server_name mtls.example.com; # dedicated mTLS hostname
ssl_certificate /etc/nginx/certs/server.crt;
ssl_certificate_key /etc/nginx/certs/server.key;
ssl_client_certificate /etc/nginx/certs/partner-ca.crt; # your CA
ssl_verify_client on; # reject missing or untrusted certificates
location / {
proxy_pass http://backend:8080;
proxy_set_header X-Client-ID $mtls_client_id; # CN -> client ID
proxy_set_header X-Profile-ID $mtls_profile_id; # OU -> profile ID
# Every profile except auth type "none" needs a non-empty Authorization
# header; for mtls profiles the value itself is not checked
proxy_set_header Authorization "mtls";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Nginx Proxy Manager: create a separate proxy host for the mTLS hostname and put the certificate lines and header overrides in its configuration (put the CA file under the /etc/letsencrypt volume, as in deploy/mtls-client-cert-forwarding.md). nginx applies proxy_set_header from the server level only to locations that set no headers of their own, so run the verification tests to confirm the overrides reach Zerq.
Ingress requirements
All of these must hold, or a caller could claim another partner's identity:
- Verify against your CA only:
ssl_verify_client onwithssl_client_certificateset to the CA that issues partner certificates.optional_no_cadoes not verify anything and is only for certificate-bound tokens. - Always overwrite the headers: set
X-Client-ID,X-Profile-IDandAuthorizationwithproxy_set_headerfrom the verified certificate. Never fall back to the caller's own headers. - Use a dedicated hostname: with
ssl_verify_client on, callers without a certificate are rejected, so keep token, OIDC and AI Gateway clients on your normal API hostname and give mTLS partners their own (for examplemtls.example.com). Both can point to the same Zerq backend. - Make the ingress the only way in: the Zerq gateway port must not be reachable except through this ingress (no published host port, and only the ingress on its network). Anything that can reach the backend directly can set these headers itself.
When partner certificates come from another CA
If partners bring certificates you don't issue (for example from an open banking trust framework or a qualified certificate provider), their CN and OU won't be Zerq IDs. Map each certificate to its IDs at the ingress instead, keyed on something unique such as the SHA-1 fingerprint:
# http {} level (Nginx Proxy Manager: /data/nginx/custom/http_top.conf)
map $ssl_client_fingerprint $zerq_client_id {
default "";
"3f1c0a…" "6650a1f2c3d4e5f6a7b8c9d0"; # Acme Payments
}
map $ssl_client_fingerprint $zerq_profile_id {
default "";
"3f1c0a…" "6650a2b4c3d4e5f6a7b8c9d1";
}
# in the mTLS server's location
proxy_set_header X-Client-ID $zerq_client_id;
proxy_set_header X-Profile-ID $zerq_profile_id;
Unknown certificates get empty headers and Zerq answers 401. Each new, renewed or revoked partner certificate then needs a map change and an ingress reload.
Calling the API
The partner only presents their certificate; the ingress supplies the identity headers:
curl -i https://mtls.example.com/orders/123 \
--cert client.crt --key client.key \
-H "Accept: application/json"
Status codes
| Status | From | Meaning |
|---|---|---|
TLS failure or 400 | Ingress | No certificate, or one your CA didn't issue |
401 | Zerq | Missing or malformed IDs, client or profile not found or inactive, profile not owned by the client, or empty Authorization |
403 | Zerq | Caller's IP is not in the profile's allowed IPs |
404 | Zerq | Path is not in a collection assigned to the client |
405 | Zerq | Method not allowed by the profile or the proxy |
429 | Zerq | Rate limit or quota reached |
Verify the ingress
Run these against the mTLS hostname before onboarding partners:
- No certificate: the request fails at the ingress.
- Certificate from another CA: the request fails at the ingress.
- Valid certificate plus forged headers: send partner A's certificate with
-H "X-Client-ID: <partner B's client ID>". The request must still run as partner A: check the entry'sclient_idin request logs. - Deactivated profile: deactivate a test profile; its certificate now gets
401. - Direct access: from outside the ingress, the Zerq backend port must not answer.
Rollback checkpoint
If a policy change over-blocks traffic, restore the previous client and profile settings, then retest one allowed path and one denied path before reapplying finer-grained rules.
Not the same as certificate-bound tokens
This mtls auth type establishes client identity from the TLS handshake itself — it does not involve or bind any bearer token. If you need a bearer token that is cryptographically tied to a client certificate (RFC 8705 sender-constrained tokens, relevant for FAPI 2.0), that's a separate, opt-in capability on OIDC profiles — see OIDC Authentication: certificate-bound tokens.