我有一个附件存储在数据库中,附件名为smime.p7m,name类型为multipart/signed。我现在需要从签名的p7m文件中提取附件,我希望我可以使用Mimekit来实现这一点。我尝试过以下几种方法:
CryptographyContext.Register(typeof(WindowsSecureMimeContext));
try
{
using (MemoryStream ms = new MemoryStream(buf))
{
ApplicationPkcs7Mime p7m = new ApplicationPkcs7Mime(SecureMimeType.EnvelopedData, ms);
p7m.Verify(out attachment);
builder.Attachments.Add(attachment);
}
}
catch (Exception ex)
{
log.Error("Exception in smime", ex);
}但它会失败,并在验证线上显示System.InvalidOperationException。
有什么想法吗?
发布于 2020-10-21 22:49:26
SecureMimeType.EnvelopedData用于加密数据,而不是签名数据。您需要使用SecureMimeTYpe.SignedData。
https://stackoverflow.com/questions/64449084
复制相似问题