You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/cloudflare-one/connections/connect-devices/user-side-certificates/manual-deployment.mdx
+1-4Lines changed: 1 addition & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -119,10 +119,7 @@ To install a Cloudflare certificate in macOS, you can use either the Keychain Ac
119
119
<TabItemlabel="Keychain Access">
120
120
121
121
1. Download a Cloudflare certificate.
122
-
2. Open the `.crt` file in Keychain Access. If prompted, enter your local password.
123
-
3. In **Keychain**, choose the access option that suits your needs and select **Add**.
124
-
4. In the list of certificates, locate the newly installed certificate. Keychain Access will mark this certificate as not trusted. Right-click the certificate and select **Get Info**.
125
-
5. Select **Trust**. Under **When using this certificate**, select _Always Trust_.
## Add mTLS authentication to your Access configuration
22
-
23
20
:::caution[Important]
24
21
25
22
The mTLS certificate is used only to verify the client certificate. It does not control the SSL certificate presented during the [server hello](https://www.cloudflare.com/learning/ssl/what-happens-in-a-tls-handshake/).
26
23
27
-
mTLS is checked on a per host basis. Access sets a flag for when a client certificate was presented and successfully completed mTLS authentication. However, to actually enforce mTLS, you need an Access policy in place, and Access policies are both host and path specific. If you want to enforce mTLS on a specific path, you need to make sure your Access policies are configured accordingly.
28
-
29
24
:::
30
25
31
-
To enforce mTLS authentication from [Zero Trust](https://one.dash.cloudflare.com):
26
+
## Enforce mTLS authentication
27
+
28
+
### Prerequisites
29
+
30
+
- An [Access application](/cloudflare-one/applications/configure-apps/self-hosted-public-app/) for the hostname that you would like to secure with mTLS.
31
+
- A CA that issues client certificates for your devices.
If the client certificate is directly signed by the root CA, you only need to upload the root. If the client certificate is signed by an intermediate certificate, you must upload the entire CA chain (intermediate and root). For example:
45
+
```txt
46
+
-----BEGIN CERTIFICATE-----
47
+
<intermediate.pem>
48
+
-----END CERTIFICATE-----
49
+
-----BEGIN CERTIFICATE-----
50
+
<rootCA.pem>
51
+
-----END CERTIFICATE-----
52
+
```
53
+
54
+
Do not include any SSL/TLS server certificates; Access only uses the CA chain to verify the connection between the user's device and Cloudflare.
42
55
43
56
5. In **Associated hostnames**, enter the fully-qualified domain names (FQDN) that will use this certificate.
44
57
45
58
These FQDNs will be the hostnames used for the resources being protected in the [Access policy](/cloudflare-one/policies/access/). You must associate the Root CA with the FQDN that the application being protected uses.
46
59
47
-
6.Select **Save**.
60
+
6. Save the policy.
48
61
49
-
If your zone is using an intermediate certificate in addition to the root certificate, upload the entire chain.
62
+
9. Go to **Access** > **Policies**.
50
63
51
-
7. Next, go to **Access** > **Applications**.
64
+
10.[Create an Access policy](/cloudflare-one/policies/access/policy-management/#create-a-policy) using one of the following [selectors](/cloudflare-one/policies/access/#selectors):
65
+
-**Valid Certificate**: Any client certificate that can authenticate with the Root CA will be allowed to proceed.
66
+
-**Common Name**: Only client certificates with a specific common name will be allowed to proceed.
52
67
53
-
8. Find the application you would like to enforce mTLS on and select **Configure**. The application must be included in the **Associated hostnames**list from Step 5.
68
+
11. If this is for a client who does not need to log in through an IdP, set the policy **Action**to _Service Auth_.
54
69
55
-
9. Create a new (or amend an existing) [Access policy](/cloudflare-one/policies/access/).
| Service Auth | Include | Common Name | `John Doe` |
75
+
</Example>
56
76
57
-
If this is for a client who does not need to log in through an IdP, set the policy **Action**to _Service Auth_.
77
+
12. Save the policy, then go to **Access**> **Applications**.
58
78
59
-
10. Add an mTLS authentication rule using the following selectors:
79
+
13. Select the application you would like to enforce mTLS on and select **Configure**. The application must be included in the **Associated hostnames** list from Step 5.
|**Common Name**| Only client certificates with a specific common name will be allowed to proceed. |
64
-
|**Valid Certificate**| Any client certificate that can authenticate with the Root CA will be allowed to proceed. |
81
+
14. In the **Policies** tab, add your mTLS policy.
65
82
66
-
11. Save the policy.
83
+
15. Save the application.
67
84
68
-
:::caution
85
+
You can now authenticate to the application using a client certificate. For instructions on how to present a client certificate, refer to [Test mTLS](#test-mtls).
69
86
70
-
Cloudflare Gateway cannot inspect traffic to mTLS-protected domains. If a device has the WARP client turned on and passes HTTP requests through Gateway, access will be blocked unless you [bypass HTTP inspection](/cloudflare-one/policies/gateway/http-policies/#do-not-inspect) for the domain.
71
-
:::
87
+
## Test mTLS
72
88
73
-
## Test mTLS using cURL
89
+
###Test using cURL
74
90
75
91
To test the application protected by an mTLS policy:
76
92
77
93
1. First, attempt to curl the site without a client certificate.
78
-
This curl command example is for the site `example.com` that has an [Access policy](/cloudflare-one/policies/access/) set for `https://auth.example.com`:
94
+
This curl command example is for the site `example.com` that has an [Access application and policy](#add-mtls-to-your-access-application) set for `https://auth.example.com`:
79
95
80
96
```sh
81
97
curl -sv https://auth.example.com
82
98
```
83
99
84
100
Without a client certificate in the request, a `403 forbidden` response displays and the site cannot be accessed.
85
101
86
-
2. Now, add your client certificate information to the request:
102
+
2. Now, add your client certificate and key to the request:
When the authentication process completes successfully, a `CF_Authorization Set-Cookie` header returns in the response.
93
109
94
-
## Test mTLS using Cloudflare PKI
110
+
:::caution
111
+
112
+
Cloudflare Gateway cannot inspect traffic to mTLS-protected domains. If a device has the WARP client turned on and passes HTTP requests through Gateway, access will be blocked unless you [bypass HTTP inspection](/cloudflare-one/policies/gateway/http-policies/#do-not-inspect) for the domain.
113
+
:::
114
+
115
+
### Test in a browser
116
+
117
+
To access an mTLS-protected application in a browser, the client certificate must be imported into your browser's certificate manager. Instructions vary depending on the browser. Your browser may use the operating system's root store or its own internal trust store.
118
+
119
+
The following example demonstrates how to add a client certificate to the macOS system keychain:
120
+
121
+
:::caution[Important]
122
+
123
+
The command adds the client certificate to the trusted store on your device. Only proceed if you are comfortable doing so and intend to keep these testing certificates safeguarded.
124
+
:::
125
+
126
+
1. Navigate to the directory containing the client certificate and key.
Assuming your browser uses the macOS system store, you can now connect to the mTLS application through the browser.
130
+
131
+
## Generate mTLS certificates
132
+
133
+
You can use open source private key infrastructure (PKI) tools to generate certificates to test the mTLS feature in Cloudflare Access.
134
+
135
+
### OpenSSL
136
+
137
+
This section covers how to use [OpenSSL](https://www.openssl.org/) to generate a root and intermediate certificate, and then issue client certificates that can authenticate against the CA chain.
138
+
139
+
#### Generate the root CA
140
+
141
+
1. Generate the root CA private key:
142
+
143
+
```sh
144
+
openssl genrsa -aes256 -out rootCA.key 4096
145
+
```
146
+
147
+
When prompted, enter a password to use with `rootCA.key`.
148
+
149
+
2. Create a self-signed root certificate called `rootCA.pem`:
You will be prompted to enter your private key password and fill in some optional fields. For testing purposes, you can leave the optional fields blank.
156
+
157
+
#### Generate an intermediate certificate
158
+
159
+
1. Generate the intermediate CA private key:
160
+
161
+
```sh
162
+
openssl genrsa -aes256 -out intermediate.key 4096
163
+
```
164
+
165
+
When prompted, enter a password to use with `intermediate.key`.
166
+
167
+
2. Create a certificate signing request (CSR) for the intermediate certificate:
95
168
96
-
You can use Cloudflare's open source tools for private key infrastructure (PKI) to test the mTLS feature in Cloudflare Access. This guide details the process to generate a Root Client Authority (CA), add it to the Cloudflare dashboard, and issue client certificates that can authenticate against the root CA and reach a protected resource.
You will be prompted to enter your private key password and fill in some optional fields. For testing purposes, you can leave the optional fields blank.
174
+
175
+
3. Create a CA Extension file called `v3_intermediate_ca.ext`. For example,
176
+
177
+
```txt
178
+
subjectKeyIdentifier = hash
179
+
authorityKeyIdentifier = keyid:always,issuer
180
+
basicConstraints = critical, CA:true
181
+
keyUsage = critical, cRLSign, keyCertSign
182
+
```
183
+
184
+
Make sure that `basicConstraints` includes the `CA:true` property. This property allows the intermediate certificate to act as a CA and sign client certificates.
185
+
186
+
4. Sign the intermediate certificate with the root CA:
1. Combine the intermediate and root certificates into a single file:
195
+
196
+
```sh
197
+
cat intermediate.pem rootCA.pem > ca-chain.pem
198
+
```
199
+
200
+
The intermediate certificate should be at the top of the file, followed by its signing certificate.
201
+
202
+
2. Upload the contents of `ca.pem` to Cloudflare Access. For instructions, refer to [Add mTLS to your Access application](#add-mtls-to-your-access-application).
203
+
204
+
#### Generate a client certificate
205
+
206
+
1. Generate a private key for the client:
207
+
208
+
```sh
209
+
openssl genrsa -out client.key 2048
210
+
```
211
+
212
+
2. Create a CSR for the client certificate:
213
+
214
+
```sh
215
+
openssl req -new -key client.key -out client.csr
216
+
```
217
+
218
+
You will be prompted to fill in some optional fields. For testing purposes, you can set **Common Name** to something like `John Doe`.
219
+
220
+
3. Sign the client certificate with the intermediate certificate:
4. Validate the client certificate against the certificate chain:
227
+
228
+
```sh
229
+
openssl verify -CAfile ca-chain.pem client.pem
230
+
```
231
+
232
+
```sh output
233
+
client.pem: OK
234
+
```
235
+
236
+
You can now use the client certificate (`client.pem`) and its key (`client.key`) to [test mTLS](#test-mtls).
237
+
238
+
### Cloudflare PKI
239
+
240
+
This guide uses [Cloudflare's PKI toolkit](https://github.com/cloudflare/cfssl) to generate a root CA and client certificates from JSON files.
241
+
242
+
#### 1. Install dependencies
99
243
100
244
The process requires two packages from Cloudflare's PKI toolkit:
101
245
@@ -105,9 +249,9 @@ The process requires two packages from Cloudflare's PKI toolkit:
105
249
You can install these packages from the [Cloudflare SSL GitHub repository](https://github.com/cloudflare/cfssl). You will need a working installation of Go, version 1.12 or later. Alternatively, you can [download the packages](https://github.com/cloudflare/cfssl) directly.
106
250
Use the instructions under Installation to install the toolkit, and ensure that you install all of the utility programs in the toolkit.
107
251
108
-
### 2. Generate the Root CA
252
+
####2. Generate the root CA
109
253
110
-
1. Create a new directory to store the Root CA.
254
+
1. Create a new directory to store the root CA.
111
255
112
256
2. Within that directory, create two new files:
113
257
@@ -154,27 +298,27 @@ Use the instructions under Installation to install the toolkit, and ensure that
154
298
}
155
299
```
156
300
157
-
3. Now, run the following command to generate the Root CA with those files.
301
+
3. Now, run the following command to generate the root CA with those files.
158
302
159
303
```sh
160
304
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
161
305
```
162
306
163
-
4.Within the directory, check its content to confirm the output was successful.
307
+
4.The command will output a root certificate (`ca.pem`) and its key (`ca-key.pem`).
164
308
165
309
```sh
166
310
ls
167
311
```
168
312
169
-
The output should now return the following content:
5. Upload the contents of `ca.pem` to Cloudflare Access. For instructions, refer to [Add mTLS to your Access application](#add-mtls-to-your-access-application).
318
+
319
+
#### 3. Generate a client certificate
176
320
177
-
Returning to the terminal, generate a client certificate that will authenticate against the Root CA uploaded.
321
+
To generate a client certificate that will authenticate against the uploaded root CA:
178
322
179
323
1. Create a file named `client-csr.json` and add the following JSON blob:
180
324
@@ -204,31 +348,9 @@ Returning to the terminal, generate a client certificate that will authenticate
The instructions here cover usage with a computer running macOS.
216
-
217
-
1. In the same working directory, run the following command to add the client certificate into the macOS Keychain.
218
-
219
-
:::caution[Important]
220
-
221
-
The command adds the client certificate to the trusted store on your device. Only proceed if you are comfortable doing so and intend to keep these testing certificates safeguarded.
2. Select the certificate in the Keychain list to set the certificate to trusted. Confirm that the certificate is listed in **My Certificates**.
351
+
The command will output a client certificate file (`client.pem`) and its key (`client-key.pem`). You can now use these files to [test mTLS](#test-mtls).
230
352
231
-
### Create a CRL
353
+
####Create a certificate revocation list
232
354
233
355
You can use the Cloudflare PKI toolkit to generate a certificate revocation list (CRL), as well. This list will contain client certificates that are revoked.
2. Open the <code>{props.cert}</code> file in Keychain Access. If prompted, enter your local password.
7
+
3. In **Keychain**, choose the access option that suits your needs and select **Add**.
8
+
4. In the list of certificates, locate the newly installed certificate. Keychain Access will mark this certificate as not trusted. Right-click the certificate and select **Get Info**.
9
+
5. Select **Trust**. Under **When using this certificate**, select _Always Trust_.
0 commit comments