Skip to content

Commit e0046ae

Browse files
maxvppedrosousa
andauthored
[ZT] Create and activate cert via API (#19114)
Co-authored-by: Pedro Sousa <[email protected]>
1 parent e35c58d commit e0046ae

File tree

1 file changed

+62
-1
lines changed
  • src/content/docs/cloudflare-one/connections/connect-devices/user-side-certificates

1 file changed

+62
-1
lines changed

src/content/docs/cloudflare-one/connections/connect-devices/user-side-certificates/index.mdx

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ banner:
77
content: The default global Cloudflare root certificate will expire on 2025-02-02. If you installed the default Cloudflare certificate before 2024-10-17, you must <a href="/cloudflare-one/connections/connect-devices/user-side-certificates/#generate-a-cloudflare-root-certificate">generate a new certificate</a> and activate it for your Zero Trust organization to avoid inspection errors.
88
---
99

10+
import { Tabs, TabItem } from "~/components";
11+
1012
Advanced security features such as [HTTPS traffic inspection](/cloudflare-one/policies/gateway/http-policies/tls-decryption/), [Data Loss Prevention](/cloudflare-one/policies/data-loss-prevention/), [anti-virus scanning](/cloudflare-one/policies/gateway/http-policies/antivirus-scanning/), [Access for Infrastructure](/cloudflare-one/applications/non-http/infrastructure-apps/), and [Browser Isolation](/cloudflare-one/policies/browser-isolation/) require users to install and trust a root certificate on their device. You can either install the certificate provided by Cloudflare (default option), or generate your own custom certificate and upload it to Cloudflare.
1113

1214
Gateway [generates a unique root CA](#generate-a-cloudflare-root-certificate) for each Zero Trust account and deploys it across the Cloudflare global network. Alternatively, Enterprise users can upload and deploy their own [custom certificate](/cloudflare-one/connections/connect-devices/user-side-certificates/custom-certificate/).
@@ -26,38 +28,97 @@ Zero Trust will indicate if a certificate is ready for use in inspection based o
2628

2729
To generate a new Cloudflare root certificate for your Zero Trust organization:
2830

31+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
32+
2933
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Settings** > **Resources**.
3034
2. In **Certificates**, select **Manage**.
3135
3. Select **Generate certificate**.
3236
4. Choose a duration of time before the certificate expires. Cloudflare recommends expiration after five years. Alternatively, choose _Custom_ and enter a custom amount in days.
3337
5. Select **Generate certificate**.
3438

39+
</TabItem>
40+
41+
<TabItem label="API">
42+
43+
Send a `POST` request to the [Create Zero Trust certificate](/api/resources/zero_trust/subresources/gateway/subresources/certificates/methods/create/) endpoint.
44+
45+
```sh
46+
curl --request POST \
47+
https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/certificates \
48+
--header "Authorization: Bearer <API_TOKEN>"
49+
```
50+
51+
The API will respond with the ID and contents of the new certificate.
52+
53+
</TabItem> </Tabs>
54+
3555
The certificate will appear in your list of certificates as **Inactive**. To download a generated certificate, select it, then choose **Download .pem** and/or **Download .crt**. To deploy your certificate and turn it on for inspection, you need to [activate the certificate](#activate-a-root-certificate).
3656

3757
Each Zero Trust account can generate a new root certificate a maximum of three times per day.
3858

3959
## Activate a root certificate
4060

4161
:::note
42-
Zero Trust accounts using the Cloudflare certificate prior to 2024-10-17 will need to redeploy and activate the newly generated certificate. Zero Trust accounts created during or after 2024-10-17 will use an available certificate by default.
62+
Zero Trust accounts using the default Cloudflare certificate prior to 2024-10-17 will need to redeploy and activate the newly generated certificate. Zero Trust accounts created during or after 2024-10-17 will use an available certificate by default.
4363
:::
4464

4565
Once a certificate is generated in or uploaded to Zero Trust, you need to activate it. Activating a certificate deploys it across the Cloudflare network. You can have up to 25 available certificates at once.
4666

4767
To activate your root certificate:
4868

69+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
70+
4971
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Settings** > **Resources**.
5072
2. In **Certificates**, select **Manage**.
5173
3. Select the certificate you want to activate.
5274
4. Select **Activate**.
5375

76+
</TabItem>
77+
78+
<TabItem label="API">
79+
80+
Send a `POST` request to the [Activate a Zero Trust certificate](/api/resources/zero_trust/subresources/gateway/subresources/certificates/methods/activate/) endpoint.
81+
82+
```sh
83+
curl --request POST \
84+
https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/certificates/{certificate_id}/activate \
85+
--header "Authorization: Bearer <API_TOKEN>"
86+
```
87+
88+
</TabItem> </Tabs>
89+
5490
The status of the certificate will change to **Pending** while it deploys. Once the status of your certificate is **Available**, you can install it on your user's devices either [with WARP](/cloudflare-one/connections/connect-devices/user-side-certificates/automated-deployment/) or [manually](/cloudflare-one/connections/connect-devices/user-side-certificates/manual-deployment/).
5591

5692
Once you deploy and install your certificate, you can turn it on for use in inspection:
5793

94+
<Tabs syncKey="dashPlusAPI"> <TabItem label="Dashboard">
95+
5896
1. In [Zero Trust](https://one.dash.cloudflare.com/), go to **Settings** > **Resources**.
5997
2. In **Certificates**, select **Manage**.
6098
3. Select the certificate you want to turn on.
6199
4. In **Basic information**, select **Confirm and turn on certificate**.
62100

101+
</TabItem>
102+
103+
<TabItem label="API">
104+
105+
Send a `PUT` request to the [Update Zero Trust account configuration](/api/resources/zero_trust/subresources/gateway/subresources/configurations/methods/update/) endpoint. For example:
106+
107+
```sh
108+
curl --request PUT \
109+
'https://api.cloudflare.com/client/v4/accounts/{account_id}/gateway/configuration' \
110+
--header "Content-Type: application/json" \
111+
--header "Authorization: Bearer <API_TOKEN>" \
112+
--data '{
113+
"settings": {
114+
"certificate": {
115+
"id": "<CERTIFICATE_ID>",
116+
"in_use": true
117+
}
118+
}
119+
}'
120+
```
121+
122+
</TabItem> </Tabs>
123+
63124
You can set multiple certificates to **Available**, but you can only turn on one certificate for use in inspection at a time. Setting a certificate as **In-Use** will set any other turned on certificates as **Available** and prevent them from being used for inspection until turned on again.

0 commit comments

Comments
 (0)