1-year certificates no longer exist. The maximum is 200 days now, 100 days from 15 March 2027 and 47 days from 15 March 2029 — automation handles every one. See the timeline →

Help centre / Setup guides

ACME when your DNS is hosted elsewhere

DNS at Cloudflare or another provider? Let certbot add the validation record through its API, so wildcards and renewals happen without you.

If your domain’s DNS is managed somewhere other than your web server, for example at Cloudflare, your registrar or Amazon Route 53, your ACME client needs permission to add a short-lived record there. This guide shows how to set that up once, so every renewal after that happens without you. We use certbot and Cloudflare as the worked example, because that is the most common combination we see, then cover other providers and clients.

Do I need this?

You need DNS validation if you want a wildcard (*.example.com), if port 80 on your server is not reachable from the internet, or if you would rather not depend on your website being up for validation. Otherwise the simpler webroot method in the ACME setup guide works fine, even when your DNS is hosted elsewhere.

How DNS validation works

To prove you control a domain, your ACME client adds a TXT record called _acme-challenge to the domain’s DNS. The certificate authority looks it up, and once it matches, the certificate is issued and the record is removed. Because certificates are re-issued regularly, this happens again at every renewal, so it needs to be automatic.

Can I add the TXT record by hand instead?

Yes. Run certbot with --manual --preferred-challenges dns and it shows you the value to add (two values if you asked for both example.com and *.example.com; add both under the same _acme-challenge name). Check it has appeared with dig TXT _acme-challenge.example.com +short before you press Enter. It works, but you must do it by hand at every renewal, which is why we recommend the API method below.

Before you start

  • Your directory URL, Key ID and HMAC key from your order page. Always use these; instructions elsewhere may show an older address. Treat the HMAC key like a password.
  • Every name you want on the certificate. Your order includes the bare domain free, but certbot only requests the names you list, so list them all: -d example.com -d www.example.com, or -d example.com -d '*.example.com' for a wildcard (a wildcard does not cover the bare domain on its own).
  • Root access to the server (the commands below are run as root).

Step 1: create a limited Cloudflare API token

  1. In Cloudflare, go to My Profile → API Tokens → Create Token.
  2. Choose the Edit zone DNS template.
  3. Under Zone Resources, pick Specific zone and your domain, so the token can change nothing else.
  4. Create the token and copy it. Cloudflare shows it only once.

Use a token like this, not your Global API Key: if it ever leaked, it could only edit the DNS of that one domain.

Step 2: install the Cloudflare plugin for certbot

# AlmaLinux, Rocky, RHEL (with EPEL)
dnf install certbot python3-certbot-dns-cloudflare

# Debian, Ubuntu
apt install certbot python3-certbot-dns-cloudflare

Step 3: store the token safely

mkdir -p /root/.secrets
chmod 700 /root/.secrets
echo 'dns_cloudflare_api_token = <your-token>' > /root/.secrets/cloudflare.ini
chmod 600 /root/.secrets/cloudflare.ini

Certbot warns, and may refuse, if the file can be read by other users, so keep those permissions.

Step 4: register your ACME account (once per server)

certbot register --server <directory-url> \
  --eab-kid <kid> --eab-hmac-key <key> \
  --email you@example.com --agree-tos --no-eff-email

Step 5: issue the certificate

certbot certonly --dns-cloudflare \
  --dns-cloudflare-credentials /root/.secrets/cloudflare.ini \
  --dns-cloudflare-propagation-seconds 30 \
  --server <directory-url> \
  -d example.com -d '*.example.com' --cert-name example.com \
  --deploy-hook "systemctl reload httpd"
  • --cert-name gives the certificate a plain name (no asterisk), which becomes its folder name.
  • --deploy-hook reloads your web server after each renewal, so it starts using the new certificate. Use the right command for your server, for example systemctl reload nginx, or /usr/local/apache/bin/apachectl graceful on CWP.
  • If certbot already holds a certificate for these names that you validated by hand, add --force-renewal once, so the switch to Cloudflare takes effect.

Step 6: point your web server at the files

Certbot keeps the current files in /etc/letsencrypt/live/example.com/:

FileWhat it isWhere it goes
fullchain.pemYour certificate plus the intermediatesApache SSLCertificateFile, NGINX ssl_certificate
privkey.pemThe private key (keep it secret)Apache SSLCertificateKeyFile, NGINX ssl_certificate_key
cert.pemYour certificate onlyRarely needed
chain.pemThe intermediates onlyRarely needed

Always use these live/ paths, so renewed certificates are picked up automatically. Check every site that should use the certificate, including the bare domain’s own site if it has one.

Using a control panel such as CWP, cPanel or Plesk?

Control panels usually run their own copy of Apache, in their own folder (on CWP, /usr/local/apache). Don’t use certbot’s --apache option: it installs and tests the system Apache instead, and fails with errors such as SSLCertificateFile … localhost.crt does not exist. Use certonly as above and set the two file paths in the panel or in your site’s SSL virtual host. If --apache was tried earlier, make sure the system web server it installed is not enabled or running.

Step 7: check that renewal is set up

systemctl enable --now certbot-renew.timer   # or certbot.timer on Debian/Ubuntu
cat /etc/letsencrypt/renewal/example.com.conf
certbot certificates

The renewal file should show authenticator = dns-cloudflare and your renew_hook. certbot certificates lists the names, expiry date and file paths at a glance.

Why not test with certbot renew --dry-run?

Certbot’s dry run is built around Let’s Encrypt’s test servers. Against another certificate authority it may not be a harmless test, so check the renewal file and timer as above instead.

Other DNS providers

Certbot has plugins for many providers, installed and used the same way: Amazon Route 53 (python3-certbot-dns-route53), DigitalOcean, OVH, Gandi, Linode, Google Cloud DNS and others. Each has its own credentials file; the plugin’s documentation lists the settings. Some registrars only allow API access on certain accounts, so check yours offers it before you start.

Using acme.sh or win-acme instead of certbot?

acme.sh has DNS support built in for over a hundred providers. For Cloudflare, set export CF_Token="<your-token>" and add --dns dns_cf to your acme.sh --issue command; it remembers the token for renewals. win-acme has a Cloudflare validation plugin you choose when it asks how to validate; paste the token when prompted.

My DNS provider has no API

You can point the challenge record at a DNS service that does have one. Add a CNAME record once, for _acme-challenge.example.com, pointing at a name on the other service (for example an acme-dns server), and your ACME client updates that service at each renewal. Alternatively, move the domain’s DNS to a provider with an API, such as Cloudflare, which offers DNS hosting free.

If you get new credentials

Certbot keeps one account for each ACME directory URL. If you are given new EAB credentials, for example after starting a new subscription, certbot register says an account already exists, and trying to remove it may fail if the old one has already been closed. Move the old account folder aside, register again, then issue the certificate again so renewals use the new account:

mv /etc/letsencrypt/accounts/<directory-host>/<path> /root/acme-account-old
certbot register --server <directory-url> --eab-kid <kid> --eab-hmac-key <key> \
  --email you@example.com --agree-tos --no-eff-email

For example, for https://acme.sectigo.com/v2/DV the folder is /etc/letsencrypt/accounts/acme.sectigo.com/v2/DV.

Stuck at any step? Send us a message with the command you ran and the error, and we will help.

Still stuck? Call 03333 444 205

Monday to Friday, UK hours. If a validation check is failing or a renewal looks wrong, we would rather talk it through than have you guess.

Related: ACME setup guide · Domain validation methods