The idea: prove you control the name, then ask for the certificate

A certificate authority (CA) must not give a certificate for example.com to just anyone. ACME (Automatic Certificate Management Environment, RFC 8555) is the protocol Let's Encrypt uses to check this without a human. A program on your server, the ACME client (here certbot), talks to the CA's ACME server over HTTPS. The CA gives it a random token. The client puts an answer built from that token where only the owner of the name can put it: a file on the web server, or a DNS record. The CA looks from the outside. If it finds the answer, it signs a certificate.

Time-down sequence between certbot on the left and the Let's Encrypt ACME server on the right: newAccount answered 201 Created, newOrder answered 201 with an order in status pending, fetching the authorization with its challenges and token, certbot placing the answer, POST to the challenge, the CA's validators checking example.com from four places, the order becoming ready, finalize with a CSR, and the certificate download.
Account, order, authorization, challenge, validation, finalize, download: every request is a signed POST, and the proof of control comes before any certificate.

The account key and signed requests

First the client makes an account key pair and sends newAccount. Every ACME request is a JWS: a JSON body signed with the account key. The first one carries the public key itself (jwk). The CA answers 201 Created with the account URL in Location. Later requests name that URL (kid) instead of the key.

Each request also carries a Replay-Nonce the server handed out in its previous answer (or from newNonce). A recorded request can't be sent again. Even reads are signed POSTs with an empty body, called POST-as-GET.

Orders, authorizations and challenges

newOrder lists the names (identifiers) wanted in the certificate. The CA makes an order and, for each name, an authorization. Each authorization offers challenges, which are ways to prove control: http-01, dns-01 and tls-alpn-01. One passed challenge makes the authorization valid. The chips on the right of the canvas show these statuses:

objectstatuses on the pagemoves on when
accountvalidnewAccount answered 201
orderpending → ready → processing → valid, or invalidall authorizations valid → ready; finalize → processing → valid
authorizationpending → valid, or invalidone of its challenges passes or fails
challengepending → processing → valid, or invalidthe client POSTs {} to it; the CA's check ends

HTTP-01 and DNS-01

Both challenges use the key authorization: the token, a dot, and the thumbprint of the account key (a SHA-256 hash of the public key, RFC 7638). That ties the proof to this account. Someone who copies the token can't use it with their own account.

  • HTTP-01: serve the key authorization at http://example.com/.well-known/acme-challenge/<token>, on port 80. certbot's webroot mode writes it as a file that nginx serves. Demo: HTTP-01, first certificate.
  • DNS-01: publish base64url(SHA-256(key authorization)) in a TXT record at _acme-challenge.example.com. It needs access to the DNS zone, but works without a web server, and it is the only challenge Let's Encrypt accepts for wildcard names like *.example.com. Demo: DNS-01 (TXT record).
Two panels side by side. HTTP-01: certbot writes a file named after the token with the key authorization inside; the validator sends GET on port 80 to /.well-known/acme-challenge/token and gets 200 with the key authorization. DNS-01: certbot adds a TXT record at _acme-challenge.example.com holding the SHA-256 of the key authorization; the validator asks DNS for that TXT record.
HTTP-01 puts the key authorization in a file on port 80; DNS-01 puts its hash in a TXT record.

Checking from several places

An attacker who can redirect traffic to example.com in one part of the Internet (a hijacked route, a poisoned DNS cache) could answer a challenge they don't own. So the CA checks from several network perspectives at once: a primary one and remote ones in other networks and regions. This is multi-perspective issuance corroboration, required by the CA/Browser Forum rules. The page draws one primary and three remote perspectives with the rule for 2 to 5 remote ones: the primary must see the right answer, and at most one remote may disagree.

The same rule also catches honest mistakes. In Demo: TXT not on every nameserver yet, the new record is on ns1 but ns2 has not loaded it. The two validators whose queries reach ns2 see no record. That makes two remote failures, one more than allowed, so the challenge fails.

Finalize and download

When the order is ready, the client makes a new domain key and a CSR (certificate signing request) for the names in the order, signed by that domain key. It POSTs the CSR to the order's finalize URL. The CA checks that the CSR asks only for proven names, signs the certificate (here with the intermediate R11) and sets the order to valid with a certificate URL. The client downloads the chain as application/pem-certificate-chain: the leaf, then the intermediate. The account key is never in the certificate, and no private key leaves the server. To see how a browser checks this chain, see TLS certificate chain.

