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 Verify issue in relaxed mode #38

Closed
mschneider82 opened this issue Nov 20, 2020 · 0 comments
Closed

DKIM Verify issue in relaxed mode #38

mschneider82 opened this issue Nov 20, 2020 · 0 comments

Comments

@mschneider82
Copy link

I have a verify issue with mails coming from gmail with attachments, i have cheked the mail with opendkim and other dkim libararys they Passed, but with go-msgauth i get body hash missmatch.

I have debugged it. Sometimes it happens that in the relaxedBodyCanonicalizer produces a \r\r\n which is written to the writer:

00000000: 6b48 4f53 636b 6748 3037 5662 4b4d 6557  kHOSckgH07VbKMeW
00000010: 424a 4841 2b59 6a41 4234 7750 3839 616e  BJHA+YjAB4wP89an
00000020: 4344 4751 7135 4743 5431 344a 347a 3655  CDGQq5GCT14J4z6U
00000030: 7853 356c 6370 7648 7642 3373 6f5a 6944  xS5lcpvHvB3soZiD
00000040: 792f 4848 6334 2b76 5370 5869 0d0d 0a    y/HHc4+vSpXi...
                                        ^--- \r\r \n

When i do a hotfix at the end of the Write() function:

func (c *relaxedBodyCanonicalizer) Write(b []byte) (int, error) {
...
	if bytes.ContainsAny(canonical, "\r\r\n") {
		canonical = bytes.ReplaceAll(canonical, []byte("\r\r\n"), []byte("\r\n"))
	}
	_, err := c.w.Write(canonical)
	return written, err
}

the checksum is Valid! i think the fixCRLF() should be different in relaxed Mode I have attached a PR to fix this issue

mschneider82 added a commit to mschneider82/go-msgauth that referenced this issue Nov 20, 2020
emersion added a commit that referenced this issue Nov 24, 2020
emersion added a commit that referenced this issue Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant