This tutorial can Auto-Renew wildcard letsencrypt certs for domain on name.com.
- wildcard domain, e.g., *.example.com
- domain hosted by https://www.name.com, we use the API of name.com to add DNS TXT records with a shell script.
Wildcard certificates issued by letsencrypt.org need DNS TXT record to challenge, we can add TXT record manually when you apply the cert. If we want to automate it, we need to write a script that use the API of DNS provider to add TXT record. certbot has provided command argument --manual-auth-hook
to pass the script.
Get your own api token provided by name.com: https://www.name.com/account/settings/api.
ATTENTION
- get username and token from PRODUCTION, not
DEVELOPMENT/TEST ENVIRONMENT
- WHITELIST your server's IP, it's the server you apply the cert.
Make sure you installed certbot before
sudo apt-get install certbot
Download the following scripts from below.
auth.sh
: a script to add txt recordclean.sh
: a script to clean txt record when the renew finishedrenew.sh
: call certbot to renew cert
then add execute permission to scripts:
sudo chmod a+x auth.sh clean.sh renew.sh
crontab -e
add this to the last line, replacing /path/to/renew.sh
, YOUR_DOMAIN_COM
, DOMAIN_TO_GET_CERT
(same as YOUR_DOMAIN_COM or subdomain of YOUR_DOMAIN_COM), USERNAME
, TOKEN
, with YOURS.
@monthly /path/to/renew.sh YOUR_DOMAIN_COM DOMAIN_TO_GET_CERT USERNAME TOKEN