Learn/Email

DKIM: selectors, key length, and how to fix keys

DKIM signs each message your email services send, so receivers can confirm it came from you unaltered. Turn it on in every service that sends as your domain.

Want this checked on your own domain?

Join the waitlist

Updated

Message for whoever manages your email

Hi, could you confirm that DKIM signing is turned on for our domain in every service that sends email as us?

That’s our mailbox provider plus newsletter, store, billing, help desk, and so on. Please choose a 2048-bit key where a service offers it, and make sure the DKIM records each service provides are published in our DNS.

Thank you.

Want this checked on your own domain? Join the waitlist.

Check yours

The DKIM checker (join the waitlist for access) looks up the names that common email services use for their keys, then checks each key it finds.

DNS can’t list every key a domain publishes, so a key at an unusual name won’t show up. To see the name your mail actually uses, read it from a message header (Find your selector). The full report checks DKIM together with SPF and DMARC.

Fix it

DKIM is set up in the service that sends the mail. That service holds the private key and signs each message. Your DNS holds the matching public key, under a name called the selector: the key for selector s1 lives at s1._domainkey.example.com (RFC 6376 §3.6.2.1).

Set up DKIM for a sending service

  1. Open the service’s domain authentication or DKIM settings. It shows you one of two things:
    • a TXT record, which is the key itself;
    • one or more CNAME records that point to keys the service hosts, and can replace for you.
  2. Publish exactly what it shows, at exactly the name it shows, at your DNS host.
    • Check whether your DNS host adds your domain to the name for you. At Namecheap, for example, you enter only the part before your domain, such as google._domainkey.
    • At Cloudflare, set DKIM CNAME records to “DNS only”. Microsoft’s instructions explain why: with Cloudflare’s proxy on, lookups return Cloudflare’s addresses instead of the CNAME target, and DKIM verification fails.
  3. Turn signing on in the service. In Google Workspace, that’s “Start authentication”. In Microsoft 365, it’s the “Sign messages for this domain with DKIM signatures” toggle.
  4. Check with a real message sent to someone else. Google notes you can’t verify DKIM by sending a test message to yourself.
    • Open the message’s full header. In Gmail, that’s More → Show original.
    • Find the Authentication-Results line. It should show dkim=pass with your domain.

Long keys. A 2048-bit key doesn’t fit in one TXT string, which holds at most 255 characters (RFC 1035 §3.3).

  • If your DNS host requires long values to be split, enter several quoted strings one after another in the same record. Receivers join them with nothing in between (RFC 6376 §3.6.2.2). Amazon Route 53, for example, wants each string in double quotes on the same line.
  • If your DNS host can’t store long values at all, Google suggests choosing a 1024-bit key.

How long it takes. Google says DKIM can take up to 48 hours to start working. Microsoft 365 detects new CNAME records in “a few minutes (or possibly longer)”.

Find your selector

Open the full header of a message your domain sent and find the DKIM-Signature line:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=google; ...
  • d= is the signing domain. It counts for DMARC when it’s your domain or another name under it, such as mail.example.com (RFC 9989 §4.4.1).
  • s= is the selector. In this example the key is at google._domainkey.example.com.

A message can carry several signatures. Microsoft notes that many hosted services sign with their own domain, and add a signature with yours once you configure it. Only a signature with your domain counts for DMARC.

Rotate and retire keys

M3AAWG (the Messaging, Malware and Mobile Anti-Abuse Working Group) recommends replacing (“rotating”) DKIM keys at least every six months.

When a service gives you CNAME records, the key lives on the service’s side, so the service can replace it without any change to your DNS. Microsoft 365, for example, has a “Rotate DKIM keys” button; a rotation takes four days to take effect.

To rotate a key you publish yourself:

  1. Publish the new key under a new selector name. Don’t reuse old selector names (RFC 6376 §3.1; M3AAWG).
  2. Once it’s visible in DNS, switch the service to sign with it.
  3. Keep the old key published for 7 to 30 days, so mail already sent can still be checked (M3AAWG).
  4. Retire the old key by emptying its key value (p=) rather than deleting the record (M3AAWG).

