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

DKIM relaxed body canonicalization #190

Closed
breedbekkikker opened this issue Nov 26, 2015 · 10 comments
Closed

DKIM relaxed body canonicalization #190

breedbekkikker opened this issue Nov 26, 2015 · 10 comments
Labels
bug Something isn't working

Comments

@breedbekkikker
Copy link

DKIM relaxed body canonicalization must "Ignore all whitespace at the end of lines. Implementations MUST NOT remove the CRLF at the end of the line.". This doesn't work anymore since commit 71abff2

Body test case:

test[CR][LF]
[SP][CR][LF]
test[CR][LF]

This must be canonicalized to:
test[CR][LF]
[CR][LF]
test[CR][LF]

@jstedfast jstedfast added the bug Something isn't working label Nov 29, 2015
@jstedfast
Copy link
Owner

This should be fixed now

@jstedfast
Copy link
Owner

I've released MimeKit 1.2.16 to NuGet with a fix for this.

@breedbekkikker
Copy link
Author

Thanks! Unfortunately, in some cases the body hash is still not correct. By adding an extra condition it seems to work.

Old code:

                if (*inptr == (byte)'\r' && (inptr + 1) < inend && *(inptr + 1) == (byte)'\n')

New code:

                if (*inptr == (byte)'\r' && (inptr + 1) == inend)
                {
                    if (!IsEmptyLine)
                    {
                        *outptr++ = *inptr;
                        lwsp = false;
                        count++;
                    }
                }
                else if (*inptr == (byte)'\r' && (inptr + 1) < inend && *(inptr + 1) == (byte)'\n')

@jstedfast
Copy link
Owner

is your message body ending with a \r?

@jstedfast
Copy link
Owner

never mind, this can happen if the \r\n is split across buffer boundaries.

@jstedfast
Copy link
Owner

This should now be fixed in git master.

@breedbekkikker
Copy link
Author

Thanks, the fix in git master works!

@jstedfast
Copy link
Owner

ok, I'll probably try to make another release this weekend then.

@jstedfast
Copy link
Owner

I've published 1.3.0-beta (I had to publish a beta because I've added dnxcore50 support which requires beta packages), so you can either install that nuget or a "hidden" MimeKit 1.2.17.2 nuget which is the same thing, but contains an incomplete list of dnxcore50 dependencies to get around needing to mark it as a beta.

@jstedfast
Copy link
Owner

I just published a non-hidden 1.2.17.3 nuget with this fix so you don't have to tell VS to allow pre-release nugets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants