Chapter 3 · Lesson 18 of 22
Domains and HTTPS

How TLS certificates are issued (ACME, HTTP-01, DNS-01)

A TLS certificate is issued through ACME: your client proves it controls the domain by answering a challenge (HTTP-01, DNS-01 or TLS-ALPN-01), then submits a CSR and downloads the signed certificate.

By the end you will

Describe each ACME step, pick the right challenge for your setup and recognise why wildcard certificates need DNS-01.

Time
15 min
Level
Intermediate
Check
4 questions
You need
  • A basic idea of what HTTPS and a certificate are

A TLS certificate is issued when a certificate authority (CA) is convinced that you control the domain. ACME is the protocol that automates that conversation. Your client, such as certbot or Caddy, asks for a certificate, receives a challenge to prove control of the name, completes it, and downloads the signed result. This lesson walks through each step and the three challenge types so that errors in the logs make sense.

How it works#

The overall flow follows RFC 8555 and is the same for any ACME CA, including Let’s Encrypt:

  1. Account. The client generates an account key pair and registers it with the CA. The account key signs every later request, so the CA knows who is asking.
  2. Order. The client says which names it wants a certificate for, such as example.com and www.example.com.
  3. Authorization. For each name, the CA creates an authorization that lists the challenges it will accept.
  4. Challenge. The client picks one challenge, publishes the proof, and tells the CA it is ready. The CA checks from the outside, usually from several network vantage points.
  5. Finalize. Once all names are authorized, the client sends a CSR (certificate signing request). The CSR holds the public key of a fresh key pair and the names. The matching private key stays on your server.
  6. Download. The CA signs the certificate and the client downloads it as a chain, which you then install. See Certificate chains and intermediates explained.

Certificates are short lived, so the client repeats the process on a schedule. See Renew Let’s Encrypt certificates.

HTTP-01: serve a token over port 80#

In an HTTP-01 challenge the CA gives the client a token. The client makes a file with a response derived from that token and your account key available at:

output
http://example.com/.well-known/acme-challenge/<token>

The CA fetches that URL over plain HTTP on port 80. The response must match, or validation fails. Requirements and traits:

  • Port 80 must be reachable from the internet. A firewall that only opens 443 blocks it. Open it in your firewall (for example with ufw).
  • The domain must already point at the server running the client or a proxy that forwards that path.
  • Redirects to HTTPS are generally followed, but the first request is on port 80. Keep the challenge path reachable. See Redirect HTTP to HTTPS explained.
  • It cannot validate wildcard names.

It is the default for most single server setups because it needs no DNS credentials.

DNS-01: publish a TXT record#

For DNS-01 the client creates a TXT record at the challenge name:

output
_acme-challenge.example.com.  60  IN  TXT  "<value derived from token and account key>"

The CA queries DNS for that record. Traits:

  • It is the only way to validate a wildcard name such as *.example.com. The record for a wildcard goes at _acme-challenge.example.com, the name without the asterisk.
  • It works for servers that are not reachable from the internet, because the CA only talks to DNS.
  • The client needs permission to edit your DNS, usually through an API token from your provider. Use a token limited to that zone, and keep it secret.
  • It is slower, since the new TXT record must be visible at the authoritative servers before the CA checks. A short TTL helps, and caches matter, see TTL and DNS caching explained.
  • Delegating _acme-challenge to a separate zone with a CNAME lets a limited account answer challenges without access to the main zone.

TLS-ALPN-01 in brief#

TLS-ALPN-01 validates over port 443. The CA opens a TLS connection using a special protocol identifier (acme-tls/1), and the server answers with a special self signed certificate containing the proof. It needs no port 80 and no DNS access, but the server software has to support it and must be reachable on 443. Caddy is a common client that supports it; certbot does not use it by default. It cannot validate wildcards.

Which challenge for which case#

SituationChallenge
One public server, port 80 openHTTP-01
Wildcard certificateDNS-01
Server not reachable from the internetDNS-01
Only port 443 is open, client supports itTLS-ALPN-01
Many servers behind one nameDNS-01 (one place to publish proof)

