networking:ssl_certificate_lets_encrypt
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| networking:ssl_certificate_lets_encrypt [2020/09/25 10:24] – [Install Let's Encrypt WildCard on Nginx] bstafford | networking:ssl_certificate_lets_encrypt [2020/10/01 08:24] (current) – removed bstafford | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Using Let's Encrypt for WildCard ====== | ||
| - | This document shows you how to generate a free WildCard certificate using Let's Encrypt that you can use on a Nginx server and/or a Palo Alto Networks firewall for things like GlobalProtect. | ||
| - | |||
| - | ===== DNS API - CloudFlare ===== | ||
| - | For this to work, you will need a public domain such as jbstafford.co.uk. Regardless of who the registrar is, this guide assumes that you have transferred the nameservers to be CloudFlare. | ||
| - | |||
| - | You will need to create an "API Token" in CloudFlare. | ||
| - | - Go to https:// | ||
| - | - Click "API Tokens" | ||
| - | - Click " | ||
| - | - Click "Use template" | ||
| - | - Set | ||
| - | - Permissions = Zone DNS Edit. | ||
| - | - Zone Resources = Include Specific zone jbstafford.co.uk. | ||
| - | - IP Address Filtering = You can add in the subnet of your public IP range to restrict token use. | ||
| - | - TTL = You can set a start and end date on the token. | ||
| - | - Click " | ||
| - | - Click " | ||
| - | - You will see your token displayed. Copy it somewhere safe and keep it secret. Treat it like a password. | ||
| - | - You can verify that the token works by running the curl command that will also be listed on the screen. The command is set to run well in a Linux CLI. | ||
| - | |||
| - | ===== Install acme.sh ===== | ||
| - | acme.sh is the script that will run in the background and renew the certificate automatically. | ||
| - | |||
| - | SSH to your Linux server and run the following commands | ||
| - | < | ||
| - | git clone https:// | ||
| - | </ | ||
| - | |||
| - | Install acme.sh to / | ||
| - | < | ||
| - | touch / | ||
| - | cd / | ||
| - | acme.sh --install --accountemail your-email-id@gmail.com</ | ||
| - | |||
| - | Generate the WildCard with the following commands as root | ||
| - | < | ||
| - | acme.sh --issue --dns dns_cf --keylength 4096 -d jbstafford.co.uk -d *.jbstafford.co.uk</ | ||
| - | |||
| - | You can enforce OCSP stapling by using this command instead | ||
| - | < | ||
| - | |||
| - | This will create the key and certificate in ''/ | ||
| - | |||
| - | ===== Install Let's Encrypt WildCard in Palo Alto Networks Firewall ===== | ||
| - | To install the certificate on a firewall, you will need the username and password of a user on the firewall that has API permissions to import and commit. Instructions on how to do that are elsewhere. | ||
| - | |||
| - | You will need to edit ''/ | ||
| - | < | ||
| - | export PANOS_PASS=" | ||
| - | export PANOS_HOST=" | ||
| - | |||
| - | Then run the following command to deploy the certificate. This command will import the certificate and commit. The certificate name will match the domain name. After the first commit, you can set Certificate SSL/TLS Profiles to use it. | ||
| - | < | ||
| - | |||
| - | ===== Install Let's Encrypt WildCard on Nginx ===== | ||
| - | This assumes the web server is on a separate machine from the Linux host generating the certificates. | ||
| - | |||
| - | Create a dedicated user account on the other web server and give it permissions to write to ''/ | ||
| - | |||
| - | Make sure that the root user can SSH without a password (i.e. use a SSH key) into the web server as the new user. | ||
| - | |||
| - | Edit ''/ | ||
| - | < | ||
| - | export DEPLOY_SSH_SERVER=" | ||
| - | export DEPLOY_SSH_KEYFILE="/ | ||
| - | export DEPLOY_SSH_CERTFILE="/ | ||
| - | |||
| - | Run the following to deploy. It may error the first time as the cert files won't exist. Run it again. | ||
| - | < | ||
| - | |||
| - | Note, you will want to get the intermediate certificate from the chain and put it in ''/ | ||
| - | |||
| - | Then run the following after the cert is created/ | ||
| - | < | ||
| - | systemctrl restart nginx | ||
| - | curl www.jbstafford.co.uk | ||
| - | curl jbstafford.co.uk</ | ||
| - | |||
| - | The last few lines above (curl) are to ensure the page is called at least once after the restarting of Nginx. This will trigger the OCSP stale refresh. If you do not do this, the first Firefox user to visit the site will get an error. When they refresh, the error will vanish. | ||
| - | |||
| - | You will also need to get the full chain of the certificate (including the root) and put it in the file ''/ | ||
| - | You will also need to update you ''/ | ||
| - | < | ||
| - | ssl_stapling_verify on; | ||
| - | ssl_trusted_certificate / | ||
| - | resolver 8.8.8.8;</ | ||
| - | |||
| - | Firefox users can permanently get around the problem with setting the following to false. | ||
| - | < | ||
networking/ssl_certificate_lets_encrypt.1601029440.txt.gz · Last modified: (external edit)
