mTLS with Cloudflare Access
Last updated Apr 23, 2026 Note
This requires an active Enterprise Account with Cloudflare Access enabled.
Setting up mTLS with Cloudflare Access can help in cases where the customer:
- Already has existing Client Certificates on devices.
- Needs to protect Access applications with Bring Your Own CA (BYOCA).
- Needs to integrate with a Zero Trust solution.
1. Create a CA
The CA certificate can be from a publicly trusted CA or self-signed.
In case you want to create your own CA from scratch, you can follow these example steps and adapt the information to your own needs:
- Create a JSON file called
ca-csr.json:
{
"CN": "Cloudflare Access Testing CA",
"key": {
"algo": "rsa",
"size": 4096
},
"names": [
{
"C": "US",
"L": "LA",
"O": "Access Testing",
"OU": "CA",
"ST": "California"
}
]
}
- Create a JSON file called
ca-config.json:
{
"signing": {
"default": {
"expiry": "8760h"
},
"profiles": {
"server": {
"usages": ["signing", "key encipherment", "server auth"],
"expiry": "8760h"
},
"client": {
"usages": ["signing", "key encipherment", "client auth"],
"expiry": "8760h"
}
}
}
}
- Run the following cfssl command to generate the CA certificate
ca.pem:
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
2. Create Client Certificates
- In order to create the Client Certificates, you need to prepare the following JSON file called
client-csr.json:
{
"CN": "mtls-access.example.com", # replace with your own hostname
"hosts": ["mtls-access.example.com"], # replace with your own hostname
"key": {
"algo": "rsa",
"size": 4096
},
"names": [
{
"C": "US",
"L": "Austin",
"O": "Access",
"OU": "Access Admins",
"ST": "Texas"
}
]
}
- Now you can run the following command to generate the Client Certificates, which will output the files
client.pem,client-key.pemandclient.csr:
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=client client-csr.json | cfssljson -bare client
3. Add mTLS CA certificate to Cloudflare Access
Follow the steps outlined in the developer documentation.
Using the example from Step 2: upload the ca.pem to your Cloudflare Access account via the dashboard or Cloudflare API.
Do not forget to enter the fully-qualified domain names (FQDN / associated hostnames) that will use this CA certificate.
Customers can identify which client sends the Client Certificates by forwarding client certificate headers to the origin server. Customers can then store and use the certificate information such as Common Name (CN), Serial number, and other fields along with the device number to perform additional checks or logics.
Additionally, authenticated requests also send the Cf-Access-Jwt-Assertion\ JWT header to the origin server. To decode the header value, you can use jwt.io ↗︎.
4. Create the self-hosted applications
Finally, the hostname you want to protect with mTLS needs to be added as a self-hosted app in Cloudflare Access, defining an Access Policy which uses the action Service Auth and the Selector "Valid Certificate", or simply requiring an IdP authentication. You can also take advantage of extra requirements, such as the "Common Name" (CN), which expects the indicated hostname, and more Selectors. Alternatively, one can also extend ZTNA with external authorization and serverless computing.
Demo
Note
Make sure that you are not using any VPN that could interfere with the certificates or TLS decryption.
With the Public and Private Client Certificates in the same directory, with this cURL command, we will gain access:
curl -IXGET --cert client.pem --key client-key.pem https://mtls-access.example.com/
HTTP/2 200
server: cloudflare
Without the certificates, we would see the following:
curl -I https://mtls-access.example.com/mtls-test
HTTP/2 401
server: cloudflare
Was this helpful?
YesNo
On this page
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/learning-paths/mtls/mtls-cloudflare-access/#page","headline":"mTLS with Cloudflare Access","description":"Implement mutual TLS authentication with Cloudflare.","url":"https://developers.cloudflare.com/learning-paths/mtls/mtls-cloudflare-access/","inLanguage":"en","image":"https://developers.cloudflare.com/learning-paths/mtls/mtls-cloudflare-access/og.png?v=f1c06628e607c471","dateModified":"2026-04-23","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/"}}
description: Implement mutual TLS authentication with Cloudflare. title: Types of mTLS implementation image: https://developers.cloudflare.com/learning-paths/mtls/mtls-implementation/og.png?v=5ef04fdccd52defd
Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/learning-paths/llms.txt
Use this file to discover all available pages before exploring further.
Docs