Abstract

Last week, dozens of schools found out their certificate authority was being distrusted and they needed to replace all of their certificates in a few days.

We wanted to know how we’d handle it if our own CA went away, and how long it would take. So we tried it with one of our other products. It has 6 certificates from Let’s Encrypt, deploying to 18 targets across Windows IIS, Linux nginx, Elasticsearch, and a mail server.

Then we wargamed it: “Let’s Encrypt is being distrusted. Chrome removes its roots in a week. Go.”

Here’s what we did.

Picking a new CA

We picked Google Trust Services. Its ACME certificates are free, it’s in every major trust store, and all it needs from us is a Google Cloud account, which we already have.

GTS uses External Account Binding, so you need a key from Google Cloud before you can open an ACME account with it. It’s two commands in your Google Cloud project, then pasting the key ID and HMAC into CertKit’s issuer form.

gcloud services enable publicca.googleapis.com
gcloud publicca external-account-keys create

CertKit uses it to register an ACME account for your CertKit account, so this only needs to happen once.

Updating CAA records

CAA records in DNS allow you to lock down which certificate authorities can issue for your domain. Our CAA records allowed Let’s Encrypt and nobody else. We added lines for GTS next to the ones we had.

example.com.  CAA  0 issue "letsencrypt.org"
example.com.  CAA  0 issue "pki.goog"
example.com.  CAA  0 issuewild "letsencrypt.org"
example.com.  CAA  0 issuewild "pki.goog"

We use wildcards in a lot of our products because it enables web clustering scenarios. Wildcards are safe, common, and widely used.

Changing the issuer

CertKit is a central hosted ACME client. Every certificate’s settings live in our database, including the names, the key type, and which CA issues it. CertKit orders each certificate itself, and the agents on our servers pick it up and deploy it. None of those servers needs an ACME client, and none of them knows or cares which CA we use.

So switching CAs is just a backend change. You can’t change the issuer on an existing certificate from the app, so for an emergency like eMudhra, our team makes the change for you. For our own six certificates, it was one small change. Point every Let’s Encrypt certificate in the account at the GTS issuer, make the current certificates due for renewal now, commit.

CertKit’s renewal job runs about once a minute. On its next pass, it found six certificates due and started ordering them from GTS.

Validation was automatic and needed no changes. Every name on these certificates already has a CNAME from _acme-challenge to CertKit’s validation DNS zone, added once when we first set them up. That’s delegated DNS validation, and the CNAME doesn’t care which CA is asking. GTS sent its DNS-01 challenges, CertKit wrote the TXT records in its own zone, and GTS found them. About two minutes after the commit, all six certificates were issued by Google Trust Services.

Deploying to 18 places

A new certificate marks every deployment that uses it as pending. Each agent checks in every 30 seconds, sees the new certificate, and deploys it. IIS got the new certificate on its existing binding. The nginx clusters and the mail server reloaded. None of those drop a connection, so their deployments run as soon as a certificate changes. About 30 seconds after issuance, 13 of our 18 deployments were serving GTS certificates.

The other five were Elasticsearch. Their deployments restart the service, so they have a deploy window from 1am to 3am. The certificate renewed with everything else, and the deployments sat in “Waiting for Deploy Window” with the Let’s Encrypt certificate still installed.

A deploy window in CertKit allows you to control when a certificate is applied to your infrastructure. We recommned you set one for every system that gets disrupted by changing a certificate

We weren’t going to wait for 1am. We opened the deployment and forced an update immediately, one at a time. The agent deployed on its next check-in, and the Elasticsearch nodes reconnected.

All 18 synced.

Wargame result

From the time we started until the last certificate was deployed, it was just under 10 minutes. Most of that was us chatting while we waited for DNS to propagate the CAA change.

10 minutes for full CA migration.

Our wargame was small. InCommon had 30,000 certificates under the distrusted root, and the University of Minnesota alone had 916 on that chain the week it broke.

Most of what we did wasn’t per certificate or per server. Two CAA lines per domain and one SQL transaction cover any number of certificates. Most agents pick up its new certificates within 30 seconds, whether it’s one of 18 deployments or 1,800.

Issuance is what slows down. GTS accepts 100 new orders an hour per Google Cloud project by default. If we needed to do hundreds, we’d pick a different issuer with higher limits, or spread the change across multiple issuers. A certificate is a certificate. The issuer doesn’t really matter. Worst case, that 10 minutes becomes a few hours waiting for limits to reset, but no one ever has to log in to a server manually.

If you’re still moving off eMudhra, contact us. We can help automate certificates so you’ll never have a panic replacement weekend again.


CertKit automates certificate lifecycle management so the next CA distrust is a database change.

Keep reading