Configure mTLS
Last updated Sep 29, 2026 When you configure mTLS authentication for API hosts, Cloudflare can block requests that do not have a client certificate for mTLS authentication. Blocking applies only to requests that match the hostname and path conditions in your mTLS rule.
Prerequisites
Before you can protect your API or web application with mTLS rules, you need to:
- Check that the certificate installed on your origin server matches the hostname of the client certificate, for example
api.example.com. Origin server wildcard certificates such as*.example.comare not supported. - Create a client certificate.
- Configure your mobile app or IoT device to use your Cloudflare-issued client certificate.
- Enable mutual Transport Layer Security (mTLS) for a host in your zone.
Note
While API Shield is not required to use mTLS, many teams may use mTLS to protect their APIs.
Caution
By default, API Shield mTLS uses client certificates issued by a Cloudflare-managed CA. If you need to use certificates issued by another CA, refer to Bring your own CA for mTLS.
Create an mTLS rule via the Cloudflare dashboard
- In the Cloudflare dashboard, go to Client Certificates page. Go to Client Certificates ↗
- Select Create a mTLS rule.
- In Custom rules, several rule parameters have already been filled in. Enter the URI path you want to protect in Value.
- (Optional) Add a
Hostnamefield and enter the mTLS-enabled hostnames you wish to protect in Value. - In Choose action, select
Block. - Select Deploy to make the rule active.
Once you have deployed your mTLS rule, requests without a valid client certificate are blocked only when they match the hostname and URI path conditions configured in the rule.
Expression Builder
To review your mTLS rule in the Expression Builder, select the wrench icon associated with your rule.
In the Expression Preview, your mTLS rule includes a compound expression formed from two simple expressions joined by the and operator.
The first expression — not cf.tls_client_auth.cert_verified — returns true when a request to access your API or web application does not present a valid client certificate.
The second expression uses the http.request.uri.path field, combined with the in operator, to capture the URI paths your mTLS rule applies to.
Because the action for your rule is Block, requests that match the configured hostname and path conditions must present a valid client certificate.
Cloudflare recommends also validating the issuer Subject Key Identifier (SKI) hash. Without this check, any valid client certificate is accepted regardless of which certificate authority (CA) issued it. Adding the SKI hash restricts access to certificates from a specific CA.
You can implement this by using an expression similar to the following:
not (cf.tls_client_auth.cert_verified and cf.tls_client_auth.cert_issuer_ski eq "A5AC554235DBA6D963B9CDE0185CFAD6E3F55E9F")
To obtain the issuer Subject Key Identifier (SKI) hash of a client certificate stored in the mtls.crt file, you can run the following OpenSSL command:
openssl x509 -noout -ext authorityKeyIdentifier -in mtls.crt | tail -n1 | tr -d ': '
A5AC554235DBA6D963B9CDE0185CFAD6E3F55E9F
Check for revoked certificates
To check for revoked client certificates, you can either add a new mTLS rule or add a new expression to the default rule. To check for revoked certificates, you must use the Expression Builder.
When a request includes a revoked certificate, the cf.tls_client_auth.cert_revoked field is set to true. If you combined this with the default mTLS rule, it would look similar to the following:
((not cf.tls_client_auth.cert_verified or cf.tls_client_auth.cert_revoked) and http.request.uri.path in {"/admin"})
Caution
This check only applies to client certificates issued by the Cloudflare-managed CA. Cloudflare currently does not check certificate revocation lists (CRL) for CAs that have been uploaded.
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/api-shield/security/mtls/configure/#page","headline":"Configure mTLS","description":"Set up mTLS authentication rules to require client certificates for API hosts.","url":"https://developers.cloudflare.com/api-shield/security/mtls/configure/","inLanguage":"en","image":"https://developers.cloudflare.com/api-shield/security/mtls/configure/og.png?v=c33eefe4e6db8977","dateModified":"2026-09-29","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["mTLS"]}
description: Supply Schema Profiles through uploaded OpenAPI schemas. title: Schema validation image: https://developers.cloudflare.com/api-shield/security/schema-validation/og.png?v=79e7231a72607932
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/api-shield/llms.txt
Use this file to discover all available pages before exploring further.
Docs