Sub topic 17
Wildcard certificates with DNS-01
This chapter assumes you can use a Linux shell with sudo, manage DNS records for a domain, and use Certbot. It also assumes that nginx and the domain are already configured.
A wildcard certificate covers many subdomains with one name. A certificate for *.example.com can cover www.example.com, api.example.com, and shop.example.com. It does not cover the bare name example.com, so request both names when you need both:
example.com*.example.com
Why wildcard certificates require DNS-01
Let's Encrypt must verify that you control the domain before issuing a certificate. The DNS-01 challenge proves control by requiring a specific TXT record under _acme-challenge.
The process is:
- Certbot asks Let's Encrypt for a certificate.
- Let's Encrypt gives Certbot a unique challenge value.
- You publish that value as a DNS TXT record.
- Let's Encrypt queries public DNS.
- If the value matches, Let's Encrypt issues the certificate.
HTTP-01 validation cannot prove control of a wildcard name. DNS-01 is therefore required for wildcard certificates. The web server does not need to serve the challenge, and port 80 does not have to be reachable for this validation method.
Requesting a wildcard certificate manually
Certbot can use manual DNS validation:
sudo certbot certonly --manual --preferred-challenges dns \
-d example.com -d '*.example.com'Certbot displays one or more TXT values. Create a DNS record with these properties:
| Property | Value |
|---|---|
| Record type | TXT |
| Name | `_acme-challenge.example.com` |
| Value | The exact challenge value shown by Certbot |
| TTL | A short value such as 60 or 300 seconds |
Wait for the record to become visible from public DNS before continuing. You can check it with:
dig +short TXT _acme-challenge.example.comIf multiple TXT values are present, keep existing values until all active validations finish. DNS providers often add the domain automatically, so the record name might need to be entered as _acme-challenge rather than the full name.
Automating DNS validation
Manual DNS validation is useful for testing, but it usually cannot renew unattended. An administrator must create a new TXT record during every renewal.
For production, use a Certbot DNS plugin supported by your DNS provider. The plugin uses the provider's API to create and remove TXT records. Store its API credentials in a protected file, grant only the permissions needed to edit DNS records, and never place credentials in a public repository.
After installing the provider's plugin, the command typically resembles this:
sudo certbot certonly \
--dns-PROVIDER \
--dns-PROVIDER-credentials /etc/letsencrypt/dns-provider.ini \
-d example.com -d '*.example.com'Replace PROVIDER and the plugin options with the names documented for your DNS provider. Test the renewal process with sudo certbot renew --dry-run before relying on it.
Exercise
Why must a wildcard certificate use DNS-01 validation, and why should a production setup use a DNS plugin instead of manual mode?
Show answer
A wildcard certificate requires DNS-01 because the challenge proves control through a DNS TXT record. A DNS plugin automates that record during renewal, while manual mode requires an administrator to intervene each time.