pgw.example.com, and loads each renewed certificate without dropping a connection.
pgw doesn’t get certificates itself. It reads a certificate and a key from two files that you name in tls_cert_file and tls_key_file, so any certificate authority and any renewal tool work. This page uses certbot.
Before you begin
- certbot on the host.
- Port 80/tcp open to the internet while certbot runs, for its standalone mode.
Get and install the certificate
1
Get the certificate
2
Create the renewal hook
certbot keeps its files readable by root only, and pgw runs as the
pgw user. So a hook copies each new certificate to a folder that pgw can read, and tells pgw to load it. Create /etc/letsencrypt/renewal-hooks/deploy/pgw.sh:3
Run the hook once
certbot runs the hook only after a renewal, so run it once now to copy the first certificate:
4
Point pgw at the files
Add these lines to
/etc/pgw/config.yaml:5
Restart pgw
pgw reads the two settings only at startup, so this one time it needs a restart:pgw doesn’t start when a named file is missing or isn’t a valid certificate and key. Run
journalctl -u pgw to see why.Check that it works
pgw as its issuer. The log no longer shows serving a self-signed certificate.
Reload the certificate
The hook reloads pgw for you. To reload by hand, after you replace the files yourself, use one of the methods in the table. A reload reads the certificate and key files again. New connections get the new certificate, and open connections stay. When the files aren’t a valid pair, pgw keeps the old certificate and logscertificate not reloaded; the old one stays.
Watch the expiry
The metricpgw_tls_cert_not_after_timestamp_seconds is when the served certificate expires, in Unix seconds. pgw sets it at startup and after each reload. Alert when it’s less than 14 days away:
Next steps
Configure apps for pgw
Register your app’s push credentials, now that apps can connect.
Alerts
Add the certificate expiry rule to your other pgw alerts.