以下用于签名的电子邮件示例的正文部分是什么?
------=_NextPart_000_005C_01CD9649.B405A420
Content-Type: multipart/alternative;
boundary="----=_NextPart_001_005D_01CD9649.B405A420"
------=_NextPart_001_005D_01CD9649.B405A420
Content-Type: text/plain;
charset="iso-8859-2"
Content-Transfer-Encoding: 7bit
test
------=_NextPart_001_005D_01CD9649.B405A420
Content-Type: text/html;
charset="iso-8859-2"
Content-Transfer-Encoding: quoted-printable
<html>
.....
</html>
------=_NextPart_001_005D_01CD9649.B405A420--
------=_NextPart_000_005C_01CD9649.B405A420
我正在使用C#电子邮件库,对于多部分/替代电子邮件,在调用时会出现错误“哈希值不正确”:
Smime.CheckSignature(true)
这意味着它会为电子邮件正文的错误部分计算哈希值。
答案 0 :(得分:1)
所以,经过几个小时的尝试,这就是答案:
------=_NextPart_000_005C_01CD9649.B405A420
*Content-Type: multipart/alternative;
*boundary="----=_NextPart_001_005D_01CD9649.B405A420"
*
*
*------=_NextPart_001_005D_01CD9649.B405A420
*Content-Type: text/plain;
*charset="iso-8859-2"
*Content-Transfer-Encoding: 7bit
*
*test
*
*
*------=_NextPart_001_005D_01CD9649.B405A420
*Content-Type: text/html;
*charset="iso-8859-2"
*Content-Transfer-Encoding: quoted-printable
*
*<html>
*.....
*</html>
*------=_NextPart_001_005D_01CD9649.B405A420--
*
------=_NextPart_000_005C_01CD9649.B405A420
以*开头的行是要进行哈希处理的消息体(字符串toDigest)。最后包括新行!所以就在这里:
Smime = new SignedCms(new ContentInfo(Encoding.ASCII.GetBytes(toDigest))