Sub topic 4
Proving domain control: HTTP-01, DNS-01 and TLS-ALPN-01
Before Let's Encrypt signs a certificate, it must be sure the requester controls the domain. This chapter explains the three challenge types the ACME protocol defines, how each one works, and how to choose between them. It assumes you know basic DNS records (A, AAAA, CNAME, TXT), HTTP, and how to use a Linux shell with sudo. You do not need to have run Certbot yet.
What a challenge proves
Let's Encrypt performs domain validation (DV). It does not check who you are or whether your business is real. It checks one thing: whether you can control something that only the domain's owner should be able to control.
Each challenge works the same way at a high level:
- Your ACME client asks the server (the CA) for a certificate covering a name.
- The CA replies with a random token for that name.
- The client combines the token with a fingerprint of its account key. This combined string is the key authorization.
- The client publishes the key authorization in a place the CA can check: a web path, a DNS record, or a TLS handshake.
- The client tells the CA it is ready. The CA checks from the outside, and marks the name valid or invalid.
The account key is part of the proof. A third party who sees the token cannot answer the challenge, because they do not hold your account key.
Let's Encrypt validates from several network vantage points, a practice called multi-perspective validation. It protects against an attacker who hijacks routing for one network path only. If your server blocks some countries or networks by IP, validation can fail from one vantage point even though it works from your own laptop.
HTTP-01
HTTP-01 is the default and the simplest. The CA requests a file over plain HTTP:
http://example.com/.well-known/acme-challenge/<token>The response body must be the key authorization. Certbot either writes this file into a webroot, or its nginx plugin answers the request itself.
Properties and constraints:
- It must use port 80. The CA does not accept other ports for this challenge.
- It can follow redirects, including a redirect from HTTP to HTTPS. It may follow redirects to port 443 or 80 only.
- It proves control of one hostname. It cannot issue wildcard certificates.
- The name must resolve publicly to a server that you control. An internal-only server cannot use it.
- IPv6 matters. If your domain has an AAAA record, the CA prefers it. A broken IPv6 listener is a common cause of failures that look unexplained.
A typical webroot-style check from your own machine looks like this:
curl -i http://example.com/.well-known/acme-challenge/test-fileA 404 for a missing file is fine and shows the path is reachable. A timeout, a connection refused error, or an HTML login page means the CA will probably fail too.
DNS-01
With DNS-01 you publish a TXT record at _acme-challenge.<name>:
_acme-challenge.example.com. 300 IN TXT "<base64url SHA-256 of key authorization>"The CA queries the authoritative name servers for that record. Properties:
- It works for wildcard names such as
*.example.com. DNS-01 is the only challenge type that can issue wildcards. - It needs no inbound web port. This suits servers behind a firewall, internal services, and hosts that are not reachable from the internet.
- One machine can request certificates for many servers, because the proof lives in DNS, not on the web server.
- Automation requires API access to your DNS provider. Certbot has plugins for many providers, and the credentials they hold can change your zone, so store them with strict permissions.
- Propagation delay is the main failure mode. The CA must see the record on every authoritative server. Plugins usually wait before asking for validation, and you can lengthen that wait if your provider is slow.
A name's TXT record is not removed by the CA. Clients delete it after validation. Stale _acme-challenge records are harmless but untidy. Multiple TXT values at the same name are allowed, which matters when you request both example.com and *.example.com. Both validate at _acme-challenge.example.com, so two values must exist at once.
Delegating with a CNAME
You can avoid giving a server full control of your main zone. Create a CNAME from _acme-challenge.example.com to a name in a zone the server may edit:
_acme-challenge.example.com. IN CNAME _acme-challenge.acme.example.net.The CA follows the CNAME and reads the TXT record at the target. The client then needs credentials only for example.net. This limits the damage if those credentials leak.
TLS-ALPN-01
TLS-ALPN-01 validates over port 443. The CA opens a TLS connection using SNI for the name and the ALPN protocol identifier acme-tls/1. The server must answer with a special self-signed certificate that contains the key authorization in a critical extension.
Properties:
- It needs only port 443, which helps when port 80 is blocked.
- It cannot be answered by a normal web server configuration. The TLS terminator itself must implement the challenge, because it must present a different certificate for that one ALPN value.
- It does not support wildcards.
- Certbot does not implement it for nginx. Servers and tools that can do it include Caddy, Traefik, and some other ACME clients. It is seldom the right choice for a classic nginx and Certbot setup.
Mention it in your design notes so you recognize it, but expect to use HTTP-01 or DNS-01 on nginx.
Comparing the three
| Property | HTTP-01 | DNS-01 | TLS-ALPN-01 |
|---|---|---|---|
| Port or record | TCP 80 | TXT record in DNS | TCP 443 |
| Wildcards | No | Yes | No |
| Server must be reachable from internet | Yes | No | Yes |
| Needs DNS API credentials | No | Yes, for automation | No |
| Works with Certbot and nginx | Yes | Yes, with a plugin or manual mode | No |
| Typical failure | Firewall or wrong server answers | Slow DNS propagation | Server does not support ALPN challenge |
Choosing a challenge
Use this order of reasoning:
- Do you need a wildcard certificate? Use DNS-01. No other type works.
- Is the server reachable on port 80 from the internet, and do you control the web server? Use HTTP-01. It is simplest and needs no secrets.
- Is port 80 blocked, but 443 open, and does your TLS terminator support it? Consider TLS-ALPN-01.
- Is the host internal or unreachable? Use DNS-01.
- Does one central host manage certificates for many machines? DNS-01 fits, ideally with a CNAME delegation and a narrowly scoped API token.
In Certbot you pick the type with options. The nginx plugin uses HTTP-01. For DNS-01 you ask for it explicitly:
sudo certbot certonly --manual --preferred-challenges dns \
-d example.com -d '*.example.com'Manual mode prints the TXT value and waits. It cannot renew unattended, so production setups use a DNS provider plugin instead.
Common edge cases
- A CDN or proxy in front. If a proxy terminates traffic, HTTP-01 may reach the proxy instead of your server. Pass
/.well-known/acme-challenge/through to the origin, or switch to DNS-01. - A forced redirect. HTTP-01 follows redirects, so redirecting port 80 to HTTPS is usually fine. A redirect to a different host that has no valid response breaks validation.
- Several servers behind one name. HTTP-01 hits whichever server answers. If you run a load balancer, make sure every backend serves the challenge file, or route the path to one place.
- CAA records. A CAA record that does not list
letsencrypt.orgstops issuance. The CA checks CAA before signing. - Authoritative servers out of sync. For DNS-01, a record visible on one name server but not another causes intermittent failure.
- Authorizations are reused. A recently validated name may not be validated again right away. This is a CA-side convenience, not something to rely on.
Exercise
You manage example.com and need one certificate for example.com and *.example.com on a server that sits behind a firewall with only port 443 open. Which challenge do you use, and why can the other two not work?
Show answer
Use DNS-01. Wildcards are only available through DNS-01, so HTTP-01 and TLS-ALPN-01 are ruled out for the wildcard name. HTTP-01 also needs port 80, which is closed. TLS-ALPN-01 does not support wildcards and Certbot cannot answer it on nginx.
Exercise
You request both example.com and *.example.com using DNS-01. How many TXT values must exist at _acme-challenge.example.com, and what is a safe way to keep a server from holding full control of your zone?
Show answer
Two TXT values must exist at the same time, because both names validate at the same record name. To limit access, create a CNAME from _acme-challenge.example.com to a name in a separate zone, and give the server API credentials only for that zone.