EML-10Required
Sign every message with DKIM
Sign every message with DKIM, using a 2048-bit RSA key on your own domain.
How to do it
DKIM (RFC 6376) signs the headers and body, so changes on the way break the signature. Ask each sending service to sign with your domain, not theirs. Publish the public key at selector._domainkey.example.com. A 2048-bit key is longer than one 255-character DNS string, so split it into several quoted strings in one record. Replace the key on a schedule, as Rotate DKIM keys every six months says. Ed25519 keys (RFC 8463) can be added next to RSA, but not instead of it. Gmail accepts 1024 bits as a minimum, but recommends 2048. Keep the private key in a secrets store, as Keep secrets in a secrets store says.
Examples
DNS example
s2026._domainkey.example.com. 3600 IN TXT ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
"...rest of the key...IDAQAB" )
How to check
dig +short TXT s2026._domainkey.example.com returns the key, and a key-length checker reports 2048 bits. A test message shows dkim=pass with header.d=example.com, or a subdomain of it.
Sources
- RFC 6376, DomainKeys Identified Mail Signatures
- RFC 8301, DKIM Cryptographic Algorithm and Key Usage Update
Related rules
- EML-76 Rotate DKIM keys every six months in Email
- ENG-26 Keep secrets in a secrets store in Engineering
- EML-11 Enforce DMARC in Email
- STK-73 Use Amazon SES to send transactional email in Software choices
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/email/sending-domain-and-authentication/dkim">Agent Wranglers email playbook</a>. In code you write, add a comment next to it with the same link.