A DKIM key is too short to count

What it means: An RSA key is shorter than 1024 bits. Signers must use keys of at least 1024 bits. Receivers must not accept signatures made with shorter keys as valid (RFC 8301 §3.2). Mail signed only with this key is treated as having no valid DKIM signature.

Fix:

  1. In the sending service, generate a new key: 2048-bit where offered, 1024-bit at minimum. Use a new selector name.
  2. Publish the new key, then switch signing to it.
  3. Retire the old key with an empty p=.

If the record is a CNAME that points into the service’s own domain, the key belongs to the service. Ask the service to replace it.

Confirm: The DKIM checker shows the new key’s size.

Some DKIM keys are 1024-bit

What it means: The key is 1024 bits. That meets the minimum in RFC 8301 and the documented minimums at Gmail and Yahoo. RFC 8301 §3.2 and Google recommend 2048 bits.

What to do: Choose 2048 bits the next time the key is rotated.

  • Google Workspace: select 2048 when you generate the key.
  • Microsoft 365: a rotation in PowerShell can change the size (Rotate-DkimSigningConfig -Identity example.com -KeySize 2048). The new size applies to the next active selector first. Note that New-DkimSigningConfig creates 1024-bit keys unless you ask for 2048.
  • Keys a service hosts behind CNAME records: those are the service’s to upgrade.

A DKIM key is in test mode

What it means: The key record contains the flag t=y. RFC 6376 §3.6.1 says receivers “MUST NOT treat messages from Signers in testing mode differently from unsigned email”. Your signatures therefore add nothing, even when they verify.

Fix: Once signing works, remove y from the t= tag. Keep any other flag: t=y:s becomes t=s, and a lone t=y can be removed entirely. If the record is a CNAME to the service’s key, ask the service.

Confirm: The checker no longer reports test mode.

A DKIM key allows only SHA-1

What it means: The key record restricts its hash algorithms to SHA-1 (h=sha1).

  • SHA-1 signing (rsa-sha1) “MUST NOT be used for signing or verifying” (RFC 8301 §3.1).
  • A signature that uses SHA-256 doesn’t match the key’s h= list, so receivers must ignore the key for it, and the signature fails (RFC 6376 §6.1.2).

Either way, no signature made with this key counts.

Fix: Remove the h= tag (the default allows all algorithms), or set it to h=sha256. Better still, generate a new key in the sending service.

Confirm: The checker no longer reports the restriction.

A DKIM record is damaged

What it means: The key record can’t be used:

  • it has v=DKIM1 but no p= tag at all, which RFC 6376 §3.6.1 requires;
  • the key value (p=) isn’t valid base64;
  • it doesn’t decode to a public key;
  • it’s an Ed25519 key that isn’t 32 bytes long;
  • it’s a key type DKIM doesn’t use.

Receivers must ignore a malformed key record, so every signature made with it fails (RFC 6376 §6.1.2). Google’s troubleshooting guide describes a common cause: a long value that was truncated, or split and pasted out of order. Quote marks copied into the value also break it, because they aren’t valid in a key. Spaces inside the value are allowed and don’t cause this (RFC 6376 §3.6.1).

Fix: Copy the full value from the sending service again and replace the record. If your DNS host needs long values split, follow the steps under Long keys in Set up DKIM. Google suggests comparing the published value with the one in the service, to check that every character is there and in the right order.

Confirm: The checker reads the key and shows its size.

Only retired DKIM keys found

What it means: Every key found has an empty value (p=), which marks a key as revoked (RFC 6376 §3.6.1). Receivers fail any signature that points to a revoked key (§6.1.2).

Leaving retired selectors in place with an empty p= is good practice (M3AAWG). But no active key was found at the names we looked up. Either your mail is signed with a key at another name, or signing isn’t working.

