Skip to content

Instantly share code, notes, and snippets.

@gustavohenrique
Last active December 6, 2020 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavohenrique/ec64364f0c04eef9553226f955ceea4c to your computer and use it in GitHub Desktop.
Save gustavohenrique/ec64364f0c04eef9553226f955ceea4c to your computer and use it in GitHub Desktop.
Generate wildcard certificates using certbot

Before Each

pip install certbot
mkdir letsencrypt

AWS Route53

export AWS_PROFILE=myprofile
pip install certbot-dns-route53
certbot certonly \
  --logs-dir ./letsencrypt/log/ \
  --config-dir ./letsencrypt/config/ \
  --work-dir ./letsencrypt/work/ \
  -m gustavo.henrique@mydomain.com.br \
  --agree-tos \
  --non-interactive \
  --server https://acme-v02.api.letsencrypt.org/directory \
  -d mydomain.com -d '*.mydomain.com' --dns-route53

ls letsencrypt/config/archive/mydomain.com

# renew
certbot renew --cert-name mydomain.com --logs-dir ./letsencrypt/log/ --config-dir ./letsencrypt/config/ --work-dir ./letsencrypt/work/

Digital Ocean

pip install certbot-dns-digitalocean
certbot certonly \
  --agree-tos \
  --logs-dir ./letsencrypt/log/ \
  --config-dir ./letsencrypt/config/ \
  --work-dir ./letsencrypt/work/ \
  -m gustavo@gustavohenrique.net \
  --dns-digitalocean \
  --dns-digitalocean-credentials ~/digitalocean.ini \
  -d "mydomain.com" \
  -d "*.mydomain.com"

Cloudflare

pip install certbot-dns-cloudflare
certbot certonly \
  --agree-tos \
  --logs-dir ./letsencrypt/log/ \
  --config-dir ./letsencrypt/config/ \
  --work-dir ./letsencrypt/work/ \
  -m gustavo@gustavohenrique.net \
  --dns-cloudflare \
  --dns-cloudflare-credentials ~/cloudflare.ini \
  -d "mydomain.com" \
  -d "*.mydomain.com"

Generic Wildcard Manual

DOMAIN="mydomain.com,*.mydomain.com"
certbot certonly \
  --server https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos \
  --manual \
  --logs-dir ./letsencrypt/log/ \
  --config-dir ./letsencrypt/config/ \
  --work-dir ./letsencrypt/work/ \
  -m gustavo@gustavohenrique.net \
  --preferred-challenges dns \
  --debug-challenges \
  -d "$DOMAIN"

You need to change TXT record manually and waiting for DNS propagation (maybe 1 hour) before press enter to continue.
Check running:

nslookup -q=txt _acme-challenge.mydomain.com
# or
dig TXT _acme-challenge.mydomain.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment