Operating PKI: ACME automation as lifetimes shrink, revocation availability and CA compromise plans
A worked example in three parts: issue, renew and revoke certificates with ACME against a local Pebble CA (HTTP-01, DNS-01 for a wildcard, a 160-hour profile and ARI), publish CRLs so that they stay available and fresh, and run an issuing-CA key compromise drill on the private PKI from lesson 4.
Contentsand lesson path
On this page
- The problem
- Step 1: How ACME issues a certificate
- Step 2: Issue with HTTP-01, then a wildcard with DNS-01
- Step 3: Renewal, ARI and revocation through ACME
- Step 4: Revocation endpoints that stay available
- Step 5: Drill an issuing-CA key compromise
- Common mistakes
- Check your understanding
- Apply it
- Review prompt
Lessons of TLS & PKI
- What TLS gives you: confidentiality, integrity and authentication Concept · 15 min
- Lab: the TLS 1.3 handshake on the wire, with SNI, ALPN and HTTP/2 vs HTTP/3 Lab · 25 min
- Certificates and chains: how a client decides to trust a server Concept · 20 min
- Lab: a two-tier private CA (offline root, issuing CA), server and client certificates, and mutual TLS Lab · 30 min
- Operating PKI: ACME automation as lifetimes shrink, revocation availability and CA compromise plans Worked example · 25 min
- Check: debug five broken TLS endpoints with openssl s_client Knowledge check · 10 questions
What you will learn
- Issue and automate certificates with a private CA and with ACME, and configure mutual TLS between two services.
- Design a private PKI for an organisation - an offline root and issuing CAs, revocation endpoints that stay available, and a recovery plan for an issuing-CA key compromise.
01. The problem
You run the private PKI from lesson 4 for internal services, and a public website with certificates from a public CA. Three jobs remain.
- Public certificates must renew without people. The CA/Browser Forum Baseline Requirements, which every publicly trusted CA follows, cut the maximum certificate lifetime from 398 days to 200 days on 15 March 2026, 100 days on 15 March 2027 and 47 days on 15 March 2029 (ballot SC-081). Reuse of a domain validation drops to 10 days by 2029.
- Revocation information must stay available: a strict client refuses every certificate once its CRL is past
nextUpdateand no new one can be fetched. - You need a tested plan for the day the issuing CA's key is stolen.
Part 1 uses Pebble, Let's Encrypt's ACME test server, and certbot; parts 2 and 3 use the pki-lab folder from lesson 4. Everything runs on 127.0.0.1. Run every block in one terminal, which keeps its variables.
02. Step 1: How ACME issues a certificate
ACME (RFC 8555) is a JSON-over-HTTPS protocol. Every request is signed with an account key, so the CA knows which account asks. One issuance has five stages:
- Account: the client creates an account with its public key.
- Order: it asks for a certificate for a list of identifiers, such as
shop.lab.test. - Authorisations and challenges: for each identifier the CA offers challenges. HTTP-01: serve a token at
http://<name>/.well-known/acme-challenge/<token>on port 80. DNS-01: publish a TXT record at_acme-challenge.<name>. TLS-ALPN-01 (RFC 8737): answer a TLS connection on port 443 that offers ALPNacme-tls/1with a special certificate. Wildcards can only be validated through DNS, and DNS-01 also works for hosts the CA cannot reach. - Finalize: once every authorisation is valid, the client sends a CSR.
- Download the certificate chain.
Renewal is a new order. ARI (ACME Renewal Information, RFC 9773) lets the CA tell each client when to renew, so a CA can move renewals earlier before a planned mass revocation.
Build Pebble with Go (1.25 or newer) and install certbot. Pebble's API uses a test certificate shipped in its source, which you copy from the Go module cache.
mkdir acme-lab && cd acme-lab
uv venv -q --python 3.12 .venv && source .venv/bin/activate
uv pip install -q "certbot==5.10.0"
GOBIN=$PWD/bin go install github.com/letsencrypt/pebble/v2/cmd/[email protected] \
github.com/letsencrypt/pebble/v2/cmd/[email protected]
TESTCERTS=$(go env GOMODCACHE)/github.com/letsencrypt/pebble/[email protected]/test/certs
mkdir -p pebble acme
cp $TESTCERTS/localhost/cert.pem $TESTCERTS/localhost/key.pem pebble/
cp $TESTCERTS/pebble.minica.pem pebble/ && chmod u+w pebble/*.pem
go version -m bin/pebble | awk '$1 == "mod" {print $2, $3}'
certbot --versiongithub.com/letsencrypt/pebble/v2 v2.10.3
certbot 5.10.0The configuration puts Pebble's API on 8450 and validates HTTP-01 on port 8451 instead of 80, so nothing needs root. Like Let's Encrypt, it has two profiles: 90 days and 160 hours. pebble-challtestsrv is a test DNS server on 8453 that answers every name with 127.0.0.1 and takes TXT records through an API on 8454.
{
"pebble": {
"listenAddress": "127.0.0.1:8450",
"managementListenAddress": "127.0.0.1:8455",
"certificate": "pebble/cert.pem",
"privateKey": "pebble/key.pem",
"httpPort": 8451,
"tlsPort": 8452,
"ocspResponderURL": "",
"externalAccountBindingRequired": false,
"retryAfter": {"authz": 1, "order": 1},
"keyAlgorithm": "ecdsa",
"profiles": {
"default": {"description": "90-day certificates", "validityPeriod": 7776000},
"shortlived": {"description": "160-hour certificates", "validityPeriod": 576000}
}
}
}bin/pebble-challtestsrv -dnsserver 127.0.0.1:8453 -management 127.0.0.1:8454 \
-http01 "" -https01 "" -tlsalpn01 "" -doh "" -defaultIPv6 "" > dns.log 2>&1 &
DNS_PID=$!
PEBBLE_VA_NOSLEEP=1 PEBBLE_WFE_NONCEREJECT=0 PEBBLE_AUTHZREUSE=0 \
bin/pebble -config pebble/config.json -dnsserver 127.0.0.1:8453 > pebble.log 2>&1 &
PEBBLE_PID=$!
sleep 2
curl -s --cacert pebble/pebble.minica.pem https://127.0.0.1:8450/dir \
| python -c "import json, sys; d = json.load(sys.stdin); print(sorted(d))"['keyChange', 'meta', 'newAccount', 'newNonce', 'newOrder', 'renewalInfo', 'revokeCert']03. Step 2: Issue with HTTP-01, then a wildcard with DNS-01
REQUESTS_CA_BUNDLE makes certbot trust Pebble's test API certificate, and CB holds the options every certbot command needs here. --standalone makes certbot run its own small web server for the HTTP-01 token. Ask for a profile explicitly: Pebble picks a random one otherwise, to catch clients that assume a lifetime.
export REQUESTS_CA_BUNDLE=$PWD/pebble/pebble.minica.pem
CB="--server https://127.0.0.1:8450/dir --config-dir acme/config
--work-dir acme/work --logs-dir acme/logs
--non-interactive --agree-tos --register-unsafely-without-email"
certbot certonly $CB --standalone --http-01-address 127.0.0.1 --http-01-port 8451 \
--preferred-profile default -d shop.lab.test 2>&1 \
| grep -E '^(Requesting|Successfully)'
grep -oE '(HEAD|POST) request to https://127.0.0.1:8450/[a-zA-Z-]+' \
acme/logs/letsencrypt.log | uniqRequesting a certificate for shop.lab.test
Successfully received certificate.
HEAD request to https://127.0.0.1:8450/nonce-plz
POST request to https://127.0.0.1:8450/sign-me-up
POST request to https://127.0.0.1:8450/order-plz
POST request to https://127.0.0.1:8450/authZ
POST request to https://127.0.0.1:8450/chalZ
POST request to https://127.0.0.1:8450/authZ
POST request to https://127.0.0.1:8450/finalize-order
POST request to https://127.0.0.1:8450/my-order
POST request to https://127.0.0.1:8450/certZThe log shows the five stages: a nonce (a one-time value against replays), the account (sign-me-up), the order, the authorisation and its challenge, polling until it is valid, finalize with the CSR, and the certificate. Now try a wildcard.
#!/bin/sh
# certbot runs this with CERTBOT_DOMAIN and CERTBOT_VALIDATION set. It publishes
# the TXT record through the lab DNS server's API (in real life: your DNS provider).
name="_acme-challenge.$CERTBOT_DOMAIN."
record="{\"host\":\"$name\",\"value\":\"$CERTBOT_VALIDATION\"}"
curl -s -d "$record" http://127.0.0.1:8454/set-txtcertbot certonly $CB --standalone --http-01-address 127.0.0.1 --http-01-port 8451 \
-d "*.lab.test" 2>&1 | grep -om1 'does not support any combination of challenges'
chmod +x dns-hook.sh
certbot certonly $CB --manual --preferred-challenges dns \
--manual-auth-hook ./dns-hook.sh --preferred-profile shortlived \
-d "*.lab.test" 2>&1 | grep -E '^(Requesting|Successfully)'does not support any combination of challenges
Requesting a certificate for *.lab.test
Successfully received certificate."""Print names, subject and lifetime of certificates (validity counts both ends)."""
import sys
from cryptography import x509
for path in sys.argv[1:]:
cert = x509.load_pem_x509_certificate(open(path, "rb").read())
san = cert.extensions.get_extension_for_class(x509.SubjectAlternativeName).value
seconds = (cert.not_valid_after_utc - cert.not_valid_before_utc).total_seconds() + 1
print(f"{', '.join(san.get_values_for_type(x509.DNSName))}: "
f"{seconds / 86400:g} days = {seconds / 3600:g} hours, "
f"subject '{cert.subject.rfc4514_string()}'")python lifetime.py acme/config/live/shop.lab.test/cert.pem \
acme/config/live/lab.test/cert.pemshop.lab.test: 90 days = 2160 hours, subject ''
*.lab.test: 6.66667 days = 160 hours, subject ''Certbot refused the first wildcard itself: Pebble offered no challenge its standalone mode can answer. The DNS-01 order with the shortlived profile worked. Both subjects are empty: public CAs put names only in the SAN. Lifetimes count both ends, which is why the Baseline Requirements advise CAs not to issue for the exact maximum.
04. Step 3: Renewal, ARI and revocation through ACME
Run certbot renew twice a day from a timer. Since certbot 4.0 that means less than a third of the lifetime left (half, for certificates valid for less than 10 days), and since 4.1 certbot also asks the CA's ARI endpoint, as acme/logs/letsencrypt.log shows. ari.py builds the ARI request by hand: base64url of the AKI key identifier, a dot, base64url of the serial number.
"""Ask an ACME server when it wants a certificate renewed (RFC 9773, ARI)."""
import base64
import json
import ssl
import sys
from urllib.request import urlopen
from cryptography import x509
DIRECTORY = "https://127.0.0.1:8450/dir"
tls = ssl.create_default_context(cafile="pebble/pebble.minica.pem")
def b64url(data: bytes) -> str:
return base64.urlsafe_b64encode(data).rstrip(b"=").decode()
cert = x509.load_pem_x509_certificate(open(sys.argv[1], "rb").read())
aki = cert.extensions.get_extension_for_class(x509.AuthorityKeyIdentifier)
serial = cert.serial_number.to_bytes((cert.serial_number.bit_length() + 8) // 8, "big")
cert_id = f"{b64url(aki.value.key_identifier)}.{b64url(serial)}"
base = json.load(urlopen(DIRECTORY, context=tls))["renewalInfo"]
with urlopen(f"{base}/{cert_id}", context=tls) as reply:
window = json.load(reply)["suggestedWindow"]
print("certificate expires :", cert.not_valid_after_utc.isoformat())
print("renew after :", window["start"])
print("renew before :", window["end"])
print("ask again after :", reply.headers.get("Retry-After"), "seconds")certbot renew $CB 2>&1 | grep -E 'not yet due|No renewals'
python ari.py acme/config/live/lab.test/cert.pemCertificate not yet due for renewal
Certificate not yet due for renewal
No renewals were attempted.
certificate expires : 2026-11-22T11:08:36+00:00
renew after : 2026-11-19T05:48:36Z
renew before : 2026-11-21T05:48:36Z
ask again after : 21600 secondsFor the 160-hour certificate the suggested window is centred about two thirds of the way through its lifetime. Now revoke the 90-day certificate as if its key had leaked and ask ARI again.
certbot revoke $CB --cert-name shop.lab.test --reason keycompromise \
--no-delete-after-revoke 2>&1 | grep -o 'successfully revoked'
python ari.py acme/config/live/shop.lab.test/cert.pemsuccessfully revoked
certificate expires : 2027-02-13T19:08:29+00:00
renew after : 2026-11-15T18:08:42.202Z
renew before : 2026-11-15T18:08:43.202Z
ask again after : 21600 secondsThe window for the revoked certificate is already in the past, which tells an ARI client to renew at once. That lets a CA replace certificates fast. Stop Pebble.
kill $PEBBLE_PID $DNS_PID05. Step 4: Revocation endpoints that stay available
A CRL is a signed file, so it can be served by any plain web server, cache or CDN: an attacker who changes it breaks the signature. Serve it over http://, not https://, so that checking one certificate does not depend on validating another (RFC 5280 requires a DER-encoded CRL behind an http distribution point). The design rules:
- publish from the CA to two or more static origins behind a CDN, never only from the CA host;
- re-sign the issuing CA's CRL often (daily here) with a validity (7 days) long enough to survive an outage;
- sign the offline root's CRL for months (180 days here) and diarise the ceremony that renews it;
- monitor each CRL's signature and time left, and alert well before
nextUpdate.
An OCSP responder is the alternative, but it is a live service with an online signing key; for a private PKI, published CRLs are usually simpler to keep available. Publish the lab CRLs to public/ and serve them on the URL that lesson 4 put in the certificates. Keep the acme-lab environment active; check_crl.py needs its cryptography.
#!/bin/sh
# Re-sign the issuing CA's CRL and publish both CRLs as DER files, the format that
# RFC 5280 requires behind an http:// distribution point. Run it from cron or a timer.
set -e
cd "$(dirname "$0")"
openssl ca -config issuing/issuing.cnf -gencrl -out issuing/crl/issuing.crl 2>/dev/null
mkdir -p public
openssl crl -in issuing/crl/issuing.crl -outform DER -out public/issuing.crl
openssl crl -in root-offline/crl/root.crl -outform DER -out public/root.crl
echo "published: $(ls public | paste -sd ' ')""""Fetch the CRL a certificate points to, check it, and warn before it goes stale.
Usage: python check_crl.py CERT ISSUER_CERT
"""
import sys
from datetime import datetime, timezone
from urllib.request import urlopen
from cryptography import x509
cert = x509.load_pem_x509_certificate(open(sys.argv[1], "rb").read())
issuer = x509.load_pem_x509_certificate(open(sys.argv[2], "rb").read())
cdp = cert.extensions.get_extension_for_class(x509.CRLDistributionPoints).value
url = cdp[0].full_name[0].value
crl = x509.load_der_x509_crl(urlopen(url, timeout=5).read())
signed = crl.is_signature_valid(issuer.public_key())
window = crl.next_update_utc - crl.last_update_utc
left = crl.next_update_utc - datetime.now(timezone.utc)
# Re-publish at half-life at the latest, so a failed run leaves time to react.
state = "OK" if signed and left > window / 2 else "ALERT"
revoked = crl.get_revoked_certificate_by_serial_number(cert.serial_number)
print(f"{state:<5} {url}")
print(f" signature {'valid' if signed else 'INVALID'}, {len(crl)} entries, "
f"next update in {left.total_seconds() / 3600:.0f} h, "
f"{'this certificate is REVOKED' if revoked else 'this certificate not listed'}")cd ../pki-lab && chmod +x publish_crls.sh && ./publish_crls.sh
python -m http.server 8456 --bind 127.0.0.1 --directory public > crl-http.log 2>&1 &
CRL_HTTP_PID=$!
sleep 1
python check_crl.py certs/app-1.crt issuing/issuing.crt
python check_crl.py issuing/issuing.crt trust/root.crtpublished: issuing.crl root.crl
OK http://127.0.0.1:8456/issuing.crl
signature valid, 1 entries, next update in 168 h, this certificate not listed
OK http://127.0.0.1:8456/root.crl
signature valid, 0 entries, next update in 4320 h, this certificate not listedNow see what a missed publication does to a strict client. Sign a CRL that is valid for one second and verify a perfectly good certificate against it.
openssl ca -config issuing/issuing.cnf -gencrl -crlsec 1 -out stale.crl 2>/dev/null
sleep 2
openssl verify -crl_check -CAfile trust/root.crt -untrusted issuing/issuing.crt \
-CRLfile stale.crl certs/app-1.crtCN = app-1.lab.test
error 12 at 0 depth lookup: CRL has expired
error certs/app-1.crt: verification failedError 12: the certificate is fine, but nobody can prove it is not revoked, so a hard-fail client refuses it, and with it every other certificate from this CA.
06. Step 5: Drill an issuing-CA key compromise
Assume issuing/private/issuing.key has been copied. The thief does not need your CA software: one openssl x509 command mints a certificate in app-1's name. Start lesson 4's mTLS server and try it.
EC="-newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes"
openssl req -new $EC -keyout evil.key -subj "/CN=app-1.lab.test" -out evil.csr \
2>/dev/null
openssl x509 -req -in evil.csr -CA issuing/issuing.crt \
-CAkey issuing/private/issuing.key -days 30 -extfile rogue/client.ext \
-out evil.crt 2>/dev/null
cat evil.crt issuing/issuing.crt > evil-fullchain.pem
grep -c . issuing/index.txt
python mtls_server.py 8448 certs/svc-fullchain.pem > drill-server.log 2>&1 &
SERVER_PID=$!
sleep 1
python mtls_client.py 8448 svc.lab.test evil-fullchain.pem evil.key5
server said: hello app-1.lab.testThe server accepted the forgery, and the CA database still lists five certificates: the CA does not know the new serial exists, so revoking leaves cannot stop it. Only the root, by revoking the issuing CA, can. Hold one root ceremony that does three things: revoke Issuing CA 1, sign a new Issuing CA 2 with a new key, and publish the new root CRL.
mkdir -p issuing-2/private issuing-2/newcerts issuing-2/crl
chmod 700 issuing-2/private && touch issuing-2/index.txt
echo 3000 > issuing-2/serial && echo 01 > issuing-2/crlnumber
sed -e 's/^dir *= issuing$/dir = issuing-2/' \
-e 's/issuing\.crl/issuing-2.crl/' issuing/issuing.cnf > issuing-2/issuing.cnf
openssl req -new $EC -keyout issuing-2/private/issuing.key \
-subj "/CN=Lab Issuing CA 2" -out issuing-2/issuing.csr 2>/dev/null
export ROOT_PASS='lab-only-root-passphrase'
openssl ca -config root-offline/root.cnf -revoke issuing/issuing.crt \
-crl_reason keyCompromise -passin env:ROOT_PASS 2>/dev/null
openssl ca -config root-offline/root.cnf -extensions v_issuing -days 1825 \
-passin env:ROOT_PASS -batch -notext -in issuing-2/issuing.csr \
-out issuing-2/issuing.crt 2>/dev/null
openssl ca -config root-offline/root.cnf -gencrl -passin env:ROOT_PASS \
-out root-offline/crl/root.crl 2>/dev/null
unset ROOT_PASS
openssl ca -config issuing-2/issuing.cnf -gencrl -out issuing-2/crl/issuing-2.crl \
2>/dev/null
sed -i -e 's#issuing/issuing.cnf#issuing-2/issuing.cnf#' \
-e 's#issuing/crl/issuing.crl#issuing-2/crl/issuing-2.crl#g' \
-e 's#public/issuing.crl#public/issuing-2.crl#' publish_crls.sh
./publish_crls.sh
cut -f1,4,6 root-offline/index.txtpublished: issuing-2.crl issuing.crl root.crl
R 1000 /CN=Lab Issuing CA 1
V 1001 /CN=Lab Issuing CA 2The sed command switches publish_crls.sh to Issuing CA 2, so your own publishing stops using the stolen key. Issuing CA 1's last CRL stays in public/ until it expires.
Who notices? Check the forgery three ways: with leaf-only CRL checking, with checking of the whole chain, and against lesson 4's server, which checks only the leaf.
cat issuing/crl/issuing.crl root-offline/crl/root.crl > crls.pem
openssl verify -crl_check -CAfile trust/root.crt -untrusted issuing/issuing.crt \
-CRLfile crls.pem evil.crt
openssl verify -crl_check_all -CAfile trust/root.crt -untrusted issuing/issuing.crt \
-CRLfile crls.pem evil.crt
python mtls_client.py 8448 svc.lab.test evil-fullchain.pem evil.keyevil.crt: OK
CN = Lab Issuing CA 1
error 23 at 1 depth lookup: certificate revoked
error evil.crt: verification failed
server said: hello app-1.lab.testLeaf-only checking still says OK, and so does the server. Revoking an intermediate protects only clients that check the whole chain. Fix the server by loading the root CRL as well and setting ssl.VERIFY_CRL_CHECK_CHAIN; nginx does this when ssl_crl holds both CRLs. Then reissue every certificate under Issuing CA 2, starting with the server's.
openssl ca -config issuing-2/issuing.cnf -extensions v_server -batch -notext \
-in certs/svc.csr -out certs/svc-2.crt 2>/dev/null
cat issuing-2/crl/issuing-2.crl root-offline/crl/root.crl > crls-2.pem
openssl verify -crl_check_all -CAfile trust/root.crt -untrusted issuing-2/issuing.crt \
-CRLfile crls-2.pem -verify_hostname svc.lab.test certs/svc-2.crt
openssl x509 -in certs/svc-2.crt -noout -issuer -ext crlDistributionPointscerts/svc-2.crt: OK
issuer=CN = Lab Issuing CA 2
X509v3 CRL Distribution Points:
Full Name:
URI:http://127.0.0.1:8456/issuing-2.crlCheck the new CRL URL; stop the servers.
python check_crl.py certs/svc-2.crt issuing-2/issuing.crt
kill $SERVER_PID $CRL_HTTP_PID; cd ..OK http://127.0.0.1:8456/issuing-2.crl
signature valid, 0 entries, next update in 168 h, this certificate not listedThe trust anchor did not change, so no client needed a new trust store: that is the payoff of the offline root. The drill gives you the runbook:
- Contain: take the issuing CA offline and keep its logs and database.
- Root ceremony: revoke the issuing CA (
keyCompromise), sign a new issuing CA with a new key and name, publish the root CRL at once. - Make every relying party check the whole chain, or remove the old intermediate from every bundle and configuration that lists it.
- Reissue all certificates under the new CA with your normal automation, swap chain files, and add the new CA's CRL to
publish_crls.sh. - Review how the key was taken, and whether it belongs in an HSM.
A compromised root has no parent to revoke it, so every trust store must change. The offline design exists to prevent that.
07. Common mistakes
08. Check your understanding
09. Apply it
For the practice project, run publish_crls.sh from a timer, alert on ALERT from check_crl.py, and make your mTLS service check the whole chain. Write a one-page compromise runbook from step 5 and time a drill. For public names, set up an ACME client with a deploy hook that reloads the web server, and test it against the Let's Encrypt staging environment first.
10. Review prompt
Without looking back, list the five ACME stages and the challenge that fits a wildcard, an internal host and a server behind a port-443 load balancer. Give the SC-081 lifetime schedule. Then explain how to keep a CRL available and fresh, why the forgery passed leaf-only checks, and the five runbook steps.
References
- RFC 8555: Automatic Certificate Management Environment (ACME)
- RFC 9773: ACME Renewal Information (ARI) Extension
- RFC 8737: ACME TLS-ALPN-01 Challenge
- RFC 5280: Internet X.509 PKI Certificate and CRL Profile
- CA/Browser Forum Baseline Requirements (section 6.3.2, validity periods)
- Let's Encrypt: Certificate Lifetime Rationale and Plans
- Let's Encrypt: Challenge Types
- Pebble: a small ACME test server
- Certbot documentation: User Guide
Your progress
Reading state
Sign in to save that you finished reading this lesson.
Prove this skill
10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.