Skip to content

Rotating DKIM keys on cPanel without a delivery gap

A practical procedure for rotating DKIM keys on a cPanel host that keeps the old selector valid long enough for in-flight mail to verify, then retires it cleanly.

DKIM keys should rotate at least once a year, and immediately after any host compromise. The mistake we see most often during cPanel handovers is a rotation that replaces the active selector in one move: the new public key is published, the new private key signs every outbound message, but mail already in receiver queues — bounces, list digests, anything held for greylisting — still references the old selector. Those messages now fail DKIM, and DMARC fails alongside them.

What’s happening

DKIM signatures embed a selector (s=) and the signing domain (d=) in the message header. The receiver fetches <selector>._domainkey.<domain> to retrieve the public key and verify. cPanel’s WHM Email Deliverability UI lets you generate a new key per domain, but it overwrites the active selector by default. Any message signed with the previous key that is still in transit — or that a receiver re-evaluates from an archive — fails verification.

How to verify

Before rotating, confirm the current selector and signing domain on a recent outbound message header:

DKIM-Signature: v=1; a=rsa-sha256; d=example.com; s=default; ...

Then check what’s actually published in DNS for that selector:

dig +short TXT default._domainkey.example.com

After rotation, the old TXT record should remain resolvable for at least 48 hours alongside the new one.

The fix

  1. Generate the new key under a new selector name, not under default. Use a dated selector like cp2026a so rotation history is self-documenting.
  2. Publish both records in DNS before flipping Exim to sign with the new selector. Confirm propagation with dig +short TXT cp2026a._domainkey.example.com from at least two resolvers.
  3. Switch the active signing selector in WHM > Email Deliverability or via whmapi1 once both records resolve. Send a test message and inspect the header to confirm s=cp2026a.
  4. Leave the old selector record in DNS for 48 hours minimum, longer if you send heavy list mail with delayed retries. Then delete it.
  5. Document the rotation with date, selector, and key length in your domain record so the next operator knows when to rotate again.

For environments where dozens of cPanel-hosted domains need synchronized key rotation, Stack Harbor handles it as part of deployment management on a calendar you actually see.