Certificates / On your servers
Use a certificate on your servers
Export an exportable certificate with its private key, install it in nginx or Caddy on your machines, and fetch it again after every renewal.
Pantech services, such as load balancers, use certificates directly. To use one on your own machines, such as in nginx or Caddy, you need its private key. That is what exportable certificates are for.
Exportable or not
A certificate is exportable only if you asked for it when you requested or imported it. You cannot change it later.
- Not exportable (the default): the private key never leaves Pantech. Only Pantech services can use the certificate. This is the safest choice.
- Exportable: owners and admins can download the certificate, its chain and its private key.
Anyone with the private key can pretend to be your site. So:
- Export needs owner or admin access, and on the API a key with the
writescope. An AI app needs Manage and delete access. - Every export is recorded with who did it, before the key is handed out.
- Every owner and admin is emailed a security notice (
certificate.exported).
Request an exportable certificate:
$ pantech certificates request example.com www.example.com --exportableExport
$ pantech certificates export <certificate> --out-dir /etc/ssl/example.comIt asks before it exports (pass --yes in scripts), and writes four files, each readable by its owner only (0600):
| File | Holds |
|---|---|
fullchain.pem | The certificate followed by its intermediates. Most servers want this |
cert.pem | The certificate only |
chain.pem | The intermediates only |
privkey.pem | The private key, PKCS #8 PEM |
A file already there is kept unless you pass --force. --stdout prints the full chain and the key instead.
The API (POST /certificates/{certificate_id}/export) returns the same as certificate_pem, chain_pem and private_key_pem. Keep the key in a file only its server can read:
$ sudo chown root:root /etc/ssl/example.com/privkey.pem$ sudo chmod 600 /etc/ssl/example.com/privkey.pemNever commit the key to git or put it in a container image.
nginx
server {
listen 443 ssl;
listen [::]:443 ssl;
http2 on;
server_name example.com www.example.com;
ssl_certificate /etc/ssl/example.com/fullchain.pem;
ssl_certificate_key /etc/ssl/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
location / {
proxy_pass http://127.0.0.1:8080;
}
}Check the configuration, then reload:
$ sudo nginx -t && sudo systemctl reload nginxCaddy
Caddy normally gets its own certificates. To use the one from Pantech instead, name the files:
example.com, www.example.com {
tls /etc/ssl/example.com/fullchain.pem /etc/ssl/example.com/privkey.pem
reverse_proxy 127.0.0.1:8080
}$ sudo systemctl reload caddyAfter every renewal
Pantech renews the certificate about every 60 days, but it cannot reach into your server. Fetch it again after each renewal, or your server keeps serving the old one until it expires.
The simplest way is a daily job that exports only when the certificate's fingerprint changed:
#!/bin/sh
# /etc/cron.daily/pantech-cert
set -e
cert=cert_06gk3x9tq7m2v8r4y1c5d0zp8w
dir=/etc/ssl/example.com
now=$(pantech certificates get "$cert" --json | jq -r .fingerprint_sha256)
[ "$now" = "$(cat "$dir/fingerprint" 2>/dev/null)" ] && exit 0
pantech certificates export "$cert" --out-dir "$dir" --force --yes
echo "$now" > "$dir/fingerprint"
nginx -t && systemctl reload nginxGive the job its own API key with the write scope, and a key policy that allows only certificates:Read and certificates:Export on this certificate. Each export emails your owners and admins, so exporting only when it changed keeps the notices meaningful.
Or react to the certificate.renewed webhook event, and export from there.
Next
- Certificates: validation, renewal and statuses.
- Import a certificate.