Obtaining a wildcard SSL certificate from Let's Encrypt is an excellent way to secure all subdomains of your domain with a single certificate. Certbot, a popular ACME client, supports various DNS plugins that automate the process of DNS validation. This guide explains how to use Certbot DNS plugins to get wildcard certificates efficiently.
Prerequisites
- A registered domain name
- Access to your DNS provider's API credentials
- Certbot installed on your server
- Supported DNS plugin for your DNS provider
Installing Certbot and DNS Plugins
First, install Certbot and the DNS plugin compatible with your DNS provider. For example, for Cloudflare:
On Debian/Ubuntu:
sudo apt install certbot python3-certbot-dns-cloudflare
Adjust the package name based on your DNS provider.
Configuring DNS API Credentials
Create a credentials file with your DNS API token or key. For Cloudflare, it might look like:
dns_cloudflare_api_token = your_api_token_here
Save this file securely, e.g., as ~/.secrets/cloudflare.ini, and set permissions:
chmod 600 ~/.secrets/cloudflare.ini
Requesting a Wildcard Certificate
Use Certbot with the DNS plugin to request a wildcard certificate. Run the following command:
sudo certbot certonly --dns-cloudflare --dns-cloudflare-credentials ~/.secrets/cloudflare.ini -d example.com -d '*.example.com' --preferred-challenges dns-01
Renewing Certificates
Certbot automatically renews certificates before they expire. To test renewal:
sudo certbot renew --dry-run
Conclusion
Using Certbot DNS plugins simplifies the process of obtaining and renewing wildcard certificates from Let's Encrypt. Ensure your DNS API credentials are secure, and regularly test your renewal process to maintain SSL coverage for all your subdomains.