# Let's Encrypt by DNS

**Through DNS** (dns-01) proves a name with a TXT record at `_acme-challenge.NAME`. Nothing is asked of your ports: it works for a server the internet cannot reach, behind any proxy, in any cluster, and it is the only way for a wildcard.

The record must be visible on **the name's own DNS servers** before the authority looks. CrushMFT reads them directly (not a cache), and goes on as soon as every one of them has it; the run's step shows which have it so far.

## The ways

Under **Through DNS**, **The record**:

| Way | Renews by itself | How |
|---|---|---|
| I add the record myself | no | the run shows the record (Copy); add it at your DNS provider, and the run goes on once it shows (30 minutes at most) |
| My DNS provider, through its API | yes | CrushMFT sets the record and removes it afterwards |
| A job of mine sets and removes the record | yes | a job you wrote, for any provider with an API or a command line |
| A record set once that stays (dns-persist-01) | yes | where the authority offers it: one record, shown the first time, then only checked |

## Providers

| Provider | What CrushMFT needs |
|---|---|
| Cloudflare | an API token with Zone, DNS, Edit for the zone |
| Amazon Route 53 | an access key id and secret allowed `route53:ChangeResourceRecordSets` and `route53:ListHostedZonesByName`; the hosted zone id is found from the name |
| Azure DNS | tenant id, client (application) id and secret of an app registration with the DNS Zone Contributor role, the subscription id and the zone's resource group |
| Google Cloud DNS | the key file (JSON) of a service account with the DNS Administrator role |
| Another DNS server (RFC 2136) | the primary server, a TSIG key name and its HMAC-SHA256 secret: BIND, Knot, PowerDNS, Windows DNS with TSIG |

The zone is found from the name; type it only when the name is delegated in an unusual way. Secrets are kept sealed and never shown again.

## A job

A job gets `dns_record_name`, `dns_record_value`, `dns_challenge_domain`, `acme_action` (add or remove) and `acme_domains`. Name the job that sets the record and, optionally, the one that removes it. A job that fails stops the run with what it said.

## dns-persist-01

The record `_validation-persist.NAME` with the authority's name and your account's address, set once. It is shown at the first order; later orders only check that it is still there. If it was removed, the renewal says so with the record to set again.

## Wildcards

`*.example.com` covers every name one level below `example.com` (not `example.com` itself, not `a.b.example.com`). Order both `example.com` and `*.example.com` together when you need both: two records with the same name `_acme-challenge.example.com`, which DNS allows.

## CNAME delegation

When your main zone cannot be changed by a program, point `_acme-challenge.files.example.com` (a CNAME) at a name in a zone that can, such as `files.acme.example.net`. CrushMFT follows the CNAME and sets and checks the record there.

## Renewing by itself

A certificate proven by a record added by hand cannot renew by itself: its renewal stops at the first step and says to choose a provider, a job or dns-persist-01.

## The record is not found

"The authority did not find the right TXT record": the record is in another zone than the one the name's servers serve (a copy at an old provider, a split DNS), it has the wrong value, or it has not spread yet. A CNAME delegation must point at the zone that was changed.

## Do not hand over the whole zone

Give the API key the least it needs: one zone, DNS edit only. A delegated zone for `_acme-challenge` names limits it further.

## Not tried for this page

The DNS providers (Cloudflare, Route 53, Azure DNS, Google Cloud DNS, RFC 2136) against the real services, and dns-persist-01 at an authority that offers it. A record added by hand was tried against Pebble.