Fix:

  1. Find the selector in a recent message.
    • If it’s one of the revoked names, signing is broken. Publish the service’s current key, or turn signing on again in its DKIM settings.
    • If it’s a name we didn’t look up, and the Authentication-Results line shows dkim=pass for your domain, nothing needs fixing.
  2. If messages carry no signature with your domain, turn on DKIM in each sending service.

Couldn’t confirm DKIM for your email provider

What it means: Your mail servers or SPF record show that you use an email service that always signs with the same selector names, but there is no usable key at any of them.

  • Microsoft 365 always uses selector1 and selector2, so a missing key there is a strong sign that DKIM isn’t set up. Microsoft’s documentation says no DKIM signing with a custom domain happens until you configure it. Microsoft signs with one of the two at a time, so a key at either name is enough for our check.
  • Services whose selector name an administrator can change, such as Google Workspace, aren’t reported here: a missing key at the default name proves nothing for them.

Why it matters: Without a DKIM signature that matches your domain, DMARC depends on SPF alone, and SPF usually fails when mail is forwarded (RFC 9989 §7.4). RFC 9989 §7.4 says domains that publish a DMARC policy of reject “MUST apply valid DKIM signatures”.

Fix:

  • Microsoft 365:
    1. In the Microsoft Defender portal, go to Email & collaboration → Policies & rules → Threat policies → Email authentication settings, and open the DKIM tab.
    2. Select your domain and copy the two CNAME records it shows.
    3. Publish them at your DNS host.
    4. After Microsoft detects them, turn on “Sign messages for this domain with DKIM signatures”.
  • Other services: open the service’s domain authentication settings and publish the records it gives you.

Confirm: The checker finds the key, and a message’s header shows dkim=pass for your domain.

No DKIM key found at common names

What it means: Depends on what we found.

  • No DKIM names exist under your domain at all. The DNS name _domainkey.example.com doesn’t exist, and when a name doesn’t exist, nothing beneath it exists either (RFC 8020). So the domain publishes no DKIM keys, and mail from it isn’t DKIM-signed with your domain.
  • Otherwise, this result proves nothing either way. A selector can be any name the service chooses (RFC 6376 §3.1 gives dates and office locations as examples), and we can only look up names we know.

What to do: Find the selector in a recent message. If there is no signature with your domain, set up DKIM in each sending service.

Technical reference

Key record

The key is a TXT record at <selector>._domainkey.<domain>, written as tag=value pairs separated by semicolons (RFC 6376 §3.6.1):

TagMeaning
v=DKIM1Version. Optional, but if present it must come first and be exactly DKIM1; a record with any other value is discarded
k=Key type: rsa (the default) or ed25519 (RFC 8463)
p=The public key, base64-encoded. Required. Empty means revoked. Whitespace inside is allowed
h=Hash algorithms the key accepts, colon-separated. The default is all
t=Flags: y means testing (receivers treat mail as unsigned); s means a signature’s i= domain must equal d= exactly
s=Service types. The default * means all
n=Notes for people. Ignored by software

Tags a receiver doesn’t recognize are ignored. A string-split value is joined with no whitespace, and if one selector name has more than one TXT record, the result is undefined (§3.6.2.2).

Examples:

s1._domainkey.example.com.  TXT  "v=DKIM1; k=rsa; p=MIIBIjANBgkq…"
s2._domainkey.example.com.  TXT  "v=DKIM1; k=ed25519; p=<44 base64 characters>"
old._domainkey.example.com. TXT  "v=DKIM1; p="

