0

以下用于签名的电子邮件示例的正文部分是什么?

------=_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)

这意味着它会为电子邮件正文的错误部分计算哈希值。

4

1 回答 1

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))
于 2012-09-19T11:29:51.833 回答