Skip to content

DKIM: signing email

Updated

DKIM (DomainKeys Identified Mail) works like a wax seal on a letter. The sending server signs each message with a private key that only it holds. The signature is added to the message as a header. A receiving server looks up the matching public key in DNS and checks the signature. If it matches, the message really passed through a server holding that key and was not altered on the way.

Where the key is published

The signature names the signing domain (d=) and a selector (s=). The public key sits in a TXT record at the selector name, under _domainkey in that domain.

s1._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A..."

Selectors let a domain use several keys at once, for example one per email service, and replace a key without a gap. The p= value is the public key. An empty p= means the key has been revoked.

Strengths and limits

  • A valid signature survives forwarding, which SPF does not
  • Changing the message after signing, for example a mailing list adding a footer, can break the signature
  • A signature proves the signing domain, which may not be the domain in the visible From line. DMARC checks that they match
  • Use keys of at least 2048 bits where your provider allows it, and rotate them from time to time

Good to know. You cannot look up a DKIM key without knowing the selector. It is shown in the DKIM-Signature header of a message you received, in the s= part.

Check a domain's DKIM key