Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What a Wildcard Covers

  • Covered: any single label in place of the asterisk, such as www.example.com, shop.example.com, or api.example.com.
  • Not covered: the bare domain example.com. Request it as a second name on the same certificate.
  • Not covered: two levels down, such as a.b.example.com. That needs its own name or a wildcard for *.b.example.com.

If you only have a few names, a normal certificate that lists each of them, as in Certbot with Nginx, is simpler and works over port 80.

How the DNS-01 Challenge Works

  1. Certbot asks Let's Encrypt for a certificate and receives a token for each name.
  2. A TXT record named _acme-challenge.example.com is published with a value derived from the token.
  3. Let's Encrypt looks up the record from several places on the internet.
  4. If the value matches, the certificate is issued, and the record can be removed.

When you request both example.com and *.example.com, both checks use the same record name, so two TXT values exist under it at the same time. Keep both. No port on the server has to be open for DNS-01, which also makes it useful for servers that are not reachable from the internet.

The Manual Method and Its Limit

sudo certbot certonly --manual --preferred-challenges dns -d example.com -d '*.example.com' --email YOUR_EMAIL

Quote the asterisk so the shell does not expand it. Certbot prints the TXT value, waits while you add it in your DNS panel, and continues when you press Enter. Check that the record is visible before you do:

dig +short TXT _acme-challenge.example.com

The limit: a manual certificate does not renew by itself. The renewal timer cannot type into your DNS panel, so certbot renew fails for it unless you wrote an authentication hook script, and the certificate expires unless you repeat the steps by hand each time. With Let's Encrypt lifetimes at 90 days today and set to shrink to 64 days in February 2027 and 45 days in February 2028, use the manual method only for a test.

Use a DNS Plugin

DNS plugins create and remove the TXT record through your DNS provider's API. Plugins exist for many providers, and the RFC 2136 plugin works with your own BIND or similar name server. The example uses the Cloudflare plugin. On Ubuntu and Debian:

sudo apt install python3-certbot-dns-cloudflare

On AlmaLinux and Rocky Linux, from EPEL:

sudo dnf install python3-certbot-dns-cloudflare

With the Certbot snap:

sudo snap set certbot trust-plugin-with-root=ok
sudo snap install certbot-dns-cloudflare

Store the API Token Safely

Create an API token in the Cloudflare dashboard with the Zone, DNS, Edit permission for this one zone only. Put it in a file that only root can read:

sudo mkdir -p /root/.secrets
sudo nano /root/.secrets/cloudflare.ini
dns_cloudflare_api_token = YOUR_API_TOKEN
sudo chmod 600 /root/.secrets/cloudflare.ini

Certbot warns about unsafe permissions on every run while other users can read the file. Anyone with this token can change your DNS, so keep it out of chats, tickets, and version control.

Request the Certificate

sudo certbot certonly --dns-cloudflare \
  --dns-cloudflare-credentials /root/.secrets/cloudflare.ini \
  -d example.com -d '*.example.com' \
  --email YOUR_EMAIL \
  --deploy-hook "systemctl reload nginx"

The files land in /etc/letsencrypt/live/example.com/. Because certonly does not touch the web server, point every HTTPS server block at them with ssl_certificate and ssl_certificate_key. The deploy hook reloads Nginx after each renewal. Check any subdomain afterward with openssl s_client.

Test the Renewal

sudo certbot renew --dry-run

If the dry run fails with a TXT record that was not found, the provider may need more time to publish records. The Cloudflare plugin waits 10 seconds by default; add, for example, --dns-cloudflare-propagation-seconds 60 when you request the certificate, and Certbot stores it for renewals. Timers and hooks are covered in how to renew Let's Encrypt certificates.

Delegate the Challenge Record

If your main DNS provider has no API, add a CNAME for _acme-challenge.example.com that points to a name in a zone you can automate. Let's Encrypt follows the CNAME, and your main DNS stays as it is. The client must then write the TXT record in that other zone, so use a hook script or a tool built for delegated validation.

Was this answer helpful?
Loading...