mTLS 接続用の証明書を管理するには、これらのコマンドを使います。
mtls-certificate コマンドは、Worker のサブリクエスト向けクライアント証明書を管理します。cert コマンドは、mTLS クライアント証明書と Certificate Authority(CA)チェーン証明書の両方を管理し、主に Hyperdrive の設定で使います。
サブリクエストの mTLS 接続に使うクライアント証明書を管理します。
これらの証明書は mtls_certificate バインディング で使えます。Worker は、クライアント認証(mTLS)を要求するオリジンとの接続時に、この証明書を提示できます。
mtls-certificate upload
Upload an mTLS certificate
npx wrangler mtls-certificate uploadyarn wrangler mtls-certificate uploadpnpm wrangler mtls-certificate upload--certstringrequiredThe path to a certificate file (.pem) containing a chain of certificates to upload
--keystringrequiredThe path to a file containing the private key for your leaf certificate
--namestringThe name for the certificate
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、upload コマンドで mTLS 証明書をアップロードする例です。
npx wrangler mtls-certificate upload --cert cert.pem --key key.pem --name my-origin-certUploading mTLS Certificate my-origin-cert...
Success! Uploaded mTLS Certificate my-origin-cert
ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Expires: 1/01/2025アップロードした証明書は、Wrangler 設定ファイル の バインディング として追加できます。
{
"mtls_certificates": [
{
"binding": "MY_CERT",
"certificate_id": "99f5fef1-6cc1-46b8-bd79-44a0d5082b8d",
},
],
}[[mtls_certificates]]
binding = "MY_CERT"
certificate_id = "99f5fef1-6cc1-46b8-bd79-44a0d5082b8d"アップロード時、証明書と秘密鍵は別ファイル(通常は .pem)である必要があります。
mtls-certificate list
List uploaded mTLS certificates
npx wrangler mtls-certificate listyarn wrangler mtls-certificate listpnpm wrangler mtls-certificate listGlobal flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、list コマンドで mTLS 証明書を一覧する例です。
npx wrangler mtls-certificate listID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Name: my-origin-cert
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Created on: 1/01/2023
Expires: 1/01/2025
ID: c5d004d1-8312-402c-b8ed-6194328d5cbe
Issuer: CN=another-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Created on: 1/01/2023
Expires: 1/01/2025mtls-certificate delete
Delete an mTLS certificate
npx wrangler mtls-certificate deleteyarn wrangler mtls-certificate deletepnpm wrangler mtls-certificate delete--idstringThe id of the mTLS certificate to delete
--namestringThe name of the mTLS certificate record to delete
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、delete コマンドで mTLS 証明書を削除する例です。
npx wrangler mtls-certificate delete --id 99f5fef1-6cc1-46b8-bd79-44a0d5082b8dAre you sure you want to delete certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d (my-origin-cert)? [y/n]
yes
Deleting certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d...
Deleted certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d successfullyセキュアな接続に使う mTLS クライアント証明書と Certificate Authority(CA)チェーン証明書を管理します。
これらの証明書は Hyperdrive の設定で使えます。クライアント認証(mTLS)やカスタム Certificate Authority(CA)を要求するオリジンデータベースへ接続するときに、証明書を提示できます。
cert upload mtls-certificate
Upload an mTLS certificate
npx wrangler cert upload mtls-certificateyarn wrangler cert upload mtls-certificatepnpm wrangler cert upload mtls-certificate--certstringrequiredThe path to a certificate file (.pem) containing a chain of certificates to upload
--keystringrequiredThe path to a file containing the private key for your leaf certificate
--namestringThe name for the certificate
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、upload コマンドで mTLS 証明書をアップロードする例です。
npx wrangler cert upload --cert cert.pem --key key.pem --name my-origin-certUploading mTLS Certificate my-origin-cert...
Success! Uploaded mTLS Certificate my-origin-cert
ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Expires: 1/01/2025アップロード時、証明書と秘密鍵は別ファイル(通常は .pem)である必要があります。
cert upload certificate-authority
Upload a CA certificate chain
npx wrangler cert upload certificate-authorityyarn wrangler cert upload certificate-authoritypnpm wrangler cert upload certificate-authority--namestringThe name for the certificate
--ca-certstringrequiredThe path to a certificate file (.pem) containing a chain of CA certificates to upload
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、upload コマンドで CA 証明書をアップロードする例です。
npx wrangler cert upload certificate-authority --ca-cert server-ca-chain.pem --name SERVER_CA_CHAINUploading CA Certificate SERVER_CA_CHAIN...
Success! Uploaded CA Certificate SERVER_CA_CHAIN
ID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Expires: 1/01/2025cert list
List uploaded mTLS certificates
npx wrangler cert listyarn wrangler cert listpnpm wrangler cert listGlobal flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、list コマンドで mTLS 証明書または CA 証明書を一覧する例です。
npx wrangler cert listID: 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d
Name: my-origin-cert
Issuer: CN=my-secured-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Created on: 1/01/2023
Expires: 1/01/2025
ID: c5d004d1-8312-402c-b8ed-6194328d5cbe
Issuer: CN=another-origin.com,OU=my-team,O=my-org,L=San Francisco,ST=California,C=US
Created on: 1/01/2023
Expires: 1/01/2025cert delete
Delete an mTLS certificate
npx wrangler cert deleteyarn wrangler cert deletepnpm wrangler cert delete--idstringThe id of the mTLS certificate to delete
--namestringThe name of the mTLS certificate record to delete
Global flags
--vbooleanalias: --versionShow version number
--cwdstringRun as if Wrangler was started in the specified directory instead of the current working directory
--configstringalias: --cPath to Wrangler configuration file
--envstringalias: --eEnvironment to use for operations, and for selecting .env and .dev.vars files
--env-filestringPath to an .env file to load - can be specified multiple times - values from earlier files are overridden by values in later files
--experimental-provisionbooleanaliases: --x-provisiondefault: trueExperimental: Enable automatic resource provisioning
--experimental-auto-createbooleanalias: --x-auto-createdefault: trueAutomatically provision draft bindings with new resources
--install-skillsbooleandefault: falseInstall Cloudflare skills for detected AI coding agents before running the command
--profilestringUse a specific auth profile
次は、delete コマンドで mTLS 証明書または CA 証明書を削除する例です。
npx wrangler cert delete --id 99f5fef1-6cc1-46b8-bd79-44a0d5082b8dAre you sure you want to delete certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d (my-origin-cert)? [y/n]
yes
Deleting certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d...
Deleted certificate 99f5fef1-6cc1-46b8-bd79-44a0d5082b8d successfully