ACME DNS-01 with certbot
certbot can answer the DNS-01 challenge through two small hook scripts that call the PrimeDNS API. This gives you
Let's Encrypt certificates, including wildcards (*.domain.tld), without exposing port 80/443. How the challenge
works with PrimeDNS is explained in ACME DNS-01 certificates with PrimeDNS.
1. Create an API key
In Account → API Keys choose Certificate key and list
each hostname you will issue a certificate for (details: Create an API key).
You'll set the key as PRIMEDNS_API_KEY below.
2. Install the hooks
Download the auth and cleanup hooks and make them executable:
curl -o /usr/local/bin/primedns-auth.sh \
https://primedns.net/media/com_primedns/acme-sh/primedns-auth.sh
curl -o /usr/local/bin/primedns-cleanup.sh \
https://primedns.net/media/com_primedns/acme-sh/primedns-cleanup.sh
chmod +x /usr/local/bin/primedns-auth.sh /usr/local/bin/primedns-cleanup.sh
3. Issue the certificate
Set your API key and run certbot:
export PRIMEDNS_API_KEY="pdns_xxxxxxxxxxxxxxxxxxxx"
certbot certonly \
--manual --preferred-challenges dns \
--manual-auth-hook /usr/local/bin/primedns-auth.sh \
--manual-cleanup-hook /usr/local/bin/primedns-cleanup.sh \
-d domain.tld -d '*.domain.tld'
Renewal
certbot does not auto-renew manual-hook certificates by default. Add a cron job
that re-runs the same command (with PRIMEDNS_API_KEY exported) and
passes --non-interactive, or use the
renewal config hooks
certbot writes under /etc/letsencrypt/renewal/.
Troubleshooting
- A second run with the same ACME account can reuse an authorization that is still valid and skip the challenge, so the hooks are not called at all.
- Errors from the API (
DOMAIN_NOT_FOUND,403,NXDOMAINreported by the CA) and their fixes are listed in the overview.