jhermsmeier / node-dkim

DomainKeys Identified Mail
MIT License
10 stars 11 forks source link

dkim.verify does not work with a raw email? #3

Closed niftylettuce closed 6 years ago

niftylettuce commented 6 years ago

I have a raw email and convert to buffer Buffer.from(rawEmail) and then pass it to dkim.verify but the dkim verification ALWAYS fails with No key for signature even though it has a valid DKIM signature

I was using validateDKIM here https://github.com/Flolagale/mailin/blob/fac7dcf59404691e551568f987caaaa464303b6b/lib/mailUtilities.js#L27 but that didn't work for google dkim

niftylettuce commented 6 years ago

should we do this automatically? https://github.com/jhermsmeier/node-dkim/blob/master/test/verify.js#L35

niftylettuce commented 6 years ago

the latest gmail spec does not work:

module.exports = `Content-Type: multipart/alternative;
 boundary="----sinikael-?=_1-15097293326030.8790521511927161"
Received: by mail-vk0-f48.google.com with SMTP id q13so2195896vkb.2 for
 <hello@niftylettuce.com>; Fri, 03 Nov 2017 10:15:32 -0700 (PDT)
Received: by 10.176.72.115 with HTTP; Fri, 3 Nov 2017 10:15:30 -0700 (PDT)
DKIM-Signature: v=1
X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net;
 s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=KcD4oIIrgFCidqyrgl9u6/mzsGKJpGvroqWqRp25fXs=;
 b=pK+npxPQSR5fV4T2KrbYFa8HKL/xzYgWaVNh8AmBf8q3c8gGkEDVuSo708/3eu9gx2
 8UJTgErJ/kdoKX+sSynU9MTJb+/Hi3O8Xj7O3dEulg8pd1ujJLIPEb9W92x1URgJZehK
 +Xkqieqo+Zdmur2eVNa5JpjKqdHHjGOoX9OpKnHmiVSRez0+jl/I2+0l/4GVV+TfCJNX
 C95KSalFgBFS8jv0iZh46+RSXP3iTM6hCNUw0gMmqdnpnkmQ3HRlSN0QamK2hggM04q5
 1afGZkpj/pSAza16IuwssmKUYO1lzSA7n52OxzSmW9hGsNwq7pGGNljy2F6zm41eSONQ
 GOVw==
X-Gm-Message-State:
 AMCzsaWdhaejPqrKQn5AfEEq+mpxpNo44DZ1cNaVuOvzUMjHAEdcWBsA
 u79V2yHKIGa71urBvIiKPtF07cHyFkeS3UQ4rxwpyQ==
X-Google-Smtp-Source:
 ABhQp+S+VA0QpTCMduDKS1GV2+U3npBzQPSpICTrKfFCIZHrvMJdVezHoMFCzhHbTahtSYChkDFgJtYnW/sLBzjY99c=
X-Received: by 10.31.151.21 with SMTP id z21mr5839864vkd.44.1509729331071;
 Fri, 03 Nov 2017 10:15:31 -0700 (PDT)
MIME-Version: 1.0
Content-Type: multipart/alternative;
 boundary="----sinikael-?=_1-15097293326030.8790521511927161"
From: Nick Baugh <niftylettuce@gmail.com>
To: hello@niftylettuce.com
Subject: another test
Message-ID:
 <CAERgpL=9T18SCg4nagGPwusC5vhfLVvD4POFQeeLhW4-a8ub+A@mail.gmail.com>
Date: Fri, 03 Nov 2017 17:15:30 +0000

------sinikael-?=_1-15097293326030.8790521511927161
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

test

--
@niftylettuce

------sinikael-?=_1-15097293326030.8790521511927161
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">test<br clear=3D"all"><div><br></div>-- <br><div =
class=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div =
dir=3D"ltr"><div><div dir=3D"ltr"><div>@niftylettuce</div></div></div></div=
></div>
</div>

------sinikael-?=_1-15097293326030.8790521511927161--

`;
niftylettuce commented 6 years ago

nevermind it was how I was parsing headers that caused it to format incorrectly