コンテンツにスキップ

mTLSを有効にする

任意のホスト名に対して相互トランスポート層セキュリティ(mTLS)を有効にできます。

mTLSを有効にする

Cloudflareダッシュボードからホストに対して相互トランスポート層セキュリティ(mTLS)を有効にするには:

  1. Cloudflareダッシュボードにログインし、アカウントとアプリケーションを選択します。
  2. SSL > クライアント証明書に移動します。
  3. ホストに対してmTLSを有効にするには、クライアント証明書カードのホストセクションで編集を選択します。
  4. 現在のアプリケーションのホスト名を入力し、Enterを押します。
  5. 保存を選択します。

ホストに対してmTLSを有効にした後、API Shieldを使用してmTLSを強制できます。API ShieldはmTLSを使用するために必須ではありませんが、多くのチームがAPIを保護するためにmTLSを使用する場合があります。

Forward a client certificate

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.

Cloudflare API

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

Request
curl --request PUT \
https://api.cloudflare.com/client/v4/zones/{zone_id}/access/certificates/settings \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
"settings": [
{
"hostname": "<HOSTNAME>",
"china_network": false,
"client_certificate_forwarding": true
}
]
}'

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

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

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
};