【发布时间】:2019-12-02 11:54:43
【问题描述】:
我们正在尝试使用 MimeKit 来验证数字签名的电子邮件 (.p7m) 签名。当我调用signature.Verify(); 时,它会抛出错误消息:
{"验证数字签名失败:非空集 必需\r\n参数名称:值"}。
但同一封邮件已被 Limilabs.Mail 成功验证。
我正在使用下面的代码来验证签名。
if (message.Body is MultipartSigned)
{
var signed = (MultipartSigned)message.Body;
foreach (var signature in signed.Verify())
{
try
{
bool valid = signature.Verify();
// If valid is true, then it signifies that the signed content
// has not been modified since this particular signer signed the
// content.
// However, if it is false, then it indicates that the signed
// content has been modified.
}
catch (DigitalSignatureVerifyException)
{
// There was an error verifying the signature.
}
}
}
任何人都可以帮助我解决为什么我收到错误吗?
【问题讨论】:
-
安全性有很多选择。您可能对 32 位和 64 位加密模式有疑问。请参阅:en.wikipedia.org/wiki/Transport_Layer_Security
-
除了
Message属性之外,还有更多的异常。异常的类型是什么?StackTrace是什么?什么是 InnerException 类型/消息/堆栈跟踪? -
您将哪种类型的 SecureMimeContext 注册为默认值? WindowsSecureMimeContext?还是 DefaultSecureMimeContext?还是别的什么?
-
我得到了 DigitalSignatureVerifyException,内部异常是 System.ArgumentException。内部异常消息是“需要非空集\r\n参数名称:值”
-
堆栈跟踪——在 Org.BouncyCastle.Pkix.PkixParameters.SetTrustAnchors(ISet tas) 在 Org.BouncyCastle.Pkix.PkixParameters..ctor(ISet trustAnchors) 在 Org.BouncyCastle.Pkix.PkixBuilderParameters。 .ctor(ISet trustAnchors, IX509Selector targetConstraints) 在 MimeKit.Cryptography.BouncyCastleSecureMimeContext.BuildCertPath(HashSet 锚点, IX509Store 证书, IX509Store crls, X509Certificate 证书, DateTime signingTime) 在 MimeKit.Cryptography.BouncyCastleSecureMimeContext.
d__29.MoveNext()跨度>
标签: c# cryptography smime mimekit mime-mail