Add support for CNAME delegated DKIM keys #3029
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).