Renewal at day 60 of 90

Let's Encrypt certificates last 90 days. A systemd timer or cron job runs certbot renew twice a day. certbot renews a certificate when 30 days or less are left (renew_before_expiry = 30 days), so at day 60. Renewal is just a new order: a new token, a new challenge, a new domain key. The old certificate keeps working until the new one is installed, and if renewal fails, there are still 30 days to notice. Demo: renew at day 60 of 90.

When a challenge fails

If the check fails, the challenge, its authorization and the whole order become invalid. An invalid order can't be retried. The client fixes the cause and starts a new order with a new token. The authorization carries an error object with a type from RFC 8555 and a message.

causewhat the validators seeerror type
file in the wrong webroot (Demo: failed challenge (404))HTTP 404 Not Foundurn:ietf:params:acme:error:unauthorized
TXT record not on every nameserver yetsome see no TXT recordurn:ietf:params:acme:error:unauthorized
port 80 closed by a firewalltimeouturn:ietf:params:acme:error:connection
name has no A/AAAA recordDNS lookup failsurn:ietf:params:acme:error:dns

Let's Encrypt also limits failed validations per account and name per hour, so a broken setup should be tested against its staging server first.

See also how an HTTPS connection is made, where the certificate from this page is sent in the TLS handshake, and digital signatures, which sign both the ACME requests and the certificate.

What the page leaves out

The newNonce and /directory requests, the JWS fields (protected, payload, signature, url) and the Retry-After polling loop are folded into the drawn messages. The page skips tls-alpn-01, external account binding, key rollover, account deactivation and revocation, reuse of recent valid authorizations, ACME Renewal Information (RFC 9773), which lets the CA suggest a renewal time, and CAA records, which say which CAs may issue for a name. Let's Encrypt now uses more remote perspectives than the three drawn, and is moving to shorter certificate lifetimes than 90 days. The tokens, hashes and serial numbers are shortened toy values.

On the mind map

Open the Networking mind mapNetworkingLayers & links: frames on one local networkLayers & linksIP & routing: packets hop between networksIP & routingCore services: address, name and timeCore servicesTCP, UDP & sockets: end to end between two portsTCP, UDP & socketsHTTP & TLS: what a browser does per requestHTTP & TLSAPIs & push: how apps talk to serversAPIs & pushProxies & edge: boxes in the middle of the pathProxies & edgeContainers: virtual networks from Linux partsContainersReal-time media: voice and video over UDPReal-time mediaSecurity at the edge: filter traffic at the borderSecurity at the edgeHTTP connectionHTTP connectionDNS, TCP handshake, request, keep-aliveTLS 1.3 handshakeTLS 1.3 handshakekey share and certificate in 1 round tripSSH connectionSSH connectionhost key signs H; known_hosts checks itCertificate chainCertificate chainleaf, intermediate, then a trusted rootACME / Let's EncryptProve control of the name, then send a CSRHTTP/1.1 vs 2 vs 3HTTP/1.1 vs 2 vs 3h2 multiplexes on TCP; h3 runs on QUICQUIC handshakeQUIC handshaketransport and TLS in one round tripHTTP cachingHTTP cachingmax-age to reuse, ETag to revalidateTLS 1.2 vs TLS 1.3TLS 1.2 vs TLS 1.31.3: 1 RTT, ECDHE only, encrypted certOpen the Networking mind mapNetworkingwhat a browser does per requestHTTP & TLSHTTP connectionHTTP connectionDNS, TCP handshake, request, keep-aliveTLS 1.3 handshakeTLS 1.3 handshakekey share and certificate in 1 round tripSSH connectionSSH connectionhost key signs H; known_hosts checks itCertificate chainCertificate chainleaf, intermediate, then a trusted rootACME / Let's EncryptProve control of the name, then send a CSRHTTP/1.1 vs 2 vs 3HTTP/1.1 vs 2 vs 3h2 multiplexes on TCP; h3 runs on QUICQUIC handshakeQUIC handshaketransport and TLS in one round tripHTTP cachingHTTP cachingmax-age to reuse, ETag to revalidateTLS 1.2 vs TLS 1.3TLS 1.2 vs TLS 1.31.3: 1 RTT, ECDHE only, encrypted cert
This page on the Networking mind map · 83 pages in 10 branches · open it to see the whole map and test yourself in recall mode.