Documentation

esc
    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 write scope. 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:

    Terminal
    $ pantech certificates request example.com www.example.com --exportable

    Export

    Terminal
    $ pantech certificates export <certificate> --out-dir /etc/ssl/example.com

    It asks before it exports (pass --yes in scripts), and writes four files, each readable by its owner only (0600):

    FileHolds
    fullchain.pemThe certificate followed by its intermediates. Most servers want this
    cert.pemThe certificate only
    chain.pemThe intermediates only
    privkey.pemThe 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:

    Terminal
    $ sudo chown root:root /etc/ssl/example.com/privkey.pem$ sudo chmod 600 /etc/ssl/example.com/privkey.pem

    Never commit the key to git or put it in a container image.

    nginx

    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:

    Terminal
    $ sudo nginx -t && sudo systemctl reload nginx

    Caddy

    Caddy normally gets its own certificates. To use the one from Pantech instead, name the files:

    caddyfile
    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
    }
    Terminal
    $ sudo systemctl reload caddy

    After 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:

    Shell
    #!/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 nginx

    Give 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

    Was this page helpful?

    Updated