Skip to content

Enable DKIM in Microsoft 365 (Office 365): CNAMEs, CnameMissing and 2048-bit keys

Without custom DKIM, mail from your Microsoft 365 domain carries at most an onmicrosoft.com signature, which DMARC cannot use. Enable DKIM in Microsoft 365 with two CNAMEs, get past CnameMissing and switch to 2048-bit keys.

Offensly Team··Updated ·6 min read

You open the headers of a message sent from Outlook and find a DKIM pass that does not help you:

Authentication-Results: spf=pass (sender IP is 198.51.100.20)
 smtp.mailfrom=example.com; dkim=pass (signature was verified)
 header.d=<tenant>.onmicrosoft.com; dmarc=pass action=none
 header.from=example.com

Look at header.d. Until you enable DKIM in Microsoft 365 for your custom domain, the only signature on the message, if any, belongs to your onmicrosoft.com domain. It verifies, but it does not align with header.from=example.com, so DMARC passes on SPF alone (RFC 7489, section 3.1.1). The first forwarder that relays the message from its own servers breaks SPF, and DMARC goes with it.

Two CNAMEs, and why you never paste a key

Microsoft 365 keeps the private keys and publishes the public keys under its own DNS zone. You only point two names in your zone at them: selector1._domainkey and selector2._domainkey. One selector signs; the other waits for the next key rotation. Both must exist from day one, because Microsoft rotates by switching selectors, not by asking you to edit DNS (Microsoft Learn).

The CNAME target format changed in May 2025. Domains added since then get targets like selector1-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft, where the single letter before -v1 is assigned by Microsoft. Older domains keep selector1-example-com._domainkey.<tenant>.onmicrosoft.com. The two formats cannot be mixed for the same selector, so do not build the value from a blog post or from another domain in your tenant. Copy it from your own tenant.

Enable DKIM in Microsoft 365 (Office 365) for a custom domain

  1. In the Defender portal, open Email & collaboration > Policies & rules > Threat policies > Email authentication settings and select the DKIM tab. Your domain shows Status NoDKIMKeys and the toggle Disabled.
  2. Slide the toggle to Enabled. It will not stay on. A Client error dialog opens with the CNAME values buried in a block of text. Select OK; the status is now CnameMissing, which means keys exist and Microsoft is waiting for DNS.
  3. Click the domain row (not the toggle) and copy both values from Publish CNAMEs. In Exchange Online PowerShell you get the same values in a cleaner form:
PS> Get-DkimSigningConfig -Identity example.com | Format-List Name,Enabled,Status,Selector1CNAME,Selector2CNAME

Name           : example.com
Enabled        : False
Status         : CnameMissing
Selector1CNAME : selector1-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft
Selector2CNAME : selector2-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft

If the domain is missing from this output, run New-DkimSigningConfig -DomainName example.com -Enabled $false -KeySize 2048 first, then repeat the command above.

  1. Publish both records at your DNS host, with a TTL of 3600:
selector1._domainkey.example.com.  3600  IN  CNAME  selector1-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft.
selector2._domainkey.example.com.  3600  IN  CNAME  selector2-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft.
  1. Wait until both names resolve publicly, then go back to the domain flyout and turn on Sign messages for this domain with DKIM signatures, or run Set-DkimSigningConfig -Identity example.com -Enabled $true. Success reads Signing DKIM signatures for this domain in the portal and Status : Valid in PowerShell.

Repeat for every domain and subdomain that appears in a From: address. Each one needs its own pair of CNAMEs.

Status stuck at CnameMissing: read what DNS returns

Microsoft says detection can take minutes or longer, so give it an hour. If the toggle still flips back, query the name yourself:

$ dig CNAME selector1._domainkey.example.com +short
selector1-example-com._domainkey.<tenant>.n-v1.dkim.mail.microsoft.

That single line is the healthy answer. Anything else points at one cause:

  • Empty output. The record sits under the wrong name. The usual culprit is a panel that appends the zone, turning selector1._domainkey.example.com into selector1._domainkey.example.com.example.com. GoDaddy does this: enter only selector1._domainkey in Name. Also check that you edited the zone your registrar actually delegates to.
  • A v=DKIM1; k=rsa; p=... string under dig TXT. Someone published a key as TXT. Microsoft 365 does not support that; delete it and create the CNAME.
  • IP addresses under dig A, no CNAME. In Cloudflare the record is proxied. Under DNS > Records, edit both selectors and set Proxy status to DNS only (grey cloud).
  • A CNAME with a different target. It was typed by hand or copied from an old format. Compare character by character with Selector1CNAME; dots versus dashes in example-com are the common slip.

All four come from Microsoft's DKIM troubleshooting list. If you rarely touch the zone, the guide to adding DNS records shows where the CNAME form sits in common panels.

Two things look related but need no change. DKIM records for other senders, such as s1._domainkey from a newsletter tool, use different selector names and keep working. Your SPF record does not change either. If your headers also show spf=permerror, that is a separate problem, usually two SPF records on one domain.

Move the keys from 1024 to 2048 bits

New-DkimSigningConfig defaults to 1024-bit keys. Use 2048. Check what you have:

PS> Get-DkimSigningConfig -Identity example.com | Format-List Selector1KeySize,Selector2KeySize,RotateOnDate

If either says 1024, run Rotate-DkimSigningConfig -Identity example.com -KeySize 2048. The new size applies only to the selector that becomes active, and the switch takes 96 hours, during which no other rotation is allowed. Rotate a second time after that to bring the other selector to 2048. No DNS change is needed for either step.

Office 365 DKIM questions

Do I need a DKIM key generator for Office 365?

No. Microsoft 365 creates the key pair itself when you enable DKIM for the domain or run New-DkimSigningConfig. A key from an online DKIM generator cannot be used, because Microsoft 365 does not accept a public key published as TXT. You only publish the two CNAMEs.

How do I change the signing domain from onmicrosoft.com to my own domain?

Enable DKIM for the custom domain as described above. There is no separate setting for the signing domain: once the status reads Valid, mail from that domain is signed with d=example.com instead of the onmicrosoft.com domain.

What are selector1 and selector2 for?

Each is a CNAME to a public key Microsoft publishes for your tenant. Only one signs at a time; the other holds the next key. That is why both must resolve before you turn signing on, and why you never edit them after a rotation.

What signing with the onmicrosoft.com domain costs you

While DKIM rides on onmicrosoft.com, every message depends on SPF to pass DMARC. That works until you tighten the policy; at p=quarantine or p=reject, mail your staff sent that was forwarded along the way lands in spam or bounces. Enabling DKIM is two DNS records and one toggle, and it is the step to finish before you move DMARC from p=none to enforcement.

Confirm the signature on a real message

Send from a mailbox in the domain to an external address, such as a Gmail or Outlook.com account. Mail between two domains in your own tenant is not signed, so an internal test proves nothing. In the received copy look for:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=selector1; ...
Authentication-Results: mx.google.com; dkim=pass header.i=@example.com header.s=selector1 ...

d=example.com is the change you wanted. If external tests pass but one partner still reports dkim=fail, the message is being altered on the way, and the article on DKIM body hash did not verify covers that case. The free Offensly check, no account needed, checks your DKIM record together with SPF, DMARC and MX, so you can see what receivers see from outside your network.

Check your DKIM record for free

Check your own domain in seconds

The free check reads your SPF, DKIM, DMARC and MX records and tells you exactly what to fix. No sign-up.