How do you rotate DKIM keys safely?
To rotate DKIM keys safely, publish a new public key under a new selector, switch signing to the new private key, and keep the old public key in DNS until mail signed with it has been delivered and verified. Then revoke the old key with an empty p= value. Signing never stops, so DKIM keeps passing throughout.
DKIM (DomainKeys Identified Mail) lets a receiver check a signature against a public key published at selector._domainkey.example.com. Rotation means replacing that key pair on a schedule, or at once if a private key may have leaked. This guide covers the standards, the overlap method, Microsoft 365, Google Workspace, vendor-managed keys, verification, rollback and an MSP (managed service provider) schedule. For the protocol basics, start with the DKIM pillar guide.
Key takeaways
- Rotate with two selectors: new key published first, old key kept for an overlap window, then revoked with
p=. Never reuse a selector for a new key. - RFC 6376 gives the method but no interval. The UK NCSC suggests every 12 months; M3AAWG says at least every six months.
- Microsoft 365 rotates with
Rotate-DkimSigningConfigor the Defender portal. Microsoft Learn says the new key starts signing after four days (96 hours). - Confirm with the
s=tag in a test message and with the<selector>element in DMARC aggregate reports, which RFC 9990 now makes mandatory. - Use each rotation to move remaining 1024-bit keys to 2048 bits.
Why should you rotate DKIM keys at all?
You rotate DKIM keys to limit the damage of a private key you no longer fully control. DKIM keys do not expire. Anyone holding the private key can sign mail that passes DKIM for your domain until the public key is removed, so rotation puts an upper bound on how long a leaked or forgotten key stays useful.
RFC 6376 section 8.3 is direct about the risk: a compromised private key means an intruder or malware can send mail signed by the domain, and the published public key will validate it. Realistic exposures are mundane: a former admin with access to an old sending platform, or a key file left on a decommissioned server. Rotation is also the natural moment to upgrade key length and to inventory who signs for each domain.
How often should DKIM keys be rotated?
No RFC sets a rotation interval. The UK NCSC (National Cyber Security Centre) suggests every 12 months, and the M3AAWG (Messaging, Malware and Mobile Anti-Abuse Working Group) DKIM key rotation best practice says at least every six months. Annual rotation is a defensible baseline; six-monthly suits domains with higher risk or busier sending.
Here is what each source actually says, checked in November 2026:
| Source | What it says about rotation | What it says about key size |
|---|---|---|
| RFC 6376 (DKIM) | Section 5.2: start signing with the new key immediately and retain the old public key "for a reasonable validation interval". Section 3.1: signers are "ill-advised to reuse selectors for new keys". No interval. | Superseded by RFC 8301 |
| RFC 8301 | Nothing on rotation frequency | Signers MUST use RSA keys of at least 1024 bits and SHOULD use at least 2048 bits; rsa-sha1 MUST NOT be used |
| NCSC DKIM guidance | "DKIM keys do not expire, but you should rotate them periodically (we suggest every 12 months)." Keep the old record live for a few days. | "We recommend you use a 2048-bit key" |
| M3AAWG DKIM Key Rotation BCP (revised 2019) | Rotate "at least every six months". Keep the old public key for a minimum of seven days and up to 30 days, then empty its p= rather than deleting the selector |
2048-bit keys recommended |
For an MSP, the useful conclusion is a written policy: annual rotation for every client domain as a minimum, six-monthly for high-risk clients, and an immediate out-of-cycle rotation whenever a private key may have been exposed. If you need a key size refresher, see DKIM key length: 1024 vs 2048.
What is the selector overlap method?
The selector overlap method keeps two public keys in DNS during the switch. The new key goes live under a new selector before signing changes, and the old key stays published until messages already signed with it have been verified. Because receivers look up the selector named in each signature, both old and new mail verify during the overlap.
A DKIM selector is the s= value in the DKIM-Signature header, naming the DNS record that holds the public key, so two keys can coexist without conflict.
The five steps are:
- Publish. Generate a new key pair and publish the public key at a new selector, for example
s202611._domainkey.example.com. The platform still signs with the old key. - Verify DNS. Confirm the new record resolves correctly from public resolvers before you touch signing.
- Switch. Point the signing platform at the new private key and selector. New mail carries
s=s202611; mail already queued still carries the old selector. - Overlap. Keep the old public key published. M3AAWG suggests 7 to 30 days. The NCSC says a few days. Seven days is a sensible minimum for most domains.
- Revoke. Replace the old record with an empty key, which RFC 6376 section 3.6.1 defines as revoked.
The revoked record looks like this:
s202505._domainkey.example.com. 3600 IN TXT "v=DKIM1; k=rsa; p="
RFC 6376 section 6.1.2 says a revoked key and a removed record mean the same thing, so deleting also works. The empty p= record, which M3AAWG recommends, shows auditors the selector was retired deliberately.
Never reuse a selector for a new key: mail still in transit points to a DNS name that now holds a different key. A date-based name such as s202611 also shows key age at a glance.
How do you rotate DKIM keys in Microsoft 365?
In Microsoft 365, run Rotate-DkimSigningConfig -Identity <domain> in Exchange Online PowerShell, or select Rotate DKIM keys in the Defender portal. Microsoft generates a new key on the inactive selector. No DNS change is needed, because the selector1 and selector2 CNAME records already point to Microsoft. The new key starts signing after four days (96 hours).
Microsoft 365 builds the overlap into the platform: each custom domain has two CNAME records, and Microsoft alternates between them. The Microsoft Learn DKIM configuration page shows the current format:
Hostname: selector1._domainkey
Points to: selector1-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft
Hostname: selector2._domainkey
Points to: selector2-contoso-com._domainkey.contoso.n-v1.dkim.mail.microsoft
Older tenants may still use the legacy target ending in contoso.onmicrosoft.com. Read the exact values from your tenant rather than copying examples.
What are the PowerShell steps?
Check the domain first. Rotation only works when DKIM is enabled and the status is Valid or CnameMissing.
# 1. Check status, key sizes and rotation state
Get-DkimSigningConfig | Format-List Name,Enabled,Status,Selector1CNAME,Selector1KeySize,Selector2CNAME,Selector2KeySize,KeyCreationTime,RotateOnDate,SelectorBeforeRotateOnDate,SelectorAfterRotateOnDate
# 2. Rotate, upgrading to 2048 bits in the same step
Rotate-DkimSigningConfig -Identity contoso.com -KeySize 2048
# 3. Re-run step 1 and note RotateOnDate and SelectorAfterRotateOnDate
Leave out -KeySize to keep the current size. An upgrade to 2048 applies only to the next active selector, so run a second rotation after the first completes. You cannot start another rotation while one is in progress.
What are the Defender portal steps?
Go to security.microsoft.com/authentication, open the DKIM tab, click the domain row and select Rotate DKIM keys. After four days the status returns to "Signing DKIM signatures for this domain", and the new key is signing.
How do you verify the Microsoft 365 rotation?
After RotateOnDate, send a message to an external mailbox. The s= value in the DKIM-Signature header should match SelectorAfterRotateOnDate. Keep both CNAME records permanently: deleting either breaks the next rotation.
How do you rotate DKIM keys in Google Workspace?
Google Workspace has no dedicated rotate button. You generate a new DKIM record in the Admin console under Apps, Google Workspace, Gmail, Authenticate email, using a selector prefix different from the current one. Publish the new TXT record, wait for it to resolve, then click Start authentication and confirm the new selector in a test message.
When we checked Google's Set up DKIM page in November 2026, it did not describe rotation as a separate process. It documents the building blocks: Generate New Record, a selector prefix (default google; use a different one if that prefix is taken), 2048 or 1024 bits, and up to 48 hours before DKIM starts working.
A safe sequence built from those documented steps:
- In the Admin console, select the domain and click Generate New Record.
- Choose 2048 bits and enter a new prefix, for example
google2026. Do not reusegoogle. - Publish the TXT record at
google2026._domainkey.example.com. Split the key into several quoted strings if your DNS host limits strings to 255 characters. - Check it resolves with
dig(see below). - Click Start authentication. The status should read "Authenticating email with DKIM".
- Send a test message and confirm
s=google2026in theDKIM-Signatureheader. - After the overlap window, set the old
google._domainkeyrecord top=or delete it.
Google's page does not say exactly when Gmail switches to the new key, so step 6 is not optional. Until the header shows the new selector, keep the old record untouched.
What about third-party senders that rotate keys for you?
Many ESPs (email service providers) host the DKIM key themselves and ask you to publish CNAME records pointing to their DNS. With that delegation, the vendor can rotate keys without any change in your zone. Your job is to keep the CNAMEs in place and confirm the vendor's rotation setting, not to generate keys.
Mailgun is a documented example. Its DKIM security documentation says Automatic Sender Security uses two CNAME records pointing to 2048-bit keys, rotated every 120 days by default, with a minimum interval of five days. The two records let Mailgun introduce a new key while the old one remains active, which is the overlap method run by the vendor. The Mailgun DMARC alignment guide covers the rest of that setup.
For other vendors, check their documentation: who generates the key, CNAME or TXT, and whether rotation is automatic. A TXT key pasted into DNS years ago never rotates on its own. RFC 6376 appendix B.1.1 notes you can revoke a vendor's signing rights by removing the delegation record, so remove the CNAMEs when a client drops a sender.
How do you confirm a rotation with dig?
Query the new selector's TXT record and check that it returns v=DKIM1 with a non-empty p= value. After revocation, query the old selector and check that p= is empty. Run the queries against a public resolver as well as your own, so you see what receivers see rather than a cached answer.
# New key: should return v=DKIM1; k=rsa; p=MIIBIjAN...
dig +short TXT s202611._domainkey.example.com @1.1.1.1
# Microsoft 365: follow the CNAME to Microsoft's key
dig +short CNAME selector2._domainkey.example.com
dig +short TXT selector2._domainkey.example.com
# Old key after revocation: p= should be empty
dig +short TXT s202505._domainkey.example.com @8.8.8.8
Multiple quoted strings are normal for a 2048-bit key. In a browser, our DKIM validator and DNS lookup tool run the same checks. To read the signature itself, see how to read email headers.
How do DMARC aggregate reports confirm the rotation?
DMARC aggregate reports show which selector each receiver used to verify DKIM. Under RFC 9990, the <selector> element inside each DKIM result is required, so you can watch traffic move from the old selector to the new one. When the old selector stops appearing with pass, the overlap has done its job and you can revoke.
RFC 9990 section 3.1.1.12 defines the dkim element in auth_results with a required domain (the d= tag), a required selector (the s= tag) and a required result. Appendix C lists "Selector is now required when reporting a DKIM signature" as a change from RFC 7489. A record during the overlap might look like this:
<auth_results>
<dkim>
<domain>example.com</domain>
<selector>s202611</selector>
<result>pass</result>
</dkim>
<spf>
<domain>example.com</domain>
<result>pass</result>
</spf>
</auth_results>
What to look for in the aggregate reports:
- During overlap: both selectors pass, and the old one fades within days.
- After revocation: a few old-selector rows with
failorpermerrorfrom late mail are expected. A steady stream means a platform still signs with the old key.
Reports arrive after the mail they describe, so wait for a couple of days of reports from major receivers before you revoke. In a multi-tenant platform such as DMARC AI, check DKIM results per source for each client domain. The RFC 9990 guide for MSPs covers the rest of the format.
How do you roll back a DKIM rotation?
Roll back by pointing signing at the old selector again, which works as long as the old public key is still published. That is the main reason for the overlap window. If you have already revoked the old key and it was not compromised, republish its public key, wait until it resolves, then switch back.
Rollback by platform:
- Self-managed TXT keys: switch the signer back to the old selector and private key. Fix the new record, verify it with
dig, and try again. - Microsoft 365: a rotation in progress cannot be cancelled or followed by another rotation until it finishes. If the new key misbehaves after
RotateOnDate, check that both CNAMEs resolve, then contact Microsoft support rather than editing DNS. - Google Workspace: check the new TXT record first. A truncated 2048-bit key is the usual cause.
- CNAME-delegated vendors: confirm your CNAMEs still point to the right targets, then raise it with the vendor.
Never roll back to a key you suspect is compromised. Revoke it immediately and accept some DKIM failures; mail with aligned SPF (Sender Policy Framework) can still pass DMARC.
How should an MSP schedule rotations across a portfolio?
An MSP should keep a DKIM inventory per client domain: each sender, its selector, key size, record type, who rotates it and the last rotation date. Then schedule rotations in batches by platform, avoid month-end and other busy sending periods, and record each change. Automatic vendor rotation still needs a periodic check.
An example rotation register:
| Domain | Sender | Selector(s) | Key | Record | Who rotates | Cadence | Next action |
|---|---|---|---|---|---|---|---|
| example-law.co.uk | Microsoft 365 | selector1 / selector2 | RSA 1024 | CNAME | MSP (Rotate-DkimSigningConfig) |
12 months | Rotate with -KeySize 2048, then rotate again |
| example-dental.com | Google Workspace | RSA 1024 | TXT | MSP (Admin console) | 12 months | New 2048-bit key on google2026 |
|
| example-build.com | Mailgun | two CNAMEs | RSA 2048 | CNAME | Vendor (120 days default) | Automatic | Confirm CNAMEs at quarterly review |
| example-clinic.co.uk | On-premises Exchange relay | s202505 | RSA 2048 | TXT | MSP | 6 months (high risk) | Revoke old selector after overlap |
Batch rotations by platform. For Microsoft 365, start the rotation on day one and verify on day five, and put both on the calendar. Treat rotations as standard changes under your DMARC change management policy, and record the selector names in the client's runbook. Common portfolio pitfalls, such as stale vendor selectors and selector drift, are covered in DKIM management for MSPs. For the wider service model, see DMARC for MSPs.
What mistakes break a DKIM rotation?
Most rotation failures come from doing steps out of order: switching signing before the new key resolves, or removing the old key before in-flight mail is verified. The rest come from DNS formatting and forgotten senders. The overlap method and a dig check prevent nearly all of them.
| Mistake | What happens | How to avoid or fix it |
|---|---|---|
| Switching signing before the new key resolves | New mail fails DKIM with no key found | Verify the new record with dig first; switch back until it resolves |
| Revoking the old key too early | Delayed and queued mail fails DKIM | Keep at least 7 days of overlap and watch aggregate reports |
| Pasting a 2048-bit key as one long string | Key is truncated or rejected by the DNS host | Split into quoted strings of 255 characters or fewer |
| Deleting a Microsoft 365 selector CNAME | The next rotation breaks | Keep selector1 and selector2 permanently |
| Forgetting secondary senders | An unrotated TXT key stays in the zone for years | Build the inventory from aggregate reports, not memory |
| Leaving old vendor CNAMEs after offboarding | A former vendor can still sign for the domain | Remove delegation records when a sender is retired |
FAQ
How often should DKIM keys be rotated?
No RFC sets an interval. The UK NCSC suggests rotating every 12 months, and M3AAWG recommends at least every six months. For most client domains, annual rotation is a sound baseline, with six-monthly rotation for high-risk clients. Rotate immediately, outside the schedule, if a private key may have been exposed.
Will rotating DKIM keys cause mail to fail?
Not if you use the selector overlap method. Publish the new key before switching signing, and keep the old public key in DNS for at least several days afterwards. Receivers verify each message against the selector named in its own signature, so old and new mail both pass during the overlap.
Is a 1024-bit DKIM key still acceptable?
RFC 8301 sets 1024 bits as the minimum RSA key size for signers and says they should use at least 2048 bits, so a 1024-bit key is compliant but below the recommendation. Rotation is the natural time to upgrade. See DKIM key length: 1024 vs 2048 for details.
Do I need to change DNS to rotate DKIM in Microsoft 365?
No. Microsoft 365 uses two CNAME records, selector1 and selector2, that point to keys Microsoft hosts. Rotate-DkimSigningConfig creates a new key on the inactive selector, and it starts signing after four days. Keep both CNAMEs published permanently, because each rotation alternates between them.
Final thoughts
DKIM key rotation is low risk once you follow the order: publish, verify, switch, overlap, revoke. Microsoft 365 and CNAME-delegated vendors handle most of the mechanics; Google Workspace and self-managed TXT keys need you to run the steps. RFC 9990 puts the selector in every aggregate report, so you can prove a rotation worked.
For an MSP, the real work is the register of signing sources and key ages. If you have not yet configured signing on a domain, start with how to set up DKIM, and see what DKIM is and why DMARC depends on it for the role it plays in alignment.