# How proof and certificates work

What the platform checks to verify a domain, how it gets and renews the certificate, and where the certificate's key is kept.

## Proof

A domain is verified by DNS only, never by a request to a web address: many endpoints share
addresses, so a request reaching one says nothing about who owns the name.

| Where the domain is                                      | What proves it                                                                                                                       |
| -------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| In one of your hosted zones, delegation verified         | The zone itself. Nothing to create.                                                                                                  |
| In one of your hosted zones, delegation not yet verified | Nothing yet; the domain is verified once the delegation is (or once the `CNAME` below is in place at the DNS that answers today).    |
| Anywhere else                                            | `_acme-challenge.<domain>` is a `CNAME` to the domain's own target, as public resolvers (`1.1.1.1`, `9.9.9.9`, `8.8.8.8`) answer it. |

Each domain gets a random target under the platform's own DNS, never reused, so a record left
behind at a former owner's DNS proves nothing for anyone else.

A verified domain holds its name: when another organization's proof for the same name, a name
under it or a name above it is found, that domain stays **Waiting for proof** with the finding
"The proof is in place, but … is held by another organization's verified domain".

## Certificate

As soon as a domain is verified, the platform orders its certificate from Let's Encrypt with the
`dns-01` challenge: the domain's name, plus `*.<domain>` when the domain covers every name one
level under it. The answer to the challenge is published in the platform's own DNS, in your hosted
zone or at the target your `CNAME` points to, so a wildcard can be issued without your DNS provider
doing anything else.

- Issuing takes about a minute: the platform waits about 35 seconds for its nameservers to serve
  the answer before Let's Encrypt looks.
- The certificate is renewed 30 days before it expires. A renewal that fails keeps the current
  certificate in service and shows the error; it is retried after 15 minutes, then on every check.
- The private key is generated by the platform, stored encrypted under the platform's master key,
  and sent only to the platform machines that serve a name of the domain.

## Checks

One check runs every five minutes: domains waiting for proof (every five minutes for 72 hours,
then once a day), and verified domains whose certificate is missing, failed or due for renewal.
**Verify now** runs it at once for one domain.
