Quick and Easy process of getting letsencrypt wildcard domain certificate with cloudflare as dns provider
Login to any of your server ( this method does not requires to run commands from a working apache or nginx web server hence you can even run these commands from your workstation line client machine)
Create a cloudflare credentials file
need your email id and api key of cloudflare login
you can get cloudflare api key from login into cloudflare account and nevigating to myprofile -> api tokens -> api keys -> global api key -> view
# vim .cloudflarecredentials.ini
paste content as bellow
# Cloudflare API credentials used by Certbot
dns_cloudflare_email = [email protected]
dns_cloudflare_api_key = 0123456789abcdef0123456789abcdef01234567
use your mail id and api key in above file
save and make it secure
# chmod 400 .cloudflarecredentials.ini
Now install required package
# yum -y install python2-certbot-dns-cloudflare
Now run bellow command
# certbot certonly --dns-cloudflare --dns-cloudflare-credentials .cloudflarecredentials.ini -d *.mydomain.com
replace *.mydomain.com with *. your domain
Now accept policy etc from certbot and it will automatically validate ddomain and generate certificate and key file for you.
certificate file : /etc/letsencrypt/live/mydomain.com/fullchain.pem;
keyfile : /etc/letsencrypt/live/mydomain.com/privkey.pem;
you can use this certificates now in nginx or apache. example bellow is config snippet for nginx
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
Now for automatic renewal setup a cron as bellow
0 0,12 * * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew
Done!
Comments
Post a Comment