DKIM Implementation and Key Management
You'll learn how to operationalize DKIM signing by generating keys, configuring selectors, publishing DNS records, and establishing a key rotation strategy.
Core Concept
While DKIM cryptographic signing validates that email hasn't been tampered with (covered previously), implementing DKIM requires careful key management. Think of it like managing building access cards: you need to create unique cards (keys), tell the security system where to validate them (DNS records), use different card batches for different departments (selectors), and periodically replace cards for security (rotation).
Setting Up DKIM Selectors
Selectors are subdomain labels that allow multiple DKIM keys for one domain. For example, default._domainkey.example.com or marketing._domainkey.example.com. This lets you:
- Segment signing keys by mail server or department
- Rotate keys without breaking existing signatures
- Test new keys before switching production traffic
Key Pair Generation
You generate an RSA or Ed25519 key pair: a private key (kept secret on your mail server) and a public key (published in DNS). Common key sizes are 1024-bit (minimum) or 2048-bit (recommended). The private key signs outgoing emails; recipients fetch the public key from DNS to verify.
Publishing DNS Records
The public key goes in a TXT record at selector._domainkey.yourdomain.com:
default._domainkey IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSq..."
This tells receiving servers where to find your verification key.
Key Rotation Strategy
Rotate keys every 6-12 months to limit exposure if compromised. Keep the old public key in DNS temporarily while signatures with the old key expire (typically 30 days), then remove it.
Key Takeaway: DKIM implementation requires generating cryptographic key pairs, using selectors for organizational flexibility, publishing public keys in DNS TXT records, and rotating keys regularly to maintain security hygiene.