Tools / Guides / DKIM 2048-bit in M365

Rotate DKIM keys to 2048-bit in Microsoft 365

How to rotate DKIM keys to 2048-bit in Microsoft 365: check the key size, run the rotation in PowerShell, wait out the 4-day switch and verify both selectors.

Updated 2026-11-18 · 7 min read

The email security review came back with one amber line: "DKIM key is 1024-bit". The domain passes DKIM, DMARC is enforced, mail flows, and now someone wants it fixed before the next audit. The good news is that you can rotate DKIM keys to 2048-bit in Microsoft 365 without touching DNS and without a mail outage. The catch is timing: each rotation takes about four days to take effect, and a full upgrade needs two of them.

Here is how to check where you stand, run the rotation, and confirm it worked from the outside.

Why is my Microsoft 365 DKIM key still 1024-bit?

Older tenants enabled custom-domain DKIM when 1024-bit was Microsoft's default, and a key never changes size on its own. Enabling DKIM again or toggling it off and on does not upgrade it. Only a rotation with an explicit key size does.

A 1024-bit RSA key is not broken in practice today, but it is below what most current guidance recommends, and auditors and scanners flag it. Since the upgrade costs nothing but a few days of waiting, there is little reason to argue about it.

How do I check the current DKIM key size?

Connect to Exchange Online PowerShell and look at the signing config for the domain:

Connect-ExchangeOnline
Get-DkimSigningConfig -Identity contoso.com |
  Format-List Domain, Enabled, Selector1KeySize, Selector2KeySize,
              Selector1CNAME, Selector2CNAME, RotateOnDate,
              SelectorBeforeRotateOnDate, SelectorAfterRotateOnDate

Read it this way:

Run Get-DkimSigningConfig without -Identity to list every accepted domain at once. Tenants with a dozen brand domains often have a mix of key sizes, and you want the whole list before you start.

How do I rotate DKIM keys to 2048-bit in Microsoft 365?

Microsoft 365 keeps two selectors per domain. One signs mail; the other sits ready. A rotation generates a new key on the inactive selector, then switches signing to it after roughly four days (Microsoft documents up to 96 hours). The old selector stays published, so messages already in transit still verify.

Before you rotate, check that both CNAME records exist in your public DNS. The values to publish are in the Selector1CNAME and Selector2CNAME fields. If only selector1 was ever published, the rotation will move signing to a selector receivers cannot look up, and DKIM will start failing.

Resolve-DnsName selector1._domainkey.contoso.com -Type CNAME
Resolve-DnsName selector2._domainkey.contoso.com -Type CNAME

Then rotate with the key size stated explicitly:

Rotate-DkimSigningConfig -Identity contoso.com -KeySize 2048

You can also rotate from the Defender portal (Email & collaboration > Policies & rules > Threat policies > Email authentication settings > DKIM, select the domain, then Rotate DKIM keys). PowerShell is the better choice here because the command states the key size and leaves no doubt about what you asked for.

Why one rotation is not enough

This is the step people miss. The first rotation upgrades only the selector that was inactive. After four days you are signing with a 2048-bit key, but the other selector still holds the old 1024-bit key. Run the same command a second time once the first switch has happened, wait another four days, and both selectors end up at 2048.

DayActionSigning withSelector state
0First Rotate-DkimSigningConfig -KeySize 2048selector1 (1024)selector2 now holds a 2048 key
~4Switch happens automaticallyselector2 (2048)selector1 still 1024
~4Second rotationselector2 (2048)selector1 gets a new 2048 key
~8Switch happens automaticallyselector1 (2048)Both at 2048

Your selectors may be the other way round; the logic is the same. If you stop after one rotation, the next external scan of selector1 will still report 1024-bit and the audit item comes back.

Do I need to change DNS records for a 2048-bit DKIM key?

No, as long as the CNAMEs are already in place. In Microsoft 365 your selector records are CNAMEs that point at a hostname Microsoft controls, and the public key lives there. Microsoft publishes the new key behind the same CNAME, so nothing in your zone changes.

This is different from self-hosted or some third-party senders, where you publish the TXT record yourself. A 2048-bit key is longer than the 255-character limit of a single DNS string, so it has to be split into several quoted strings inside one TXT record. If you ever copy a key into a DNS host by hand and DKIM starts failing, that is the first thing to check.

How do I confirm the rotation worked?

Check in three places, because each one answers a different question:

  1. The config. Run Get-DkimSigningConfig again. Both key sizes should read 2048, and RotateOnDate should be in the past.
  2. DNS, from outside. Look up both selectors and compare the length of the p= value. A 1024-bit RSA key is about 216 base64 characters; a 2048-bit key is about 392. You do not need to decode it to tell them apart.
  3. A real message. Send a mail to an external mailbox and open the headers. The DKIM-Signature line shows d=contoso.com and s=selector1 or s=selector2, and Authentication-Results should show dkim=pass with header.d=contoso.com. If you are not used to reading these, see how to read email headers.
Resolve-DnsName selector2._domainkey.contoso.com -Type TXT |
  Select-Object -ExpandProperty Strings

The DNS check matters most for audits, because that is what external scanners see. The header check is what proves receivers are actually verifying the new key.

Where this usually goes wrong

If DKIM is the reason you are holding DMARC at p=none, this is a good moment to finish that job as well: moving DMARC from p=none to p=reject walks through it.

FAQ

Will rotating DKIM keys interrupt mail flow?

No. Both selectors stay published during the switch, so mail signed with the old key still verifies while it is in transit or sitting in queues. Receivers simply look up whichever selector the message names.

Can I use a 4096-bit DKIM key in Microsoft 365?

No. Microsoft 365 supports 1024 and 2048 bits for DKIM. 2048 is also the practical ceiling for most senders, because longer keys are awkward in DNS and some receivers handle them poorly.

Does the onmicrosoft.com domain need rotating?

Microsoft manages DKIM for the initial onmicrosoft.com domain, and you have no DNS for it to publish. Focus on your custom domains, which are what DMARC alignment and external scans care about.

How often should I rotate DKIM keys after this?

Once or twice a year is a common rhythm, and many security baselines ask for a scheduled rotation. In Microsoft 365 the private key never leaves Microsoft, so routine rotation is housekeeping rather than an emergency; just remember each one takes about four days to switch over.