DKIM Key Rotation: Procedure, Cadence and Best Practices (RFC 6376 + RFC 8301)
An operational deep dive on DKIM key rotation defined by RFC 6376 and updated by RFC 8301: why rotation matters (cryptographic strength erosion, key compromise, replay attacks), when to rotate (scheduled cadence and trigger-driven events), the canonical dual-selector zero-downtime procedure that every operator should use for routine rotation, the riskier single-selector hot-swap for emergency rotations, per-provider automation for Google Workspace + Microsoft 365 + Amazon SES + Mailgun + Postmark + SendGrid, the 1024-bit deprecation and the migration path to 2048-bit RSA or Ed25519 (RFC 8463), the 255-byte TXT-record pitfall that silently corrupts large public keys at some DNS provider UIs, and an FAQ covering the operator questions search engines and LLMs are asked most often.
This reference is provided in English. DKIM is specified in English-language RFCs (RFC 6376, RFC 8301, RFC 8463) and the canonical vocabulary (selector, private key, public key, body hash, signature, RSA, Ed25519, rotation) does not translate. We keep the body in the source language so technical terms remain consistent with the specifications.
TL;DR
- DKIM key rotation is the operational practice of periodically replacing the cryptographic keypair that signs outbound mail under a domain. Specified in RFC 6376; minimum key size mandated by RFC 8301 (2048-bit RSA minimum, 1024-bit deprecated).
- The industry-baseline cadence is annual rotation for production signing keys, with shorter cadences (3-6 months) for high-value brand domains and immediate emergency rotation on suspicion of key compromise.
- The canonical zero-downtime procedure is dual-selector rotation: publish the new public key under a fresh selector, wait for DNS propagation, switch the signer to the new selector, leave the old selector live for at least 7 days plus the longest receiver cache window, then remove the old selector.
- Single-selector hot-swap is the riskier emergency procedure: replace the public-key TXT record at the current selector with the new public key, simultaneously switch the signer to the new private key, and accept a 24-48 hour window of body-hash failures on in-flight mail.
- Managed providers automate rotation: Google Workspace Auto Key Rotation (quarterly, DNS-API or manual), Microsoft 365 selector1 / selector2 alternation (quarterly, CNAME-based), Amazon SES Easy DKIM (automatic on schedule), Mailgun (per-selector), Postmark (per-server- identifier).
- The 1024-bit RSA factoring risk documented by the 2012 Zach Harris research project plus the 2018 RFC 8301 deprecation mandate make 2048-bit RSA the operational minimum; RFC 8463 Ed25519 is the recommended migration target.
- The 255-byte TXT record limit is the most common operator-facing pitfall: 2048-bit RSA public keys exceed 255 characters and MUST be published as multiple quoted strings within one TXT record. Some DNS provider UIs silently truncate, producing a corrupted published key.
- The old public-key TXT record
SHOULD be removed promptly after a key
compromise; some operators prefer publishing
a revocation record (
p=empty value) at the compromised selector. The practical effect is identical because both routes leave the attacker with no valid DKIM signature.
1. Overview: what DKIM key rotation is and why every operator needs a rotation plan
DomainKeys Identified Mail (DKIM)
authenticates email by attaching a cryptographic
signature over selected message headers and the
message body. The signing operation uses a
private key held by the sender;
the receiver fetches the matching
public key from a DNS TXT record
at {selector}._domainkey.{domain}
and verifies the signature. Because the private
key is the cryptographic anchor for every signed
message, the operational integrity of DKIM hinges
on the operator keeping the private key secret
AND retiring keys on a sensible cadence before
cryptographic advances erode their strength.
DKIM key rotation is the operational practice of periodically generating a fresh keypair, publishing the new public key in DNS, switching the mail signer to use the new private key, and retiring the old key. Rotation serves three distinct purposes that often get conflated:
- Cryptographic hygiene - replacing keys before computational advances make them factorable. The 2018 RFC 8301 deprecation of 1024-bit RSA was the most recent collective recognition that older keys had crossed the threshold; the next such recognition is anticipated when 2048-bit RSA becomes economically factorable (currently projected post-2030).
- Compromise recovery - immediately retiring a key that has been exposed, suspected of exposure, or whose signing host has been breached. This is the unscheduled emergency rotation path; every operator MUST be prepared to execute it without delay.
- Compliance and audit - many regulated industries (financial services, healthcare, government contracting) require documented key-rotation procedures with defined cadences. Annual rotation is the most common compliance baseline.
This guide walks the cadence, the canonical zero-downtime dual-selector procedure, the riskier single-selector hot-swap procedure for emergency rotations, per-provider automation flows for Google Workspace + Microsoft 365 + Amazon SES + Mailgun + Postmark, the RSA-to-Ed25519 migration path, common operator mistakes, troubleshooting of TXT-record-size and body-hash issues, and answers to the most-searched DKIM rotation questions.
2. Why rotate: the security rationale
DKIM is unusual among email-authentication standards in that it does NOT have an automatic key-rotation protocol built into its DNS layer. RFC 6376 defines selectors and the public-key TXT record schema but explicitly leaves rotation policy to the operator. The practical consequence is that a published DKIM key remains valid until the operator removes the TXT record - no expiry, no automatic refresh, no DNSSEC-level signal.
Three distinct threat models motivate rotation:
2a. Cryptographic strength erosion
The 2012 Zach Harris research project demonstrated that 1024-bit RSA DKIM signing keys were factorable with then-available cloud computing resources at sub-thousand-dollar cost. Harris factored Google's, PayPal's, Twitter's, Yahoo's, and US-Bank's then-published 1024-bit DKIM keys as a proof of concept, demonstrating that an attacker willing to spend a few hundred dollars in compute could forge DKIM signatures for any message under those domains. The disclosure triggered an industry-wide upgrade to 2048-bit RSA, formalised in RFC 8301 (January 2018) which mandates a minimum of 1024 bits but recommends 2048 bits and warns that 1024-bit keys SHOULD NOT be used.
The current generation of 2048-bit RSA DKIM keys is considered safe through approximately 2030 per NIST SP 800-131A guidance on key-strength transition. Operators publishing 2048-bit keys today have a roughly 5-7 year cryptographic runway; longer-term operators should plan to migrate to RFC 8463 Ed25519 DKIM signing once major receivers universally support it (Gmail and Microsoft 365 both verify Ed25519 signatures as of 2024).
2b. Key compromise
The DKIM private key is held by every host that signs outbound mail. Compromise paths include:
- A breach of the signing-host operating system (private key on disk).
- Accidental commit of the private key to a version-control system (the most common small-business compromise path).
- An insider with administrative access taking a copy of the key on exit.
- A misconfigured backup that ships the private key to a third-party storage service in cleartext.
- A vulnerable signing implementation that leaks key material via timing side channels.
A compromised DKIM private key lets the attacker sign arbitrary messages under the victim domain that pass DKIM at every receiver. Combined with a published DMARC policy (which most receivers treat as legitimising the message), the attacker gains a forged-but-authenticated channel that bypasses every receiver-side anti-phishing control that respects DKIM authentication.
2c. Replay attacks
A signed DKIM message remains valid until the key is rotated or revoked. An attacker who captures a legitimately-signed message body (for example a marketing newsletter sent to thousands of recipients) can re-send that same body verbatim to additional recipients - the DKIM signature remains valid because the body bytes are unchanged. This is the DKIM replay attack class that the 2023 SMTP smuggling work brought back into focus. Rotation does not prevent replay during the key's lifetime, but it bounds the replay window: an attacker has only until the key is rotated to exploit a captured signature.
3. When to rotate: scheduled vs trigger-driven rotation
Rotation events fall into two categories: planned scheduled rotations on a calendar cadence, and unplanned trigger-driven rotations in response to a specific event.
3a. Scheduled rotation triggers
- Annual cadence - the industry baseline. Most regulated industries (PCI DSS, HIPAA, SOC 2) accept annual rotation as sufficient documentation for a key-management control.
- Quarterly cadence - the baseline used by Google Workspace Auto Key Rotation, Microsoft 365 selector1 / selector2 alternation, and Amazon SES Easy DKIM. The shorter cadence is well within reach when rotation is automated by the provider.
- Bi-annual or semi-annual - the middle-ground cadence for high-value brand domains where annual feels too long but quarterly is operationally burdensome.
3b. Trigger-driven (unscheduled) rotation triggers
- Confirmed compromise - the private key has been exposed (committed to a public repository, captured by an attacker, included in a breach disclosure). Execute emergency rotation immediately; the old key MUST be removed from DNS within hours.
- Suspected compromise - signs of unauthorised access to the signing host OR unusual outbound mail volumes attributable to the signing identity. Execute emergency rotation while the forensic investigation proceeds in parallel.
- Key-size upgrade - moving from 1024-bit RSA to 2048-bit RSA (the RFC 8301 mandate), from 2048-bit RSA to 4096-bit RSA (defensive depth), or from RSA to Ed25519 (RFC 8463 future-proofing). Treat as a scheduled rotation but use dual-selector to avoid downtime.
- Personnel changes - an administrator with access to the signing key has left the organisation under unfriendly terms.
- Mail-platform migration - switching mail-sending platforms (for example from self-hosted Postfix to Amazon SES, or from Mailgun to SendGrid). The new platform will generate its own keypair; the rotation is an unavoidable consequence of the migration.
- Annual penetration-test finding - the pentest report flags long-lived DKIM keys as a finding. Rotation closes the finding.
The pre-condition for every emergency rotation is a documented rotation runbook (Section 5 - Dual-selector procedure - below). Operators who have never executed a rotation discover its pitfalls during an emergency, which is the worst possible time. Practice rotation at least once during quiet periods so the procedure is rehearsed before it is needed.
4. Recommended cadence by sender profile
There is no universal answer to "how often should I rotate DKIM keys". The right cadence depends on the sender's threat model, compliance regime, and operational capacity. The table below summarises the cadence recommendations for the most common operator profiles:
| Sender profile | Recommended cadence | Rationale |
|---|---|---|
| High-value brand (bank, payment, healthcare) | 3 months | High attacker incentive; compliance regimes (PCI DSS 3.2 + HIPAA 164.312) require documented key-management. |
| Enterprise corporate domain | 6-12 months | Standard SOC 2 + ISO 27001 cadence. Annual rotation accepted by most auditors as adequate. |
| SaaS product domain (transactional) | 3-6 months | Replay-attack risk is elevated because transactional messages are predictable in content. |
| Marketing-only subdomain | 12 months | Lower attacker incentive; replay risk less severe because marketing content is intended to be widely distributed anyway. |
| Small-business hosted on Google Workspace / Microsoft 365 | Automatic (provider-managed) | Auto Key Rotation (Workspace) or selector1 / selector2 alternation (M365) handles rotation; operator inaction is acceptable. |
| Personal domain / hobby | 12-24 months | Lowest attacker incentive; rotation primarily for cryptographic-strength hygiene. |
| Any sender suspecting compromise | Immediate | Emergency path; remove the old key from DNS within hours of suspicion. |
The cadence is independent of the key-size decision. A 2048-bit RSA key rotated quarterly and a 2048-bit RSA key rotated annually are cryptographically equivalent for the duration each is published; the difference is in the replay window and the responsiveness to a compromise. The cadence is also independent of the rotation METHOD (dual-selector vs single-selector); the canonical zero-downtime method is dual-selector regardless of cadence.
5. The canonical dual-selector rotation procedure
Dual-selector rotation is the only safe production DKIM key rotation method. It guarantees zero downtime by ensuring that at every moment of the transition AT LEAST ONE valid DKIM selector is published, so every in-flight message can be validated by the receiver.
The procedure has six discrete stages:
Stage 1: Generate the new keypair
Generate a fresh 2048-bit RSA keypair using OpenSSL or your provider's key-generation tool. The private key is stored on the signing host; the public key (in base64-encoded SubjectPublicKeyInfo DER format) goes into DNS.
# Generate the private key
openssl genrsa -out dkim-2026.key 2048
# Extract the public key in DKIM format
openssl rsa -in dkim-2026.key -pubout -outform der 2>/dev/null \
| openssl base64 -A
The base64 output is the value that goes into
the p= field of the public-key TXT
record.
Stage 2: Publish the new public key under a fresh selector
Choose a new selector name. The convention is
date-stamped (2026q2, jan2026,
20260521) or numbered (s2,
selector2). The selector name has no
cryptographic significance; it is purely a label
that lets multiple keys coexist under one domain.
; New selector TXT record published in DNS:
2026q2._domainkey.example.com. IN TXT ( "v=DKIM1; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
"..continues for ~400 bytes total.."
"..ends with the closing equals signs.." )
The 2048-bit RSA public key in base64 encoding is approximately 400 characters and must be split across multiple quoted strings (Section 11 Troubleshooting below).
Stage 3: Wait for DNS propagation
Wait 24-48 hours for DNS propagation. During this stage the OLD selector remains the active signing selector and the NEW selector is published but unused. The new selector is available for any receiver that fetches it but no production mail references it yet.
Verify the new public-key TXT record is reachable from external recursive resolvers before proceeding:
dig +short TXT 2026q2._domainkey.example.com @8.8.8.8
dig +short TXT 2026q2._domainkey.example.com @1.1.1.1
Stage 4: Switch the signer to use the new selector
Update the mail-signing daemon configuration to
sign outbound mail with the NEW private key and
reference the NEW selector in the
s= tag of the DKIM-Signature
header. The exact configuration change depends
on the signing software:
- OpenDKIM: update the KeyTable + SigningTable files to map the sending domain to the new private key file and selector. Restart opendkim.
- Rspamd DKIM module: update
the
selector+pathkeys indkim_signing.conf. Reload rspamd. - Postfix milter: same as
OpenDKIM but invoked via the milter socket
in
main.cf. - Amazon SES / Mailgun / Postmark / SendGrid: handled by the provider's management UI; switch the active selector via the provider's web console.
Stage 5: Wait for the retention window
Wait at least 7 days (14 days is safer for high-value domains) with BOTH selectors published. This is the retention window during which any in-flight or queued mail signed with the OLD private key can still be validated by the receiver using the OLD public key. Mailing lists that re-deliver legitimate mail days after the original send, retry queues at receivers bouncing temporary errors back to disk, and archival forensic-analysis tools that fetch Authentication-Results headers all benefit from the retention window.
Stage 6: Remove the old public-key TXT record
After the retention window expires, delete the
OLD selector's public-key TXT record from DNS.
The OLD private key on the signing host should
be wiped from disk at the same time (using
shred on Linux or a comparable
secure-deletion tool). Document the rotation in
your key-management log: date generated, date
published, date switched, date retired, reason
for rotation.
The cycle repeats on the next scheduled cadence with the selectors swapping back: the next rotation generates a new key, publishes it under a fresh selector (or reuses the now-empty old selector slot if the operator prefers alternating between two names indefinitely), and the procedure runs again.
6. Single-selector hot-swap: the riskier emergency procedure
Single-selector hot-swap is the rotation method that replaces the public-key TXT record AT THE SAME SELECTOR with a new public key, while simultaneously switching the signer to use the new private key. The selector name does not change; only the published key material does.
The trade-off: zero selector-management complexity, at the cost of a 24-48 hour window during which in-flight mail signed with the OLD private key may fail DKIM validation because the receiver fetches the NEW public key from DNS and the signature does not verify against it.
The procedure has three stages:
- Generate the new keypair (same as dual-selector Stage 1).
- Atomically swap the published public-key TXT record at the existing selector AND the signing configuration on the signer. The DNS update and the signer-config update should happen as close together as possible - ideally within seconds.
- Accept the 24-48 hour validation
window during which messages
signed with the OLD key but validated
against the NEW key will fail DKIM. With
a published DMARC policy of
p=quarantineorp=reject, those messages may be quarantined or rejected by the receiver.
When is single-selector justified? The narrow answer is: only for emergency rotations where the security cost of leaving the old key live for the dual-selector retention window exceeds the deliverability cost of the validation window. Confirmed compromise of the private key is the canonical case - the attacker is already using the compromised key, so leaving it published in DNS for any longer than strictly necessary is unacceptable.
For every NON-emergency rotation, prefer dual-selector. The operational overhead of managing two selectors is small; the deliverability overhead of single-selector rotation is unacceptable for routine cadence work.
7. Per-provider automation: Google Workspace, Microsoft 365, Amazon SES, Mailgun, Postmark, SendGrid
Most operators do not run a self-hosted DKIM signer. The mailbox provider or transactional email service handles signing and key management. The rotation flow depends on the provider:
7a. Google Workspace
Google Workspace offers two DKIM modes: manual (the default) and Auto Key Rotation (an explicit opt-in).
- Manual: the admin uses the
Admin Console at Apps > Google
Workspace > Gmail > Authenticate
email to generate a key, publishes the
TXT record at
google._domainkey(the default selector), and clicks Start authentication. The selector and key persist until the admin manually generates a new record. - Auto Key Rotation: Google
manages the keypair generation and rotation
on a quarterly cadence. If the DNS provider
is one Google integrates with (Cloudflare,
AWS Route 53, GoDaddy, and others), the new
public-key TXT record is published
automatically via the DNS API; otherwise
the admin receives an email notification
with the new record to publish manually.
The selector name rotates between a Google-
chosen sequence (typically
google._domainkeyalternating with a fresh name).
Operator action for routine rotation: enable Auto Key Rotation and confirm the DNS integration works. After that the rotation is fully automated.
7b. Microsoft 365 (Exchange Online)
Microsoft 365 uses a dual-selector model out of
the box: selector1._domainkey and
selector2._domainkey, both
implemented as CNAME records pointing at the
tenant's onmicrosoft.com subdomain. Microsoft
rotates the underlying RSA keys behind those
CNAMEs on a quarterly cadence without any
operator action. The operator's responsibility
is to keep BOTH CNAME records published; if
either is deleted, the next automatic rotation
silently breaks signing because the new key is
not reachable from the operator domain.
; The two Microsoft 365 DKIM CNAMEs:
selector1._domainkey.example.com. CNAME selector1-example-com._domainkey.example.onmicrosoft.com.
selector2._domainkey.example.com. CNAME selector2-example-com._domainkey.example.onmicrosoft.com.
Operator action for routine rotation: none - Microsoft handles it. Verify quarterly that BOTH CNAME records still resolve correctly.
7c. Amazon SES (Easy DKIM)
Amazon SES Easy DKIM uses three CNAME records
pointing at SES-managed targets in the AWS DNS
zone (amazonses.com). SES rotates
the underlying keys behind the CNAMEs on a
schedule managed by AWS. The operator's
responsibility is to keep ALL THREE CNAME
records published.
; The three Amazon SES Easy DKIM CNAMEs (example):
abc123._domainkey.example.com. CNAME abc123.dkim.amazonses.com.
def456._domainkey.example.com. CNAME def456.dkim.amazonses.com.
ghi789._domainkey.example.com. CNAME ghi789.dkim.amazonses.com.
7d. Mailgun
Mailgun uses a per-domain DKIM selector (typically
mailo._domainkey or
mta._domainkey) with manually-
managed rotation. The admin generates a new
key via the Mailgun control panel, publishes
the new TXT record (or CNAME if delegated), and
switches the signing-selector via the control
panel. Mailgun does not currently offer fully
automated rotation, so operators using Mailgun
are responsible for the cadence themselves.
7e. Postmark
Postmark uses one DKIM keypair per Postmark server (the Postmark abstraction for a logical sending identity). The operator manages keys via the Postmark control panel; rotation is manual and requires the operator to generate a new key, publish the new TXT record, and switch the signing selector.
7f. SendGrid
SendGrid uses CNAME-delegated DKIM with selector
names s1._domainkey and
s2._domainkey. Like Microsoft 365,
SendGrid rotates the underlying keys behind the
CNAMEs on an internal cadence. The operator
publishes the two CNAMEs once during initial
setup and SendGrid handles rotation
automatically thereafter.
8. Key size: 1024-bit vs 2048-bit vs Ed25519 (RFC 8463)
The choice of key size is the cryptographic decision that bounds the signing key's safe operating lifetime. Three options are practical in 2026:
| Algorithm | Status | Key length (base64 in DNS) | Notes |
|---|---|---|---|
| 1024-bit RSA | DEPRECATED (RFC 8301, January 2018) | ~216 characters (fits in one 255-byte TXT string) | Factorable with modest cloud budget per the 2012 Zach Harris research. Operators with 1024-bit keys MUST upgrade. |
| 2048-bit RSA | RECOMMENDED minimum (RFC 8301) | ~400 characters (requires multi-string TXT) | The current operational baseline. NIST projects safe through approximately 2030. |
| 4096-bit RSA | Optional defensive depth | ~745 characters (requires multi-string TXT, may hit other UI limits) | Some DNS provider UIs do not handle 4096-bit RSA TXT records cleanly. Verification CPU cost at the receiver is 4x the 2048-bit case. |
| Ed25519 (RFC 8463) | RECOMMENDED for new deployments | ~43 characters (fits trivially in one TXT string) | Verification CPU cost is ~10x faster than 2048-bit RSA. Compact public key. Gmail + Microsoft 365 + most major mailbox providers verify Ed25519 as of 2024. |
The pragmatic recommendation for 2026: publish 2048-bit RSA as the primary algorithm AND Ed25519 as a secondary algorithm under a different selector. Most signers can sign with both keys; receivers that support Ed25519 will prefer it for the verification-cost win, and receivers that do not support Ed25519 will fall back to the RSA signature.
The transition from 1024-bit to 2048-bit (or from 2048-bit to Ed25519) is a rotation event that follows the dual-selector procedure (Section 5). The new key under a new selector is published, the signer is reconfigured to use the new algorithm, and the old algorithm's selector retires after the retention window.
9. Common mistakes
- Never rotating. The most common mistake. A DKIM key published in 2015 and never rotated is still valid until the TXT record is removed. Operators discovering a 10-year-old DKIM key in their zone should treat it as a security finding and rotate immediately.
- Rotating without dual-selector propagation. Hot-swapping the public-key TXT at the same selector at the same instant as switching the signer produces a 24-48 hour validation gap. Use dual-selector unless this is an emergency.
- Removing the old selector too early. The retention window protects in-flight mail; cutting it short produces silent body- hash failures on legitimate retries and mailing-list rebroadcasts. 7 days minimum, 14 days for high-value domains.
- Leaving 1024-bit keys live. RFC 8301 deprecated 1024-bit in 2018. Every domain with a 1024-bit DKIM key today is cryptographically exposed.
- Truncating the TXT record at 255 bytes. Some DNS provider UIs accept a 400-byte string in the input field but truncate it silently. Always verify the published record with a recursive query after publication (Section 11 Troubleshooting).
- Storing the private key in version control. Accidental commit of a DKIM private key to a public Git repository is the most common small-business compromise path. Treat the private key with the same care as a TLS private key: gitignore it, store it on the signing host only, never email it.
- Not rotating after personnel changes. An administrator who has had access to the DKIM private key continues to have that access after departure unless the key is rotated. Treat administrator departures as a rotation trigger.
- Skipping the rehearsal. First-time rotations often hit unexpected issues (TXT-record splitting, signer config syntax, propagation timing). Practice rotation at least once during a quiet period so the procedure is rehearsed before an emergency requires it.
- Not documenting the rotation log. Auditors will ask. Maintain a log of every rotation: date, reason, old selector, new selector, retention-window dates, validator used to confirm publication.
- Forgetting subdomains. If
the parent domain publishes DKIM and a
marketing subdomain publishes its own DKIM
under a separate selector, BOTH need to be
rotated. The most common omission is
forgetting that
news.example.comhas its own selector.
10. Troubleshooting common rotation failures
10a. The 255-byte TXT record limit
A single character-string within a DNS TXT record is limited to 255 bytes by RFC 1035. A 2048-bit RSA public key encoded in base64 produces approximately 400 characters that cannot fit in one string. The standard solution is to split the value across multiple quoted strings within ONE TXT record:
; CORRECT: multi-string TXT record (concatenated by the resolver)
2026q2._domainkey.example.com. IN TXT ( "v=DKIM1; k=rsa; "
"p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
"..middle 255 bytes.."
"..final bytes ending in equals signs.." )
The pitfall is DNS provider UIs that accept a 400-byte string in the input field but silently truncate at 255 bytes when storing. Always verify the published record:
dig +short TXT 2026q2._domainkey.example.com @8.8.8.8
# Expected output: a SINGLE record with multiple strings,
# concatenated as: "v=DKIM1; k=rsa; p=MIIBIjAN..." (400 chars total)
If the output shows only the first 255 characters, the provider truncated. Workarounds:
- Use a different DNS provider (most modern providers handle multi-string TXT correctly).
- Provide the record via the provider's API with explicit string-splitting (bypassing the UI truncation).
- Use Ed25519 DKIM (RFC 8463) which produces ~43-character public keys that fit in one string trivially.
10b. Body-hash failures during the transition
A DKIM signature includes a hash of the
canonicalised message body. If the receiver
fetches the WRONG public key during a rotation
transition (for example, the new public key but
the signer used the old private key), the
body-hash check passes but the signature check
fails - producing a DKIM result of
signature mismatch or
bodyhash mismatch.
Mitigation: the dual-selector procedure (Section 5) avoids this by keeping both keys published and active during the transition. Single-selector hot-swap (Section 6) accepts a 24-48 hour window where this happens; the operator must accept that some in-flight mail will fail.
10c. ARC chain breakage during the transition
Authenticated Received Chain (RFC 8617) preserves upstream DKIM verdicts across forwarding hops by signing the original DKIM result with the forwarder's ARC key. If a forwarder has cached the OLD DKIM public key and validates an in-transit message using that cache, the ARC seal records a "pass" verdict that downstream receivers may treat as authoritative even after the OLD key is retired. The practical effect is minimal because ARC is consultative (downstream receivers can re-verify against the current DNS state), but operators rotating heavily- forwarded mail (mailing-list subscribers, Microsoft 365 distribution-list rewrites) should add a small extra retention buffer.
10d. Body-hash failures from canonicalization mismatch
DKIM has two canonicalization modes for the body:
simple (preserves whitespace) and
relaxed (collapses repeated
whitespace). A rotation that changes the
canonicalization mode (rare but possible if the
signer is replaced as part of the rotation) can
produce body-hash failures even when the
public-key TXT record is published correctly.
Verify the signer's canonicalization mode before
and after the rotation; keep it consistent.
10e. Public key publication verified, signatures still fail
If dig confirms the public key is
correctly published and reachable from external
resolvers but DKIM signatures still fail, the
most common remaining cause is that the SIGNER
is using a different selector or different
private key than the operator expects. Inspect
the DKIM-Signature header on an
outbound test message:
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=example.com; s=2026q2;
h=from:to:subject:date; ...
The s= tag MUST match the
selector name published in DNS. If it does not,
the signer is misconfigured.
11. Frequently asked questions
- How often should I rotate DKIM keys?
- The industry baseline is annual rotation for production DKIM signing keys, with shorter cadences (3-6 months) for high-value brand domains and immediate rotation on suspicion of key compromise. Most managed providers (Google Workspace Auto Key Rotation, Microsoft 365 selector1 / selector2 alternation, Amazon SES Easy DKIM automatic rotation) handle rotation automatically on a quarterly to annual cadence; self-hosted DKIM signing requires explicit operator-managed rotation.
- What is dual-selector DKIM rotation?
- Dual-selector rotation is the canonical zero-downtime DKIM key rotation procedure. The operator publishes a new public key under a fresh selector while the old selector remains live. After the new selector propagates the signer is switched to the new selector; the old selector then stays published for at least 7 days so in-flight mail can validate, after which the old selector is removed.
- Why should I upgrade from 1024-bit to 2048-bit DKIM keys?
- RFC 8301 (January 2018) deprecated 1024-bit RSA DKIM signing keys and mandated 2048-bit RSA minimum. The 2012 Zach Harris research project demonstrated 1024-bit DKIM keys were factorable at sub-thousand-dollar cost; the economics have only improved since.
- What happens when a DKIM key is compromised?
- A compromised DKIM private key lets the attacker sign arbitrary messages under the victim domain that pass DKIM authentication. The mitigation is immediate emergency rotation: generate a fresh keypair, publish the new public key under a new selector, switch the signer to the new selector, and remove the compromised public key from DNS within hours.
- Does Google Workspace rotate DKIM keys automatically?
- Google Workspace offers an Auto Key Rotation feature that periodically generates a new DKIM keypair and publishes the new public key via DNS-API integration or manual TXT publication. Default cadence is quarterly.
- Does Microsoft 365 rotate DKIM keys automatically?
- Microsoft 365 uses a dual-selector model (selector1 and selector2) with automatic quarterly alternation. The selectors are CNAME records pointing at the tenant onmicrosoft.com domain; Microsoft rotates the underlying keys behind the CNAMEs automatically as long as both CNAMEs remain published.
- What is the 255-byte TXT record limit and why does it affect DKIM?
- A single character-string within a DNS TXT record is limited to 255 bytes by RFC 1035. A 2048-bit RSA public key in base64 produces about 400 characters that must be split across multiple quoted strings within one TXT record. Some DNS provider UIs silently truncate, producing a corrupted published key - always verify with a recursive query.
- How long should the old DKIM selector stay published after rotation?
- The conservative answer is 7 days plus the longest known receiver DKIM cache TTL. Most operators keep the old selector for 7-14 days. After the retention window the old public-key TXT record is removed.
13. Audit your current DKIM signing keys now
DMARC Analyzer's
Domain Security Checker
performs a live recursive lookup of any
published DKIM public key under a given selector
(via includes/DnsChecker.php),
reporting the key algorithm, key size, canonical
selector name, and whether the record matches
the RFC 6376 schema. The
Email Header Analyzer
parses the DKIM-Signature header from any
message (via
includes/EmailHeaderParser.php)
and surfaces the signer's selector + algorithm
+ signed-header list + verification result -
the data you need to confirm a rotation has
correctly propagated to your outbound mail.