Lesson 5 of 9 · 26m
DKIM Signing, Selectors, Canonicalization, and Key Operations
Operate DKIM as a cryptographic identity system: selector design, key rotation, signing domains, canonicalization, alignment, and provider boundaries.
DKIM is the part of email authentication that most often survives the real world. It binds a domain to a message using a cryptographic signature, and it can survive forwarding better than SPF because it travels inside the message. It also fails in wonderfully boring ways: wrong selector, missing public key, whitespace in DNS, provider signing the wrong domain, or a mailing list modifying a header covered by the signature.
What DKIM actually signs
A DKIM signature is a header added before transmission. It names the signing domain, selector, signed headers, canonicalization, and signature value:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mail.sudosecurity.org; s=s202611;
h=from:to:subject:date:message-id; bh=7xQHqoS9yP0w3V...; b=Kj8sdf...The receiving server fetches the public key at:
dig +short TXT s202611._domainkey.mail.sudosecurity.orgThe DNS record looks like:
v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQE...If the body hash and selected headers verify with that key, DKIM passes for d=mail.sudosecurity.org. It does not inherently mean the visible sender is safe. It means that domain signed this message.
Alignment is the part people forget
DMARC asks whether the DKIM signing domain aligns with the header From: domain. This passes DKIM but fails alignment:
From: support@sudosecurity.org
DKIM-Signature d=sendgrid.netMany providers can sign with their own domain by default. That is operationally convenient and authentication-wise insufficient for DMARC. Configure custom DKIM signing so d= is your domain or an aligned subdomain.
Selectors are operational handles
The selector lets you publish multiple keys at once. Use dated or purpose-specific selectors rather than default forever:
s202611/m202611._domainkey.mail.sudosecurity.org transactional and marketing streams
provider1._domainkey.sudosecurity.org vendor-managed signingRotation becomes possible because old mail can still verify while new mail uses a new key. Publish the replacement key first, switch signing, then remove the old key after enough time for delayed delivery and verification. A week is usually safer than a day; mailing lists and queued retries exist.
Canonicalization is compatibility tuning
Canonicalization defines how whitespace and body mutation are normalized before verification:
simple/simple strictest, easiest to break
relaxed/relaxed tolerant of common whitespace and header reformattingUse relaxed/relaxed unless you have a specific reason not to. The cost of strictness is not theoretical: mailing lists append footers, security gateways rewrite URLs, and forwarding infrastructure sometimes reflows content. If those systems alter signed material beyond canonicalization tolerance, verification fails.
Field notes
- DKIM does not encrypt mail. It authenticates integrity and a signing domain, nothing more.
- The
h=list matters. IfFromis not signed, the signature misses the identity users care about. - A revoked or malformed DNS key produces deterministic failure even when signing code is correct.
- Beware DNS providers that silently truncate long TXT records.
- Sending the same template through two providers means two signing configurations, two rotation schedules, and two places alignment can break.
Was this lesson helpful?