Free Wildcard Certificates using Cloudflare, Let’s Encrypt and

Table of Contents


I already covered Azure DNS, it’s time to cover Cloudflare, too.

If you haven’t done so yet, sign up to Cloudflare (it’s free), and move your domain name to Cloudflare.

Note: Cloudflare can (and in fact does, by default) proxy your website and generate SSL certificates for you automatically (which you can disable by pausing your website), but in this case you still do need SSL certificates on your server for full security. is one of the many Let’s Encrypt clients. It has built-in support for Cloudflare DNS, and it is written in pure Bash, so it’s very portable. Most importantly, it supports ACME v2, which allows for wildcard certificates.


To obtain

git clone /opt/

Obtain your Cloudflare Global API Key, then set up your credentials on the server:

export CF_Key="***"
export CF_Email="[email protected]"

Don’t worry, you only need to set these once, then will save those in its config folder. Now acquire a staging cert for and all its subdomains:

/opt/ --issue --dns dns_cf --dnssleep 20 --force -d -d * --staging

If it works, you can try doing the same for a production cert:

/opt/ --issue --dns dns_cf --dnssleep 20 --force -d -d *

Since the certificates are stored under /root/, you need to tell SELinux to treat these files as certs:

yum install setools-console checkpolicy policycoreutils policycoreutils-python
semanage fcontext --add -t cert_t "/root/*)?"
restorecon -rv /root/


A cronjob like this should suffice:

00 07 1 * * root /opt/ "--renew" "--dns" "dns_cf" "--dnssleep" "20" "--force" "-d" "" "-d" "*" >> /var/log/ 2>&1
05 07 1 * * root /sbin/nginx -s reload


Tags: , , , , , , , , ,