Let's Encrypt wildcard certificate with certbot and DNS-01: step-by-step guide
How to obtain a *.domain.com certificate with certbot and DNS-01 verification, from installation on Ubuntu 24.04 to automatic renewal.
UptimeMag editorial team · 21 November 2026 · 3 min read

Anyone managing multiple subdomains under a single domain (panel, webmail, API, staging) often prefers a single wildcard certificate instead of one for each host. With Let's Encrypt you get it for free, but only with one specific verification method: DNS-01. This guide covers the entire procedure on Ubuntu 24.04, from installation to renewal verification.\n\n## Why DNS-01 and not the standard HTTP-01\n\nCertbot's official documentation is clear: obtaining a wildcard certificate requires the DNS authentication method, via --manual or a suitable DNS plugin for your DNS provider. The technical reason lies in the nature of the wildcard name: HTTP file-based verification proves control of a single host at a time, while a wildcard covers names that may not yet exist on the server. This is why Let's Encrypt asks you to publish a TXT record under _acme-challenge in your DNS zone, which proves control of the entire zone.\n\n## Installing certbot on Ubuntu 24.04\n\nThe package recommended by the project is the snap, not the one in apt repositories. The command-line sequence on a system with snapd already present (included by default on Ubuntu 24.04):\n\n\nsudo snap install core\nsudo snap refresh core\nsudo snap install --classic certbot\nsudo ln -s /snap/bin/certbot /usr/bin/certbot\n\n\nIf certbot is already installed from apt on your system, remove it before switching to snap, to prevent the certbot command from invoking the wrong version.\n\n## Choosing the plugin: automatic or manual DNS\n\nTo automate TXT record publication, you need a specific plugin for your DNS provider (Cloudflare, Route53, DigitalOcean and others): sudo snap set certbot trust-plugin-with-root=ok followed by sudo snap install certbot-dns-<provider-name> (for example certbot-dns-cloudflare). Those not using one of the supported providers must use the manual plugin, which prints the record value you need to create manually in your DNS panel and waits for keyboard confirmation.\n\nOne point many guides online miss: in the official plugin table, the manual one is explicitly marked as incompatible with automatic renewal, unless you hook a script that handles TXT publication on its own at each renewal. Those choosing the manual method without a hook will need to repeat the operation by hand every 90 days.\n\n## The command to obtain the wildcard\n\nWith a DNS plugin installed, a typical command is:\n\n\nsudo certbot certonly \\\n --dns-cloudflare \\\n --dns-cloudflare-credentials /etc/letsencrypt/cloudflare.ini \\\n -d example.com \\\n -d '*.example.com'\n\n\nWithout a plugin, with manual verification:\n\n\nsudo certbot certonly --manual --preferred-challenges dns \\\n -d example.com -d '*.example.com'\n\n\nThe quotes around the wildcard prevent the shell from interpreting * as a filesystem wildcard character. By requesting both the bare domain and the wildcard, certbot generates two separate DNS-01 challenges: both TXT records must stay online simultaneously until issuance completes, because they share the same name _acme-challenge.example.com.\n\n## Where the certificate ends up\n\nThe files are placed under /etc/letsencrypt/live/, in a folder named after the first domain specified in the command (so if the wildcard is listed first, the folder will take that name unless a certificate with that name already exists). Inside you'll find fullchain.pem (complete certificate) and privkey.pem (private key), the two files to point to in your webserver configuration.\n\n## Automatic renewal: what to check\n\nInstallation via snap sets up periodic renewal via a systemd timer automatically, with no need to add anything to crontab. To verify that the timer exists and is active:\n\n\nsystemctl list-timers 'certbot*' 'snap.certbot*'\n\n\nThe typical name on snap installations is snap.certbot.renew.timer. To test the renewal process without consuming actual requests against Let's Encrypt (which has rate limits), use the staging environment with a dry-run:\n\n\nsudo certbot renew --dry-run\n\n\nA dry-run with an automatic DNS plugin actually writes a test TXT record and then deletes it: if the API credentials don't have permission to delete records, the error surfaces here, not at the first real renewal a few months from now.\n\n## Final verification of the installed certificate\n\nOnce the webserver is serving the new certificate, direct command-line verification avoids relying solely on the browser lock icon:\n\n\nopenssl s_client -connect example.com:443 -servername example.com < /dev/null 2>/dev/null | openssl x509 -noout -dates -subject\n\n\nThe command prints the certificate expiry date (notAfter) and subject: if *.example.com appears among the alternative names, the wildcard was installed correctly. To check all covered names, including alternative names, you can replace -dates -subject with -text and search for the Subject Alternative Name line.
Written with the help of artificial intelligence and checked by the editors (EU AI Act, art. 50).