DKIM verification failing with mixed email formats in To field #1026
-
I've run into an issue with trying to validate the DKIM signature on a message received from Gmail. The message had two recipients, both on an IDN domain. One of the recipient email addresses had a local part that included a non-ASCII character and the other recipient email address had an all ASCII local part. The message received from Gmail had a header-field like the following (the domain name has been anonymized):
When trying to use
and
Can anyone suggest a way to verify the DKIM signature for a message like this? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
The DKIM verifier logic doesn't reformat the headers international vs non-international because I don't think it is supposed to (am I wrong?). My guess is that an MTA reformatted the headers at some point (which is why there is a mix) and that's what is causing DKIM to fail. |
Beta Was this translation helpful? Give feedback.
-
Based on my understanding of the relevant RFCs, the DKIM verifier should not be modifying the headers as far as international/non-international goes. However, it does appear to be doing so. I've run some tests with a few different messages, and got the following results:
One thing to note is that, due to how Gmail formats parameters in the Content-Type and Content-Disposition headers, when using a FormatOptions with International set to true, I also set AlwaysQuoteParameterValues to true. Without that, the body hash was not properly validating. As for an intermediate MTA modifying the headers in transit, that could only be the case if one of Google's own servers is modifying the message. The received headers indicate that it was received by a Google server which assigned an SMTP id, then sent directly to the server doing the DKIM verification. I did another walk through the code trying to verify the message I originally described, and I can confirm that the headers are being converted in some scenarios during DKIM verification. The problem appears to be in |
Beta Was this translation helpful? Give feedback.
-
I think I figured out why International needs to be set to true for validating a message from Gmail to an address like
When attempting to verify the DKIM signature with International = false, |
Beta Was this translation helpful? Give feedback.
-
I figured out what was causing the behavior I described. It appears to be due to a service I was unaware was running on our system. That service did not properly support 8BITMIME and was trying to ensure the headers were properly encoded. Due to timing, this was happening between when the message was received over SMTP and when the DKIM verification was done. Removing that service fixed the issue, and all my test cases are now verifying correctly with the default FormatOptions. |
Beta Was this translation helpful? Give feedback.
I figured out what was causing the behavior I described. It appears to be due to a service I was unaware was running on our system. That service did not properly support 8BITMIME and was trying to ensure the headers were properly encoded. Due to timing, this was happening between when the message was received over SMTP and when the DKIM verification was done. Removing that service fixed the issue, and all my test cases are now verifying correctly with the default FormatOptions.