Skip to content

Conversation

@lucaforni
Copy link

Questa PR replica la PR originale: postalserver#3029

Autore originale: @schueffi
Branch originale: add_dkim_cname_support
Repository originale: schueffi/postal


In order to use a DKIM public key, it has to be published in the DNS system. The most easy setup simply puts it directly into the appropriate TXT record. A more advanced setup also allows them to be delegated to some other record pointed to by a CNAME record.

As an example, both variants are equivalent in terms of DKIM key validation:

selector1._domainkey.example.org IN TXT "v=DKIM1; p=..."

and

selector1._domainkey.example.org IN CNAME "somekey.mailprovider.org." somekey.mailprovider.org IN TXT "v=DKIM1; p=..."

So, the actual key management can be delegated to some other party by means of using a CNAME.

This is of special importance for infrastructure automation and DKIM key rotation (we just ask the customer / domain dns owner once to add the appropriate CNAME pointing to the corresponding record on our own domain, and then we're able to modify the DKIM keys on our own without requiring the customers to update their DNS records all the time).
As key rotation is a current best practice, the added CNAME support will ease the respective implementation.

This commit changes the code to first check a TXT record (as before), and in addition checks a CNAME record (and if found, check the record it is referring to - up to a limit of 10 recursion steps to avoid endless recursions).

In order to use a DKIM public key, it has to be published in the DNS system.
The most easy setup simply puts it directly into the appropriate TXT record.
A more advanced setup also allows them to be delegated to some other record
pointed to by a CNAME record.

As an example, both variants are equivalent in terms of DKIM key validation:

selector1._domainkey.example.org IN TXT "v=DKIM1; p=..."

and

selector1._domainkey.example.org IN CNAME "somekey.mailprovider.org."
somekey.mailprovider.org IN TXT "v=DKIM1; p=..."

So, the actual key management can be delegated to some other party by means of
using a CNAME.

This is of special importance for infrastructure automation and DKIM key rotation
(we just ask the customer / domain dns owner once to add the appropriate CNAME
pointing to the corresponding record on our own domain, and then we're able to
modify the DKIM keys on our own without requiring the customers to update their
DNS records all the time).
As key rotation is a current best practice, the added CNAME support will ease
the respective implementation.

This commit changes the code to first check a TXT record (as before), and in
addition checks a CNAME record (and if found, check the record it is referring
to - up to a limit of 10 recursion steps to avoid endless recursions).
@github-actions
Copy link

github-actions bot commented Sep 2, 2025

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the stale label Sep 2, 2025
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

This PR was closed because it has been stalled for 10 days with no activity.

@github-actions github-actions bot closed this Nov 7, 2025
@lucaforni lucaforni reopened this Nov 10, 2025
@lucaforni lucaforni merged commit 5ce0b1c into main-modalsource Nov 10, 2025
12 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants