Forward certificate to server

Last updated Apr 17, 2026

Add Client-Cert and Client-Cert-Chain headers (RFC 9440)

RFC 9440 ↗︎ defines the Client-Cert and Client-Cert-Chain HTTP header fields for passing client certificate information to origin servers. You can construct these headers using request header modification rules with the following Ruleset Engine fields:

As indicated in field definitions, the fields may be set to either an empty string or a valid RFC 9440 encoding. Proper usage depends on a couple of factors discussed in the following sections.

Security considerations

Important

Before constructing Client-Cert or Client-Cert-Chain headers, you must address the following security concerns. Failing to do so can expose your origin server to forged or unverified certificate data.

The cert_rfc9440 and cert_chain_rfc9440 fields are populated regardless of the certificate validation result. This means a client can present an invalid, expired, or self-signed certificate, and the fields will still contain the encoded certificate data. Always check the following fields before trusting the values:

A client can also include its own Client-Cert or Client-Cert-Chain headers on a request to inject arbitrary values. As described in the RFC 9440 security considerations ↗︎, you must unconditionally remove any existing Client-Cert and Client-Cert-Chain headers from incoming requests, regardless of certificate validity. This prevents a client from injecting forged certificate data that your origin would trust.

See Enable mTLS for details on how to configure mTLS and certificate validation.

Size limits

The encoded leaf certificate is limited to 10 KiB and the encoded chain is limited to 16 KiB. If the encoded value exceeds the limit, the corresponding field contains an empty string. Use the following fields to check for this condition:

Example Transform Rules

Here we provide an example on how to securely use these fields to construct trusted Client-Cert and Client-Cert-Chain headers to be forwarded to your origin. The origin can then rely on the presence of the headers to be certain the client presented a valid certificate. Note: the Client-Cert-Chain header may be omitted when the client did not present any intermediates (only a leaf certificate).

You need to create the following request header modification rules. The Remove rules must be placed before the Set dynamic rules so that client-injected headers are stripped on every request before the validated values are set.

Rule 1 — Remove Client-Cert header

This rule unconditionally removes any Client-Cert header sent by the client.

Text in Expression Editor:

true

Selected operation under Modify request header: Remove

Header name: Client-Cert

Rule 2 — Remove Client-Cert-Chain header

This rule unconditionally removes any Client-Cert-Chain header sent by the client.

Text in Expression Editor:

true

Selected operation under Modify request header: Remove

Header name: Client-Cert-Chain

Rule 3 — Set Client-Cert header

This rule sets the Client-Cert header only when the client presented a valid, non-revoked certificate that is within the size limit.

Text in Expression Editor:

cf.tls_client_auth.cert_verified
and not cf.tls_client_auth.cert_revoked
and not cf.tls_client_auth.cert_rfc9440_too_large

Selected operation under Modify request header: Set dynamic

Header name: Client-Cert

Value: cf.tls_client_auth.cert_rfc9440

Rule 4 — Set Client-Cert-Chain header

This rule sets the Client-Cert-Chain header only when the client presented a valid, non-revoked certificate and the chain is non-empty and within the size limit.

Text in Expression Editor:

cf.tls_client_auth.cert_verified
and not cf.tls_client_auth.cert_revoked
and cf.tls_client_auth.cert_chain_rfc9440 ne ""
and not cf.tls_client_auth.cert_chain_rfc9440_too_large

Selected operation under Modify request header: Set dynamic

Header name: Client-Cert-Chain

Value: cf.tls_client_auth.cert_chain_rfc9440

Cloudflare Workers

You can also construct RFC 9440 headers in a Cloudflare Worker using the tlsClientAuth properties on the incoming request.

The same security considerations mentioned above apply.

Forward a client certificate (legacy)

In addition to enforcing mTLS authentication for your host, you can also forward a client certificate to your origin server as an HTTP header. This setup is often helpful for server logging.

To avoid adding the certificate to every single request, the certificate is only forwarded on the first request of an mTLS connection.

Caution

This process is only available on accounts with Cloudflare Access.

Cloudflare API

The most common approach to forwarding a certificate is to use the Cloudflare API to update an mTLS certificate's hostname settings.

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

  • <code>Access: Mutual TLS Certificates Write</code>

</details>

Update an mTLS certificate's hostname settingsbash

curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/access/certificates/settings" \
    --request PUT \
    --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    --json '{
        "settings": [
                {
                        "hostname": "<HOSTNAME>",
                        "china_network": false,
                        "client_certificate_forwarding": true
                }
        ]
    }'

Once client_certificate_forwarding is set to true, every request within an mTLS connection will now include the following headers:

  • Cf-Client-Cert-Der-Base64
  • Cf-Client-Cert-Sha256

Note

The Cf-Client-Cert-Der-Base64 and Cf-Client-Cert-Sha256 headers are a Cloudflare-proprietary mechanism. For a standardized approach, use RFC 9440 Client-Cert and Client-Cert-Chain headers.

Managed Transforms

You can also modify HTTP response headers using Managed Transforms to pass along TLS client auth headers.

Cloudflare Workers

Additionally, Workers can provide details around the client certificate.

const tlsHeaders = {
    "X-CERT-ISSUER-DN": request.cf.tlsClientAuth.certIssuerDN,
    "X-CERT-SUBJECT-DN": request.cf.tlsClientAuth.certSubjectDN,
    "X-CERT-ISSUER-DN-L": request.cf.tlsClientAuth.certIssuerDNLegacy,
    "X-CERT-SUBJECT-DN-L": request.cf.tlsClientAuth.certSubjectDNLegacy,
    "X-CERT-SERIAL": request.cf.tlsClientAuth.certSerial,
    "X-CERT-FINGER": request.cf.tlsClientAuth.certFingerprintSHA1,
    "X-CERT-VERIFY": request.cf.tlsClientAuth.certVerify,
    "X-CERT-NOTBE": request.cf.tlsClientAuth.certNotBefore,
    "X-CERT-NOTAF": request.cf.tlsClientAuth.certNotAfter,
};

Was this helpful?

YesNo

On this page

Forward certificate to server - 图1Docs

{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/ssl/client-certificates/forward-a-client-certificate/#page","headline":"Forward certificate to server","description":"Forward client certificate details to your origin server.","url":"https://developers.cloudflare.com/ssl/client-certificates/forward-a-client-certificate/","inLanguage":"en","image":"https://developers.cloudflare.com/ssl/client-certificates/forward-a-client-certificate/og.png?v=07c63fcf80dbe891","dateModified":"2026-04-17","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","Headers"]}


description: Organize client certificates with labels for easier management. title: Label client certificates image: https://developers.cloudflare.com/ssl/client-certificates/label-client-certificate/og.png?v=2d369b078482a9f2


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/ssl/llms.txt
Use this file to discover all available pages before exploring further.