For hands on steps, see HTTPS and Let’s Encrypt and Wildcard certificates explained.

Check it worked#

After issuance, inspect what you received:

bash
sudo certbot certificates
openssl s_client -connect example.com:443 -servername example.com </dev/null 2>/dev/null | openssl x509 -noout -issuer -subject -dates

The subject and names should be yours, the issuer should be the CA, and the dates show the validity window. See Inspect a TLS certificate with openssl.

To rehearse validation without using up real issuance limits, many clients offer a staging or dry run mode. With certbot, sudo certbot renew --dry-run tests the renewal path.

Edge cases and gotchas#

  • Validation from several places: the CA may check from multiple locations, so a firewall that blocks some regions can cause intermittent failures.
  • Token path rewrites: a proxy rule or app route that catches every path can swallow /.well-known/acme-challenge/, so exclude it.
  • Rate limits: CAs limit failed validations and duplicate certificates. Use staging while testing and check the CA’s published limits rather than assuming numbers.
  • CAA records: if the domain has CAA DNS records, they must allow your CA, or issuance is refused.
  • DNS caching: an old cached _acme-challenge TXT value can break DNS-01, so clean up old records and keep the TTL low.
  • CDN or proxy in front: if a proxy answers port 80 itself, the token never reaches your server. Pass the path through or use DNS-01.

Troubleshooting#

SymptomLikely causeFix
Timeout or connection refused during HTTP-01Port 80 blocked or nothing listeningOpen port 80, stop conflicting services, retry
404 or wrong content at the challenge URLProxy or app intercepts the pathRoute /.well-known/acme-challenge/ to the client’s webroot
DNS problem: NXDOMAIN looking up the nameDomain does not point anywhere yetCreate the A record first and check with dig
Wildcard request fails with HTTP-01Wildcards need DNS-01Switch to the DNS-01 plugin for your DNS provider
Incorrect TXT record foundOld or mistyped _acme-challenge valueDelete stale TXT records and retry
CAA record forbids issuanceCAA does not list the CAAdd the CA to the CAA record set

Quick reference#

output
HTTP-01      port 80   /.well-known/acme-challenge/<token>      no wildcards
DNS-01       TXT       _acme-challenge.<name>                   wildcards ok
TLS-ALPN-01  port 443  protocol acme-tls/1                      no wildcards
bash
sudo certbot certonly --standalone -d example.com    # HTTP-01
sudo certbot certificates                            # list what you have

Next#

Continue with Certificate chains and intermediates explained.

Check what you learned4 questions
1Where must an HTTP-01 challenge response be served?
2Which challenge type is required for a wildcard certificate such as *.example.com?
3What name is the DNS-01 TXT record created at?
4What does the client send in the finalize step?

Frequently asked questions

What is ACME in Let's Encrypt?

ACME (Automatic Certificate Management Environment) is the protocol an ACME client uses to talk to a certificate authority, prove domain control and obtain certificates without manual steps. Certbot and Caddy are ACME clients.

What is the difference between HTTP-01 and DNS-01?

HTTP-01 proves control by serving a token file on port 80 of the domain. DNS-01 proves it by publishing a TXT record at _acme-challenge. Only DNS-01 can validate wildcard names, and it works for servers not reachable from the internet.

Does Let's Encrypt need port 80 open?

Only for HTTP-01. If you use DNS-01 or TLS-ALPN-01 you can validate without port 80, though most setups keep port 80 open anyway for the HTTP to HTTPS redirect.

Does the CA ever see my private key?

No. Your client generates the key on your own machine and sends only a certificate signing request with the public key.

Sources

View MD Edit
Share
Helpful?
Progress is saved in this browser only.

Keep going: guides and tutorials

View MD Edit
Share
Helpful?
Run this on your own server

Levelrail deploys apps from git with health-checked releases and one-click rollback.

docker pull ghcr.io/glincker/levelrail:latest Install Levelrail From GLINR Studios