The short answer

To validate www.example.com, the ACME client publishes a TXT record at _acme-challenge.www.example.com holding a value derived from the CA's token and the client's account key. The CA then looks that record up itself, from several network locations, through resolvers that ask your authoritative nameservers. Validation fails if the record is not yet on every authoritative server, is at the wrong name or in the wrong zone, holds the wrong value, is hidden by a broken CNAME or broken DNSSEC, or if a CAA record does not allow the CA. Check each of those with dig against your own nameservers before asking the CA to try again, and allow time for the CA's resolvers to drop any answer they cached during the failed attempt.

How the challenge works

  1. The client asks the CA for a certificate and picks the dns-01 challenge for each name.
  2. It computes the TXT value: the base64url-encoded SHA-256 digest of the token joined to its account key thumbprint (RFC 8555, section 8.4). The value is always 43 characters.
  3. It creates the TXT record, usually through the DNS provider's API.
  4. It waits for the record to reach the authoritative servers, then tells the CA it is ready.
  5. The CA queries _acme-challenge.<name> from multiple vantage points. If any TXT value at that name matches, the name is validated.
  6. The client removes the record.
Certificate nameTXT record name
example.com_acme-challenge.example.com
www.example.com_acme-challenge.www.example.com
*.example.com_acme-challenge.example.com, the same name as the apex

A certificate for both example.com and *.example.com therefore needs two different TXT values at the same name at the same time. Clients handle this, but a provider integration that replaces the record instead of adding a second value will make one of the two fail.

Checking the record yourself

CommandWhat you want to see
dig +short NS example.comThe nameservers the CA will end up asking
dig +norecurse +short TXT _acme-challenge.example.com @ns1.example.comThe expected value, on every nameserver in turn
dig +short CNAME _acme-challenge.example.comEmpty, or the validation name you delegated to (see below)
dig CAA example.comNo CAA records, or ones that allow your CA
dig +dnssec TXT _acme-challenge.example.com @1.1.1.1Status NOERROR. SERVFAIL here usually means broken DNSSEC.
Resolve-DnsName _acme-challenge.example.com -Type TXT -Server ns1.example.comThe TXT check from Windows PowerShell

Common failures

Error or symptomLikely causeFix
"No TXT record found" or NXDOMAINThe record was checked before it reached every nameserver, or was created in the wrong zone (for example a stale zone at an old provider, or a doubled name like _acme-challenge.example.com.example.com)Check each authoritative server; raise the client's propagation wait; confirm the zone is the one the domain is delegated to
"Incorrect TXT record"An old value from a previous attempt, a record for another name, or quotes added around the value in a provider form that adds its ownCompare the value with the client's log; remove stale values
Works for example.com, fails for *.example.com (or the reverse)The second value replaced the first at the shared nameUse a client or plugin that adds values rather than replacing them
SERVFAIL looking up TXTBroken DNSSEC (an old DS record, expired signatures) or a nameserver that fails for the nameSee debugging DNSSEC validation errors
CAA errorA CAA record that does not list the CA, or no issuewild permission for a wildcardAdd the CA's identifier; see CAA records
First issue works, renewal failsA manual DNS-01 setup with no hook, an API key that expired or lost permission, or a provider changeAutomate the record with the provider's API and test renewal ahead of time
Rate limitedToo many failed attempts in a short timeFix the cause and test against the CA's staging environment first

Delegating _acme-challenge

Giving every web server an API key that can edit your whole zone is a large risk: a stolen key can change MX, NS or any other record. CAs follow CNAMEs during validation, so you can point the challenge name at a small zone used only for validation:

_acme-challenge.example.com.      3600 IN CNAME  example-com.acme.example.net.
_acme-challenge.www.example.com.  3600 IN CNAME  www-example-com.acme.example.net.

The ACME client then needs write access only to acme.example.net, which can live at a different provider or in a dedicated acme-dns server. The CNAMEs are created once by hand and never change. Other ways to limit the blast radius:

  • Scoped API tokens: most providers can limit a token to one zone; some, such as Route 53 with IAM conditions on record names, can limit it to the _acme-challenge names.
  • A delegated subdomain for the challenge names, with its own provider and credentials. See delegation.
  • RFC 2136 dynamic updates with a TSIG key that the server only accepts for TXT records at the challenge names.

CAA and DNS-01

CAA records say which CAs may issue for a domain. RFC 8657 adds two useful parameters for ACME:

example.com.  3600 IN CAA 0 issue "letsencrypt.org; validationmethods=dns-01"
example.com.  3600 IN CAA 0 issuewild "letsencrypt.org; validationmethods=dns-01"

validationmethods limits issuance to the methods you list, and accounturi can limit it to your own ACME account. Without an issuewild record, the issue records also govern wildcards. Check that the CA you use supports these parameters before relying on them.

Renewal and stale tokens

  • Certificate lifetimes are getting shorter across the industry, so renewal runs more often. Treat DNS-01 as an automated job with alerting, not a yearly task.
  • Clients normally delete the TXT record after validation. Records left behind do no harm to validation, because the CA accepts any matching value, but they clutter the zone and can trip a TXT size limit. Clean up old values, and exclude _acme-challenge names from drift checks.
  • Run a renewal test against the staging environment (for example certbot renew --dry-run) after any DNS provider change.

How DNS Panopticon helps

Security Posture reads a domain's CAA records in its TLS and Certificates card, which catches the most common policy mistake. The DNS Propagation Checker can look up a TXT record such as _acme-challenge.example.com on the authoritative servers and public resolvers at once, which shows whether the record has reached every server. DNS Panopticon does not run ACME clients or issue certificates.

FAQ

Do I need DNS-01 for a wildcard certificate?

With Let's Encrypt and most public CAs, yes. Wildcard names can only be validated with the DNS-01 challenge.

How long should the client wait before asking the CA to validate?

Until every authoritative nameserver serves the record. With most managed providers that is seconds to a minute or two; with slow secondaries it can be longer. Some clients check the nameservers themselves before continuing. For a retry after a failure, also wait for answers the CA has already cached to expire (see the TTL question below).

Does the TXT record's TTL matter?

Yes, for retries. The CA looks the record up through its own recursive resolvers, which cache answers. Set a short TTL such as 60 seconds before the first attempt. A failed attempt can leave an old value cached for its full TTL, or a negative answer (no such record) cached for the negative TTL set in the SOA record (RFC 2308). Changing the TTL afterwards does not shorten either, so wait for them to expire before retrying, or you risk repeated failures and rate limits.

Is it safe to leave old _acme-challenge records?

They do not weaken anything, because each value only works for one validation, but they clutter the zone. Let the client remove them, and clean up any that remain.

Sources and further reading