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
@@ -48,6 +48,8 @@ To enforce mTLS authentication for an application:
48
48
-----END CERTIFICATE-----
49
49
```
50
50
51
+
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.
52
+
51
53
5. In **Associated hostnames**, enter the fully-qualified domain names (FQDN) that will use this certificate.
52
54
53
55
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.
@@ -77,7 +79,7 @@ To enforce mTLS authentication for an application:
77
79
78
80
15. Save the application.
79
81
80
-
Next, [test mTLS authentication](#test-mtls) to your application.
82
+
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).
81
83
82
84
## Test mTLS
83
85
@@ -125,9 +127,114 @@ Assuming your browser uses the macOS system store, you can now connect to the mT
125
127
126
128
## Generate mTLS certificates
127
129
130
+
You can use open source private key infrastructure (PKI) tools to generate certificates to test the mTLS feature in Cloudflare Access.
131
+
132
+
### OpenSSL
133
+
134
+
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.
135
+
136
+
#### Generate the root CA
137
+
138
+
1. Generate the root CA private key:
139
+
140
+
```sh
141
+
openssl genrsa -aes256 -out rootCA.key 4096
142
+
```
143
+
144
+
When prompted, enter a password to use with `rootCA.key`.
145
+
146
+
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.
153
+
154
+
#### Generate an intermediate certificate
155
+
156
+
1. Generate the intermediate CA private key:
157
+
158
+
```sh
159
+
openssl genrsa -aes256 -out intermediate.key 4096
160
+
```
161
+
162
+
When prompted, enter a password to use with `intermediate.key`.
163
+
164
+
2. Create a certificate signing request (CSR) for the intermediate certificate:
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.
171
+
172
+
3. Create a CA Extension file called `v3_intermediate_ca.ext`. For example,
173
+
174
+
```txt
175
+
subjectKeyIdentifier = hash
176
+
authorityKeyIdentifier = keyid:always,issuer
177
+
basicConstraints = critical, CA:true
178
+
keyUsage = critical, cRLSign, keyCertSign
179
+
```
180
+
181
+
Make sure that `basicConstraints` includes the `CA:true` property. This property allows the intermediate certificate to act as a CA and sign client certificates.
182
+
183
+
4. Sign the intermediate certificate with the root CA:
1. Combine the intermediate and root certificates into a single file:
192
+
193
+
```sh
194
+
cat intermediate.pem rootCA.pem > ca-chain.pem
195
+
```
196
+
197
+
The intermediate certificate should be at the top of the file, followed by its signing certificate.
198
+
199
+
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).
200
+
201
+
#### Generate a client certificate
202
+
203
+
1. Generate a private key for the client:
204
+
205
+
```sh
206
+
openssl genrsa -out client.key 2048
207
+
```
208
+
209
+
2. Create a CSR for the client certificate:
210
+
211
+
```sh
212
+
openssl req -new -key client.key -out client.csr
213
+
```
214
+
215
+
You will be prompted to fill in some optional fields. For testing purposes, you can set **Common Name** to something like `John Doe`.
216
+
217
+
3. Sign the client certificate with the intermediate certificate:
4. Validate the client certificate against the certificate chain:
224
+
225
+
```sh
226
+
openssl verify -CAfile ca-chain.pem client.pem
227
+
```
228
+
229
+
```sh output
230
+
client.pem: OK
231
+
```
232
+
233
+
You can now use the client certificate (`client.pem`) and its key (`client.key`) to [test mTLS](#test-mtls).
234
+
128
235
### Cloudflare PKI
129
236
130
-
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.
237
+
This guide uses [Cloudflare's PKI toolkit](https://github.com/cloudflare/cfssl) to generate a root CA and client certificates from JSON files.
131
238
132
239
#### 1. Install dependencies
133
240
@@ -139,9 +246,9 @@ The process requires two packages from Cloudflare's PKI toolkit:
139
246
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.
140
247
Use the instructions under Installation to install the toolkit, and ensure that you install all of the utility programs in the toolkit.
141
248
142
-
#### 2. Generate the Root CA
249
+
#### 2. Generate the root CA
143
250
144
-
1. Create a new directory to store the Root CA.
251
+
1. Create a new directory to store the root CA.
145
252
146
253
2. Within that directory, create two new files:
147
254
@@ -188,27 +295,27 @@ Use the instructions under Installation to install the toolkit, and ensure that
188
295
}
189
296
```
190
297
191
-
3. Now, run the following command to generate the Root CA with those files.
298
+
3. Now, run the following command to generate the root CA with those files.
192
299
193
300
```sh
194
301
cfssl gencert -initca ca-csr.json | cfssljson -bare ca
195
302
```
196
303
197
-
4.Within the directory, check its content to confirm the output was successful.
304
+
4.The command will output a root certificate (`ca.pem`) and its key (`ca-key.pem`).
198
305
199
306
```sh
200
307
ls
201
308
```
202
309
203
-
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).
315
+
209
316
#### 3. Generate a client certificate
210
317
211
-
Returning to the terminal, generate a client certificate that will authenticate against the Root CA uploaded.
318
+
To generate a client certificate that will authenticate against the uploaded root CA:
212
319
213
320
1. Create a file named `client-csr.json` and add the following JSON blob:
214
321
@@ -238,11 +345,7 @@ Returning to the terminal, generate a client certificate that will authenticate
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).
0 commit comments