Apply for Let's Encrypt's wildcard certificates for second-level-domains with Drone CI, in both RSA and EC (Elliptic Curve) algorithms.
The idea is to apply for wildcard certificates and use them elsewhere, deploying them in other automation procedures, instead of applying for one keypair per server. This might also help to reduce exposures of what you've deployed on searching services like crt.sh.
The .drone.yml
that comes with this repository is not something you can commit and push and deploy right away. The DNS provider I use as an example is ClouDNS, you might want to refer to LEGO's manual, to figure out which variable to fill in when using a different DNS provider (as long as it's supported by LEGO).
Also, no exception handling in this automation. Running CI tasks with empty or wrong variables provided will results in build failures, or hitting the rate limit of Let's Encrypt.
This automation obtains certificates in RSA and EC algorithms that cover the following DNS names, assuming you're signing example.com
:
example.com
*.example.com
That would satisfy the needs of deploying personal websites, as well as self-hosted services.
This automation uses LEGO to respond to LE's ACME challenge and obtaining certificates. If the signing is successful, rsa.cert.pem
and ec.cert.pem
, which returned by LE's server, will be left within the workspace. You can append your own steps, commit or publish them somewhere else, and fetch them in other automation procedures.
- Fill in the name of domain you own, in the
DOMAIN
variable at the beginning of.drone.yml
. - Fill in the E-mail address you want to use as an account, in the
ACME_ACCOUNT_MAIL
variable. - If you're testing the automation, it's usually good idea to temporarily change the
ACME_SERVER
variable fromhttps://acme-v02.api.letsencrypt.org/directory
tohttps://acme-staging-v02.api.letsencrypt.org/directory
. - Create a repository to hold this automation, trigger a sync in Drone CI if needed, and activate the repository in Drone CI.
- Create a secret named
ACME_ACCOUNT_KEY
under the repository's secret panel, and fill in the private key of your Let's Encrypt account. (Note that it's okay to provide multi-line PEM private keys with Drone CI's Secret feature)
To generate an account private key, useopenssl genrsa 4096 > account.key
. - Create a secret named
DOMAIN_RSA_KEY
, and fill in the RSA private key which you want to apply certificates with.
To generate an RSA key for your domain, useopenssl genrsa 4096 > domain_rsa.key
. - Create a secret named
DOMAIN_EC_KEY
, and fill in the EC private key which you want to apply certificates with.
To generate an EC key for your domain, useopenssl ecparam -name prime256v1 -genkey -noout -out domain_ec.key
. - Go to LEGO project's manual, find the DNS provider you use, find out the variable you need to provide to the LEGO, and provide them with secrets in both
signing_rsa_key
andsigning_ec_key
step in.drone.yml
.
For example, LEGO wantsCLOUDNS_AUTH_ID
andCLOUDNS_AUTH_PASSWORD
when using ClouDNS. - Append your own steps to push/publish/commit these resulting certificates, which named
rsa.cert.pem
andec.cert.pem
under the workspace.
Attention! They will go to nowhere if you don't do anything.