Certificate based authentication
Time Required
15 Minutes
Difficulty
Easy
Required Knowledge
DNS, Zero Trust, Shell
Prerequisites
Domain managed by Cloudflare
Zero Trust configured
Cloudflare Tunnels configured
Client Certificate
This section only needs to be done for 1 domain
Generate a certificate
Log into Cloudflare and select your domain
In the search box, input
Client Certificatesand open the page
Click on Create Certificate on the right
SettingEntryPrivate Key Type
RSA 2048
Certificate Validity
Your choice
Click on Create and ensure your key format is
PEM
Save your Certificate
You will be presented with a certificate and a private key
Under Certificate, click on
Click to copyOpen a text editor, paste the contents and save the file as
certificate.pemUnder Private key, click on
Click to copyDo not share your private key - anyone with this can bypass your Zero Trust
Open a text editor, paste the contents and same the file as
certificate.keyYou should have something similar to the below:

Generate your PFX file
Download and install the relevant OpenSSL version for your machine from here: https://slproweb.com/products/Win32OpenSSL.html
Launch OpenSSL - you will be prompted with a terminal window
CD to the directory with your certificate files
Run the below command, and provide password when prompted
openssl pkcs12 -export -out certificate.pfx -inkey certificate.key -in certificate.pemYou will now have a certificate.pfx file - this is the file you can import to your end user devices

Do not share your PFX file - anyone with this can bypass your Zero Trust
Save your 3 files to somewhere secure
Import / install your PFX file
You will need to import the PFX file on any devices you wish to authenticate using the certificate
Get the PFX file onto your machine
Double click the file to open it
Certificate Import Wizard page:
Store location: Current User
Click next
On the file to import page
Click on next
Private Key protection page
Input the password set above
Click on next
Certificate store page
Tick "place all certificates in the following store"
Click on browse
select Trusted Root Certification Authorities
Click ok OK
click on next
Click on Finish
Get the PFX file onto your device
Use a file browser to open it
On the extract certificate page,
input the password
Click on OK
On the certificate type page,
Select app user certificate
Click on OK
On the certificate name page,
Input the name of the domain
click on OK
Configure host addresses that can use the client certificate
In this example, we will set a wildcard - this means all subdomains will use the client certificate.
Go back to the Cloudflare Client Certificates page
Under hosts, click on edit and input
*, then select*.your.domainfrom the dropdownConfirm the domain looks valid (eg not
*..your.domain)Click on save
I have broken WSS connection from Pterodactyl Panel to Wings enabling this on a domain that Pterodactyl was hosted on
Configure Zero Trust
Create your Certificate authentication policy
Click on your name in the top left
On the left hand menu, select Zero Trust
On the left, expand Access controls and select Policies
Click on Add a policy
Last updated