# DKIM key rotation and 2048-bit keys: how to change keys without breaking mail

A DKIM key is a private key on the sending side and a public key in your
DNS. Most domains set one up once and never touch it again. The private
key then lives for years on servers and in vendor systems, and every
message signed with it vouches for your domain. Rotating the key, and
moving to 2048 bits while you're at it, limits how long a leaked or weak
key stays useful.

Done in the right order, rotation doesn't interrupt mail at all.

## Why rotate

- **A leaked key signs as you.** Anyone holding your private key can send
  mail that passes DKIM, and therefore DMARC, for your domain. You rarely
  find out it leaked.
- **Short keys get weaker with time.** M3AAWG's DKIM key rotation best
  practices recount 512-bit keys being cracked in 2012, and say 1024-bit
  keys are at the edge of attack for general-purpose computers.
- **People and vendors change.** A key generated by a former admin, or
  for a sending service you've left, should not still be valid.

M3AAWG recommends rotating **at least every six months**. Microsoft's
documentation makes the same comparison with passwords: you should
periodically change the DKIM key.

## Key sizes: what the standards say

RFC 8301 updated DKIM's rules in 2018:

- Signers **MUST** use RSA keys of at least 1024 bits, and **SHOULD** use
  keys of at least 2048 bits.
- Verifiers **MUST NOT** consider signatures with RSA keys under 1024
  bits valid, and must be able to validate keys from 1024 to 4096 bits.
- `rsa-sha1` **MUST NOT** be used for signing or verifying; sign with
  `rsa-sha256`.

Gmail is in step: Google's sender guidelines require a DKIM key of 1024
bits or longer for mail to personal Gmail accounts, and recommend 2048
bits if your DNS provider supports it.

So 1024 bits still passes, but 2048 is the size to rotate to. A key under
1024 bits doesn't count as a signature at all.

## Ed25519

RFC 8463 added a second algorithm, `ed25519-sha256`. Its public keys are
tiny (44 characters of base64) and published with `k=ed25519`:

```
ed1._domainkey.example.com  TXT  "v=DKIM1; k=ed25519; p=<44 characters>"
```

The RFC says signers SHOULD and verifiers MUST implement it, and for
backward compatibility it suggests signers add signatures with both the
old and new algorithms. In practice that means **dual signing**: keep an
RSA 2048-bit signature on every message, and add Ed25519 alongside it if
your mail server or sending service supports it.

## Long keys and the 255-character limit

A 2048-bit RSA public key is about 400 characters of base64, and a single
string in a DNS TXT record holds at most 255. The record is still one TXT
record, written as several quoted strings that receivers join with no
spaces in between (RFC 6376, section 3.6.2.2):

```
s2._domainkey.example.com  TXT  ( "v=DKIM1; k=rsa; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA..."
                                  "...rest of the key...IDAQAB" )
```

Some DNS providers split long values for you; others need you to enter
the pieces in quotes yourself. Google's DKIM troubleshooting page
describes both splitting the key and, as a fallback, choosing a 1024-bit
key. If a lookup shows the key with a space, a stray quote or a missing
end, the record was split wrong and the signature will fail.

## Rotating with two selectors

The **selector** is what makes rotation painless. RFC 6376 says selectors
make it possible to "seamlessly replace public keys on a routine basis":
the new key is published under a new name, so the old and new keys exist
side by side.

1. **Publish the new key** under a new selector, for example
   `s2._domainkey.example.com`, while mail is still signed with `s1`.
   Check it with `dig TXT s2._domainkey.example.com +short`.
2. **Wait for DNS**: at least the record's TTL, so receivers can find the
   new key.
3. **Switch signing** to the new selector. New messages carry `s=s2` in
   their `DKIM-Signature` header.
4. **Keep the old key published.** Mail signed with `s1` may still be in
   queues or re-checked later. M3AAWG says to keep it for at least seven
   days and up to 30.
5. **Revoke the old key** by emptying `p=`. RFC 6376: "An empty value
   means that this public key has been revoked."

   ```
   s1._domainkey.example.com  TXT  "v=DKIM1; p="
   ```

6. **Leave the revoked record**, or delete it later. M3AAWG advises
   keeping the empty record so it's clear the key was retired on purpose.
   Next time, rotate back the other way or on to `s3`.

To check which key a message used, open it in Gmail with **Show
original** and read `s=` and `d=` in the `DKIM-Signature` header.

## Microsoft 365

Microsoft 365 publishes two CNAMEs, `selector1._domainkey` and
`selector2._domainkey`, that point at keys Microsoft holds. Only one is
active; the other is used after the next rotation. You don't edit DNS to
rotate. Instead:

- In the Defender portal, open **Email authentication settings → DKIM**,
  select the domain and choose **Rotate DKIM keys**, or
- In Exchange Online PowerShell, check the current sizes and rotate to
  2048 bits:

  ```
  Get-DkimSigningConfig | Format-List Name,Selector1KeySize,Selector2KeySize,RotateOnDate
  Rotate-DkimSigningConfig -Identity example.com -KeySize 2048
  ```

The new key starts signing after **four days (96 hours)**; until then
the current key is used. If you created the configuration with
`New-DkimSigningConfig` and didn't set `-KeySize`, it's 1024 bits, which
is that cmdlet's default. If the domain won't enable at all, see
[Microsoft 365 DKIM won't enable](/guides/microsoft-365-dkim-cannot-enable).

## Google Workspace

Google doesn't publish separate rotation steps; you rotate by generating
a new key. In the Admin console (**Apps → Google Workspace → Gmail →
Authenticate email**), choose **Generate new record** with a 2048-bit key.
Google offers 1024 bits only for DNS hosts that can't hold the longer
record.

The default selector prefix is `google`. For the new key, enter a prefix
you haven't used before (Google asks for a different one if `google` is
taken), so the old key stays published while the new one goes live.
Publish the new TXT record, check that it resolves, then **Start
authentication**, and follow steps 4 to 6 above for the old key.
Full setup: [set up DKIM](/guides/dkim-setup).

## Other sending services

Many newsletter, CRM and helpdesk platforms host the key behind a CNAME
you publish once, so they can change the key without you editing DNS. Check each one's
documentation for its key size and whether it rotates for you. If a
service gave you a TXT record with a key pasted in, rotation is your job.

## Check your domain

The [email security checker](/tools/email-checker) looks up DKIM keys at
the selectors common mail services use and reports their type and size:
under 1024 bits, 1024, or 2048 and above, plus revoked keys. You get the
grade and the top issues without an account, and every finding with fix
steps after a free [sign in](/login). Working through deliverability
problems? Start with the
[emails going to spam checklist](/guides/emails-going-to-spam-checklist).

## Sources

- [RFC 6376: DKIM signatures (3.1 selectors, 3.6.1 revoked keys, 3.6.2.2 TXT strings)](https://www.rfc-editor.org/rfc/rfc6376)
- [RFC 8301: DKIM cryptographic algorithm and key usage update](https://www.rfc-editor.org/rfc/rfc8301)
- [RFC 8463: Ed25519 for DKIM](https://www.rfc-editor.org/rfc/rfc8463)
- [M3AAWG: DKIM key rotation best common practices (2019)](https://www.m3aawg.org/DKIMKeyRotation)
- [Google: email sender guidelines](https://support.google.com/a/answer/81126)
- [Google Workspace: set up DKIM](https://knowledge.workspace.google.com/admin/security/set-up-dkim)
- [Google Workspace: troubleshoot DKIM issues](https://knowledge.workspace.google.com/admin/security/troubleshoot-dkim-issues)
- [Microsoft: how to use DKIM for email in your custom domain](https://learn.microsoft.com/en-us/defender-office-365/email-authentication-dkim-configure)

---
Source: https://nameward.app/guides/dkim-key-rotation (updated 2026-12-04)
