Given a DKIM-Signature with d=example.com and s=s2026a, where does a receiver look up the public key, and what must that record contain?
answer
- two tags from the signature header
- a fixed underscore label
- selector first, signing domain last
- one tag REQUIRED, the rest default
basics
~20 sThe receiver queries the TXT record at s2026a._domainkey.example.com: the s= selector, the fixed _domainkey label, then the d= domain. The value is a tag list whose only required tag is p=, the base64 public key.
solid answer
~40 sA verifier builds the query name from two tags of the signature, the selector `s=` and the signing domain `d=`, joined by the fixed label `_domainkey`: `s=s2026a; d=example.com` means a TXT lookup of `s2026a._domainkey.example.com` (RFC 6376 section 3.6.2.1). The value is a `tag=value` list. `p=` is REQUIRED and holds the base64 public key; an empty `p=` means the key was revoked. `v=DKIM1` is RECOMMENDED and, when present, must be the first tag; `k=` names the key type and defaults to `rsa`, with `ed25519` added by RFC 8463 in 2018. The key sits under the `d=` domain, which is not necessarily the From address's domain, and one domain can publish as many selectors as it has keys.
code
dns · 2 lines; public key for selector s2026a, signing domain example.com
s2026a._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA...IDAQAB"go deeper
Recall the query name: selector, then _domainkey, then the d= domain. Know that p= is the one required tag and holds the base64 public key.
Explain that the name comes from the signature's s= and d= tags, that k= defaults to rsa, and that v=DKIM1, when present, must be the first tag of the record.
Show that you can check a live record against the selector a real message carries, read header.d and header.s in Authentication-Results, and spot a record published under the wrong domain.
Treat the _domainkey namespace as an inventory you govern: every selector should map to a known signer and an owner, and an unexplained one is a finding to chase.
## Where the key lives **DKIM** (DomainKeys Identified Mail, RFC 6376, September 2011) lets a domain sign outgoing mail with a private key and publish the matching **public key in DNS**, so that any receiver can check the signature without a certificate authority or a prior relationship. The signature travels in a `DKIM-Signature` header field; the key lives in a **key record** that the receiver fetches at verification time. Two tags of the signature tell the receiver where to look: - `d=` is the **signing domain** (the SDID), the domain that takes responsibility for the message. - `s=` is the **selector**, a name that tells apart the several keys one domain may publish. RFC 6376 defines a single key-distribution method, DNS TXT records, signalled by the signature's optional `q=dns/txt` (its default). ## Building the query name Section 3.6.2.1 fixes the construction. For a signature carrying `d=example.com` and `s=s2026a`: 1. Take the selector exactly as written: `s2026a`. 2. Append the fixed label `_domainkey`. The leading underscore keeps this name apart from ordinary host names. 3. Append the `d=` value: `example.com`. 4. Query the TXT record at the result: `s2026a._domainkey.example.com`. A selector may contain periods, and each period becomes a DNS label boundary, so `s=march2026.eu` with `d=example.com` is looked up at `march2026.eu._domainkey.example.com`. The key is always found under `d=`, never under the From header's domain unless the two happen to be the same. A message whose From address is `[email protected]` but whose signature says `d=mailer.example.net` is checked against a key under `mailer.example.net`; whether that matters for the brand is a question for DMARC's alignment check, not for the key lookup. ## What the record holds The TXT value is a **tag list** (section 3.6.1). Tags the verifier does not understand MUST be ignored, which is how the format can grow. | Tag | Status | Default | Meaning | |---|---|---|---| | `v=` | RECOMMENDED | `DKIM1` | Record version; if present it must be exactly `DKIM1` and the first tag | | `k=` | OPTIONAL | `rsa` | Key type; `ed25519` added by RFC 8463 (September 2018) | | `p=` | **REQUIRED** | none | Base64 public key; an empty value means revoked | | `h=` | OPTIONAL | all allowed | Acceptable hash algorithms, colon-separated | | `s=` | OPTIONAL | `*` | Service types the key applies to, such as `email` | | `t=` | OPTIONAL | no flags | `y` = the domain is testing DKIM; `s` = no subdomain `i=` values | | `n=` | OPTIONAL | empty | Notes for a human; no program interprets them | A minimal working record is therefore `v=DKIM1; p=...`, and many domains add `k=rsa` for clarity even though it is the default. Two traps sit in this table: - **`s=` on the key record is the service type, not the selector.** The selector is part of the DNS name and never appears inside the record. - **`h=` on the key record lists hash algorithms**, not header fields; the signed-headers list is a different `h=`, inside the signature. ## What the record does not say The key record is deliberately thin. It says that whoever controls the `d=` domain stands behind messages signed with this key, and nothing more: - It names no sending server, IP address or From address; those belong to SPF and DMARC. - It carries no expiry date; a key is valid until the record is changed or removed. - It does not tell receivers what to do with unsigned or failing mail; that policy is DMARC's. - Under RFC 6376 it cannot restrict a key to particular local parts: the old `g=` tag of DomainKeys and RFC 4871 was dropped in 2011 and must now be ignored. ## Checking it yourself An administrator confirming a new selector does three things: 1. Query the TXT record at `<selector>._domainkey.<d= domain>` and read back the joined value. 2. Confirm the record starts with `v=DKIM1` if it carries a version, that `k=` matches the key type the signer uses, and that `p=` is complete. 3. Send an ordinary test message to a mailbox you control and read the receiver's `Authentication-Results` field: `dkim=pass` with `header.d=example.com` and `header.s=s2026a` (the selector property RFC 8601 registered) shows the receiver found and used exactly this record. If no record exists at the name, RFC 6376 treats the signature as a permanent failure; if the query cannot be answered, the receiver may defer and try again later. How a receiver turns those cases into results belongs with signature verification; for the domain owner, the lesson is that the record must exist at exactly the name the signer puts in `s=` and `d=`.
- Why is the key looked up under d= rather than under the domain in the From header?DKIM authenticates the signing domain, the `d=` value the signer chooses: the author's domain, a subdomain of it, or an outside service's own domain. The key record only says that whoever controls `d=` vouches for messages signed with this key. Whether `d=` matches the From domain is a separate test, DMARC's alignment check, made after the signature has been verified.
- What happens if the key record does not exist, or the DNS query times out?RFC 6376 separates the two. A key record that does not exist is a permanent failure (PERMFAIL, no key for signature). A query that gets no answer may be retried later (TEMPFAIL, key unavailable), and `Authentication-Results` records that case as `temperror`. A typo in the selector or a record published under the wrong domain therefore fails every message, not just some.
- The key is published under the From header's domain, whatever d= says.
- The selector is a secret that stops outsiders from verifying signatures.
- A domain can publish only one DKIM key at a time.
- v=DKIM1 is mandatory and the record is invalid without it.
- On the key record, s= repeats the selector name.