Obtaining a wildcard SSL certificate from Let's Encrypt enhances your website's security by encrypting all subdomains with a single certificate. Using Certbot with DNS challenges is the recommended method for obtaining such certificates, as it proves domain ownership through DNS record modifications. This guide walks you through the process step-by-step.
Prerequisites
- A registered domain name.
- Access to your DNS provider's management console.
- Server with Certbot installed.
- API credentials for DNS provider (if automation is desired).
Installing Certbot
Certbot can be installed using your server's package manager. For example, on Ubuntu:
Run:
sudo apt update
sudo apt install certbot
Requesting a Wildcard Certificate with DNS Challenge
To obtain a wildcard certificate, you need to specify the DNS challenge. Use the following command:
sudo certbot -d "*.yourdomain.com" -d "yourdomain.com" --manual --preferred-challenges dns certonly
Explanation of the command:
- -d "*.yourdomain.com": Specifies the wildcard subdomain.
- -d "yourdomain.com": Also includes the base domain.
- --manual: Uses manual DNS challenge.
- --preferred-challenges dns: Chooses DNS challenge specifically.
- certonly: Only obtains the certificate without installing.
Adding DNS TXT Records
Certbot will prompt you to create a DNS TXT record with specific values. Log in to your DNS provider's dashboard and add a new TXT record with the provided name and value.
For example:
Record name: _acme-challenge.yourdomain.com
Record value: the string provided by Certbot
After adding the record, wait for DNS propagation, which may take a few minutes.
Completing the Certificate Request
Once the DNS TXT record is in place, press Enter in the terminal to continue. Certbot will verify the DNS record and, if successful, will generate your wildcard certificate.
Automating DNS Challenges
If your DNS provider supports API access, you can automate DNS record creation using Certbot plugins or scripts. Check Certbot's documentation for DNS plugins compatible with your provider.
Installing Your Wildcard SSL Certificate
After obtaining the certificate, you can configure your web server (Apache, Nginx, etc.) to use the new SSL files. Typically, Certbot stores certificates in /etc/letsencrypt/live/yourdomain.com/.
Renewing the Certificate
Wildcard certificates obtained via DNS challenge require renewal every 90 days. Automate renewal with scripts or DNS plugins to simplify the process.
Using Certbot with DNS challenges provides a secure and flexible way to obtain wildcard SSL certificates, ensuring your entire domain and subdomains are protected.