DKIM fails after the key changed
Receiving servers report that a domain's DKIM signature fails after its key is rotated. If the domain's DNS is hosted elsewhere, publish the missing record for the new key Rspamd uses.
Symptoms
After you run urbestack-mail-dkim-rotate, receiving servers report that the domain's DKIM signature fails. A receiving server that runs Rspamd adds the following header.
Authentication-Results: mx.example.org;
dkim=none ("invalid DKIM record") header.d=example.com header.s=s20261130 header.b=TrRAWVev;The header.s field gives the selector used to sign the message. Other servers may report the failure as dkim=permerror or dkim=fail.
Cause
urbestack-mail-dkim-rotate creates a key under a dated selector such as s20261130. A second rotation on the same day uses s20261130a. Rspamd starts signing with the new key immediately.
UrbeStack publishes the new key's record in the domain's DNS zone on this server. It keeps the previous selector's record until the next rotation so receiving servers can verify mail still in transit. It removes older records.
When the domain's DNS is hosted elsewhere, receiving servers find no key for the new selector until you copy the record to that DNS host.
Resolution
Use the following command to find the selector in use and the DNS records.
dkim_selectorshows the selector Rspamd signs with, anddkimlists each record'snameandcontent.urbestack-mail-domain-get --name example.comAt the DNS host, add a TXT record using the
nameandcontentfor the selector in use. In this example, the record name iss20261130._domainkey.example.com.Check the public DNS response. It should show the TXT record you published.
dig +short TXT s20261130._domainkey.example.comRotate a key only when you can publish its record immediately. Rspamd starts signing with the new key as soon as you rotate it.