Algorithms and key sizes

  • RSA with SHA-256 (rsa-sha256): signers must sign with it and receivers must verify it. rsa-sha1 must not be used for signing or verifying, and signatures that use it have permanently failed (RFC 8301 §3.1).
  • RSA key size: signers must use at least 1024 bits and should use at least 2048. Receivers must handle 1024 to 4096 bits, and must not accept signatures made with keys under 1024 bits (RFC 8301 §3.2).
  • RSA key format: the p= value is a DER-encoded RSAPublicKey, which may be wrapped in a SubjectPublicKeyInfo structure. RFC 6376’s own key-generation example (Appendix C) produces the wrapped form, and Erratum 3017 notes that most implementations accept it (RFC 6376 §3.6.1 with Erratum 3017).
  • Ed25519 (ed25519-sha256, RFC 8463): the key is 32 bytes, which is 44 characters of base64, and fits in a single TXT string.
    • Receivers must implement it; signers should (§5).
    • A receiver ignores signatures that use an algorithm it doesn’t implement (RFC 6376 §3.3.4). That’s why RFC 8463 §6 suggests signing with both RSA and Ed25519, each under its own selector.

Verification

The receiver takes d= and s= from the DKIM-Signature header and looks up the key (RFC 6376 §6.1.2). Then:

  • No key: if the key record doesn’t exist, the signature fails.
  • Bad key: a malformed key, a key whose h= excludes the signature’s hash, or a revoked key (empty p=) also fails it.
  • Removed or revoked: RFC 6376 defines no difference between the two (§3.1, §6.1.2). M3AAWG recommends the empty p=, so the selector stays discoverable as intentionally retired.
  • Wildcards: a wildcard TXT record that covers _domainkey names answers every selector lookup, usually with something that isn’t a valid key (§6.1.2).

A valid signature from any domain proves only that that domain signed. DMARC counts a DKIM pass only when d= shares an organizational domain with the From address (relaxed alignment, the default), or matches it exactly when the DMARC record sets adkim=s (RFC 9989 §4.4.1, §4.7). See DMARC.

Selectors can’t be listed

A DNS query asks about one name (RFC 1035 §4.1.2), so a key can only be found by someone who knows or guesses its selector. Selectors are chosen by whoever signs. Some services use fixed names (google, selector1); others use dates or random values, both of which RFC 6376 §3.1 describes. To learn a domain’s real selectors, look at the s= tag in messages it sent.

What the report checks

We look up _domainkey.<domain> itself, a random selector name that no one publishes, and the documented default selectors of the email services we recognize, plus a few common generic names. CNAME records are followed to the key they point to.

  • Wildcards: if the random name returns an answer, the domain has a wildcard. We ignore any answer that’s identical to it.
  • Which keys count: each TXT answer is parsed as a key record. Answers without a p= tag, or with a v= other than DKIM1, aren’t keys and are skipped.
  • RSA key size comes from the decoded key itself.
  • Which domains we check: domains that send or receive email, and any domain where a key is found.

Finding a key proves it’s published, not that mail is signed with it. Not finding one proves absence only when _domainkey itself doesn’t exist.

FindingWhen we report itStandard
DKIM signing keys foundAt least one usable keyRFC 6376 §3.6.1
A DKIM key is too short to countAn RSA key under 1024 bitsRFC 8301 §3.2
Some DKIM keys are 1024-bitAn RSA key of exactly 1024 bitsRFC 8301 §3.2
A DKIM key is in test modeA usable key with t=yRFC 6376 §3.6.1
A DKIM key allows only SHA-1A usable key whose h= lists only sha1RFC 8301 §3.1
A DKIM record is damagedA v=DKIM1 record has no p=, or p= isn’t valid base64, isn’t a public key, is an Ed25519 key that isn’t 32 bytes, or is an unsupported key typeRFC 6376 §3.6.1, §6.1.2
Only retired DKIM keys foundEvery key found is revoked (empty p=)RFC 6376 §3.6.1
Couldn’t confirm DKIM for your email providerYour MX or SPF records point to an email service that always signs with the same selector names, and none of them has a usable key—
No DKIM key found at common namesNo keys at any name we looked up. Certain when _domainkey doesn’t exist (RFC 8020)RFC 6376 §3.1

Sources

Want this checked on your own domain?

Join the waitlist
Domain Readiness

Free checks for email, website, DNS, and registration, with plain-English fixes.

Domain Readiness™ (domainreadiness.com) is a service of Riviera Learning, LLC.