skip to content

Selectors & Key Records

The public key sits in a TXT record at <selector>._domainkey under the d= domain, with k= and p= tags, and a domain may publish many selectors. Interviewers ask how an ESP signs as your domain.

on this pageshow

questions

6

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?

level: juniorimportance: must knowfreq 58%

answer

  1. two tags from the signature header
  2. a fixed underscore label
  3. selector first, signing domain last
  4. one tag REQUIRED, the rest default

basics

~20 s

The 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 s

A 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
dns
; 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

for a junior

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.

for a middle

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.

for a senior

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.

for a principal

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.
open as a page

What does each tag in the DKIM key record "v=DKIM1; k=rsa; h=sha256; s=email; t=y:s; p=MIIB..." tell a verifier, and which are defaults?

level: middleimportance: should knowfreq 24%

basics

~20 s

v=DKIM1 is the version, k=rsa the key type, h=sha256 the only hash this key accepts, s=email the service, t=y a domain still testing and t=s no subdomain i= values; p= is the key. Only p= is required.

open as a page

Why would one domain publish several DKIM selectors at the same time, and what makes a good selector naming scheme?

level: middleimportance: should knowfreq 30%

basics

~20 s

Selectors let one d= domain hold many independent keys: one per signing system, outside service, region or algorithm, plus overlap during a change. Name them by signer and key generation, never reuse one for a new key, and leak no personal data.

open as a page

When an outside sending service asks you to publish a CNAME at a DKIM selector under your domain, what do you hand over compared with publishing its key yourself?

level: seniorimportance: should knowfreq 34%

basics

~20 s

A CNAME-delegated selector hands the key record to the service: it holds the private key and writes p=, key length, flags and rotation timing in its own zone. Publishing its public key yourself keeps the record and revocation yours.

open as a page

As the lead for example.com's mail, how do you decide which outside senders get a DKIM selector under the domain, and on what terms?

level: principalimportance: should knowfreq 14%

basics

~20 s

Give a selector only to senders whose mail must sign as the domain, prefer a dedicated subdomain as d=, choose a self-published or CNAME-delegated record per sender, require signer-generated keys of 2048-bit RSA or Ed25519, and track each selector's owner and end date.

open as a page

After a 2048-bit DKIM key is pasted into a DNS panel, signatures start failing; why does the key's length matter, and how do you check the record?

level: seniorimportance: nice to knowfreq 16%

basics

~20 s

A 2048-bit RSA key is about 392 base64 characters, more than one 255-octet TXT string holds, so it is published as several strings in one record, joined with no separator. Panels that truncate, quote or split it wrongly break p=.

open as a page