Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid (wrong body hash) due to no line breaks #20

Open
JakeTheSnake3p0 opened this issue Nov 2, 2015 · 11 comments
Open

Invalid (wrong body hash) due to no line breaks #20

JakeTheSnake3p0 opened this issue Nov 2, 2015 · 11 comments

Comments

@JakeTheSnake3p0
Copy link

i.e., look here to see the issue. The error warning only appears in the Thunderbird dkim extension but I can't imagine this would be too hard a fix to implement the appropriate line breaks instead of having the entire DKIM key on one line in the email source.

@carsonreinke
Copy link
Collaborator

I think you forgot the link. Mind attaching?

@JakeTheSnake3p0
Copy link
Author

Oops! Here you go: https://www.osso.nl/blog/thunderbird-postfix-dkim-invalid-body-hash/

I've logged into my spamdrain account and they say there's a problem as well. "Computed body hash is different from the expected one"

@JakeTheSnake3p0
Copy link
Author

The first header shown here is generated whenever I send emails from my email client (Thunderbird):

DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
    d=whatever.com; s=default; h=Content-Type:MIME-Version:Date:
    Message-ID:Subject:From:To:Reply-To;
    bh=FVAhhJz6FzTfjyLzFYYUDyyNxa/NB6YNmUG8BROFscA=; b=0560610thBwMn0khOFFm5yFW2r
    /iNutZkbdGoLExrE0riCcoRjShKiIV5bRtumlHj69kp+XAi5RjmUtcVqYF1xhyizuifuSwqTwDh9V
    afCUX/FTCv8TxglpBErRpIoGUrJPAJUVO9j7OO66SCW1yYHbWSu6UDpDyp1c7xWN/Fh9CpeQXnDM6
    zI5QW7MwJbufPrXVQ1V010X1o447R6OSuVaMDi16u3G50u9RUGNLqZa+6cPJwEXx6QZ7hVt32LK1I
    QUDU34VjzyHFrTjmanT4Lp3NDr6PAF2BKK5LWm8XkHpEmHcu3yr9V4RfrYu07XLzJUjTM2n5lXOPs
    ux/aEJeA==;

However this is an example of one sent from my rails app:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whatever.com; q=dns/txt; s=default; t=1446495573; bh=v+Gie+4nzghZzpOSiQC08piKoNeY/n4Q11yNcr/BPCM=; h=date:from:to:message-id:subject:mime-version:content-type:content-transfer-encoding; b=011109VB+ZbHcdo0JM4USctVg83vJvG9QKWlgn/bI8jwtI1LXdHg5f22huIxTwOruuh+6nXsRkBR/SMzTDQ5z1FnFbuYD0JbEW47X6Qu0ItMseZwBnkVNKsfP0Qxt3LbmPHsWhM1Rg3ne78tLq4OLBrs0J+fLMk2tRAHJ1JRWakP2hG8pg6FPEWjWKi3da5555TjVC0zg1osvwF1+l/QoruPZ+hoawKajG1LNY/Dub7xlGzDrJqtjxtvO+h7Iutk30y0MaiP7I3782uOJ+pAuBSQQBM8TEdisjkllymBT4skhSt+W2LjNiQBxCZtIS6mhAAuBK48FnOtMtC5v6QHhQ==

I modified the string so don't worry about its validity, I only illustrate the fact that the one sent from my email client has new lines and the one sent via the rails app is all on one line.

@carsonreinke
Copy link
Collaborator

I see what you mean. A lot of the clients wrap the header too. Let me see what I can find.

On Nov 3, 2015, at 9:36 AM, Jake Mitchell notifications@github.com wrote:

The first header shown here is generated whenever I send emails from my email client (Thunderbird):

DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;
d=sprucewoodshores.com; s=default; h=Content-Type:MIME-Version:Date:
Message-ID:Subject:From:To:Reply-To;
bh=FVAhhJz6FzTfjyLzFYYUDyyNxa/NB6YNmUG8BROFscA=; b=0560610thBwMn0khOFFm5yFW2r
/iNutZkbdGoLExrE0riCcoRjShKiIV5bRtumlHj69kp+XAi5RjmUtcVqYF1xhyizuifuSwqTwDh9V
afCUX/FTCv8TxglpBErRpIoGUrJPAJUVO9j7OO66SCW1yYHbWSu6UDpDyp1c7xWN/Fh9CpeQXnDM6
zI5QW7MwJbufPrXVQ1V010X1o447R6OSuVaMDi16u3G50u9RUGNLqZa+6cPJwEXx6QZ7hVt32LK1I
QUDU34VjzyHFrTjmanT4Lp3NDr6PAF2BKK5LWm8XkHpEmHcu3yr9V4RfrYu07XLzJUjTM2n5lXOPs
ux/aEJeA==;
However this is an example of one sent from my rails app:

DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sprucewoodshores.com; q=dns/txt; s=default; t=1446495573; bh=v+Gie+4nzghZzpOSiQC08piKoNeY/n4Q11yNcr/BPCM=; h=date:from:to:message-id:subject:mime-version:content-type:content-transfer-encoding; b=011109VB+ZbHcdo0JM4USctVg83vJvG9QKWlgn/bI8jwtI1LXdHg5f22huIxTwOruuh+6nXsRkBR/SMzTDQ5z1FnFbuYD0JbEW47X6Qu0ItMseZwBnkVNKsfP0Qxt3LbmPHsWhM1Rg3ne78tLq4OLBrs0J+fLMk2tRAHJ1JRWakP2hG8pg6FPEWjWKi3da5555TjVC0zg1osvwF1+l/QoruPZ+hoawKajG1LNY/Dub7xlGzDrJqtjxtvO+h7Iutk30y0MaiP7I3782uOJ+pAuBSQQBM8TEdisjkllymBT4skhSt+W2LjNiQBxCZtIS6mhAAuBK48FnOtMtC5v6QHhQ==
I modified the string so don't worry about its validity, I only illustrate the fact that the one sent from my email client has new lines and the one sent via the rails app is all on one line.


Reply to this email directly or view it on GitHub.

@carsonreinke
Copy link
Collaborator

Related Perl lib for the wrapping: http://search.cpan.org/~jaslong/Mail-DKIM/lib/Mail/DKIM/TextWrap.pm

@JakeTheSnake3p0
Copy link
Author

I'm not sure that this Perl lib is what I need as I'm using RoR/ActionMailer to generate my emails. This gem hooks into ActionMailer during the delivery process which happens outside of the scope of my app.

I tried forking your repo and figuring out at what point the headers are generated but I can't make heads or tails of how things come together. The wrapping would need to be done somewhere in this gem.

@carsonreinke
Copy link
Collaborator

Sorry for not clarifying, I just noted that as a reference to the Perl library which wraps the DKIM header. A new feature would be have to be added to provide the wrapping.

If you are using the interceptor, the header is actually added here: https://github.com/jhawthorn/dkim/blob/master/lib/dkim/interceptor.rb#L18

@cg2v
Copy link

cg2v commented Apr 18, 2016

I have a partial implementation of this feature at https://github.com/cg2v/dkim/tree/interceptor_wrap_dkim_header

It has no new tests, and fails the Dkim::InterceptorTest#test_same_output_as_direct_usage because I implemented the change in mail/dkim_field.rb and the output no longer matches.

@carsonreinke
Copy link
Collaborator

@cg2v Definitely throw that over to a PR and lets get that going!!! The test failure is probably just because of assertion is against an unwrapped header.

@cg2v
Copy link

cg2v commented Apr 22, 2016

It doesn't assert against a fixed result that includes an unwrapped header, but against a call to Dkim.sign that generates one. If most people use Dkim.sign, then you need a solution that works there too. I didn't touch that part because the mixture of data and presentation in the Dkim::Header classes makes this harder.

@oz
Copy link

oz commented Mar 29, 2021

🆙 Hey!

I know that time is a finite and precious resource, but can I get someone to look at this PR some time, or maybe the issue is a won't fix ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants