| [ Web Proxy ] |
| Viewing: https://developers.cloudflare.com/ssl/client-certificates/byo-ca/ | [Back] [Original] |
This page explains how you can manage client certificates that have not been issued by Cloudflare CA. For a broader overview, refer to the mTLS at Cloudflare learning path.
Bring your own CA (BYOCA) is especially useful if you already have mTLS implemented and client certificates are already installed on devices.
Note
If you exceed the CA certificate quota, the API returns error 1489 with the message "Hit maximum CA cert allocation." Contact your account team to request a quota increase.
When you upload your CA, Cloudflare validates the certificate according to certain requirements.
The CA certificate can be from a publicly trusted CA or self-signed.
In the certificate Basic Constraints, the attribute CA must be set to TRUE.
The certificate must use one of the signature algorithms listed below:
Allowed signature algorithms
x509.SHA1WithRSA
x509.SHA256WithRSA
x509.SHA384WithRSA
x509.SHA512WithRSA
x509.ECDSAWithSHA1
x509.ECDSAWithSHA256
x509.ECDSAWithSHA384
x509.ECDSAWithSHA512
Note
Uploading the CA private key is only required if you wish to use Zero Trust's block page. To upload your own CA with the private key, use the Upload mTLS certificate endpoint.
In the Cloudflare dashboard, go to the Client Certificates page.
Go to Client Certificates ↗Select Add Certificate.
In the Certificate Authority dropdown, select Bring your own CA.
Upload your CA certificate file (PEM encoded) and enter a name for the CA.
Select Continue.
On the Associate Hostnames page, enter the hostname that should use this CA for mTLS validation and select Add for each one. You can also skip this step and associate hostnames later.
Select Save to confirm.
ca boolean required
true to indicate that the certificate is a CA certificate.certificates string required
.pem file associated with the CA certificate, formatted as a single string with \n replacing the line breaks.name string optional
private_key string optional
.pem file associated with the private key for the certificate, formatted as a single string with \n replacing the line breaks.id) that is returned in the API response.hostnames array required
List the hostnames that will be using the CA for client certificate validation.
Caution
Submitting an empty array will remove all hostname associations.
mtls_certificate_id string required
Indicate the certificate ID obtained from the previous step.
Caution
If no mtls_certificate_id is provided, the action will be performed against the Cloudflare-managed CA.
After uploading the CA and associating hostnames, create a custom rule to enforce client certificate validation. You can do this via the dashboard or via API.
"expression": "(http.host in {\"<HOSTNAME_1>\" \"<HOSTNAME_2>\"} and not cf.tls_client_auth.cert_verified)",
"action": "block"
Note
When using CNAME records, enforce mTLS on the specific hostname where it should be checked. It is not enough to have it set on the CNAME target.
There can be multiple CAs (Cloudflare-managed or BYOCA) associated with the same hostname. For BYOCA certificates, the most recently deployed certificate will be prioritized.
If you wish to remove the association from the Cloudflare-managed certificate and only use your BYOCA certificate(s):
In the Cloudflare dashboard, go to the Client Certificates page.
Go to Client Certificates ↗On the Hosts section under Cloudflare-issued Client Certificates, select Edit.
Select the cross next to the hostname you want to remove.
Select Save to confirm.
mtls_certificate_id parameter.Required API token permissions
At least one of the following token permissions is required:SSL and Certificates WriteSSL and Certificates Readcurl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/certificate_authorities/hostname_associations" \
--request GET \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"hostnames array returned by the API and update it, removing the hostname that should no longer use the Cloudflare-managed CA.mtls_certificate_id parameter to perform the action against the Cloudflare-managed CA. For hostnames use the list from the previous step.Required API token permissions
At least one of the following token permissions is required:SSL and Certificates Writecurl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/certificate_authorities/hostname_associations" \
--request PUT \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--json '{
"hostnames": [
"<UPDATED_HOSTNAME_ASSOCIATIONS>"
]
}'If you want to remove a CA that you have previously uploaded, you must first remove any hostname associations that it has.
In the Cloudflare dashboard, go to the Client Certificates page.
Go to Client Certificates ↗Select the BYOCA tab.
Find the CA you want to delete and select the three dots next to it.
Remove all associated hostnames first, if any exist.
Select the delete option and confirm.
hostnames and specifying your CA certificate ID in mtls_certificate_id: "hostnames": [],
"mtls_certificate_id": "<CERTIFICATE_ID>"In the Cloudflare dashboard, go to the Client Certificates page.
Go to Client Certificates ↗Select the BYOCA tab.
Find the CA you want to inspect and select the three dots next to it.
Select Edit hostnames. The Certificate Details panel displays the associated hostnames.
Use the List Hostname Associations endpoint with the mtls_certificate_id query parameter set to the certificate ID of the uploaded CA.
Required API token permissions
At least one of the following token permissions is required:SSL and Certificates WriteSSL and Certificates Readcurl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/certificate_authorities/hostname_associations?mtls_certificate_id=ID_FROM_STEP_2" \
--request GET \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"| Web Proxy Viewer | New URL | Original Page |