【发布时间】:2016-10-22 04:21:41
【问题描述】:
我不太了解如何处理 PKCS#7 消息。
我用我拥有的 X509Certificate2 签署了一些字节数组,并获得了一个字节数组。
byte[] data = new byte[5] { 110, 111, 112, 113, 114 }, signedData;
X509Certificate2 cert = new X509Certificate2(certPath, password);
ContentInfo content = new ContentInfo(data);
SignedCms envelope = new SignedCms(content);
CmsSigner cmsSigner = new CmsSigner(cert);
envelope.ComputeSignature(cmsSigner);
signedData = envelope.Encode();
signedData 被传输到某个远程接收者,他得到了 SignedCms 信封。
SignedCms envelope = new SignedCms();
envelope.Decode(signedData);
他如何解码信封?他没有将我的公钥作为参数传递。信封中有我的公钥,在 SignerInfo 属性中,但有什么原因,因为任何人都可以用整个签名替换它吗?
收件人可以使用他拥有的我的公钥确定信封的实际发件人是我吗?
有envelope.CheckSignature(new X509Certificate2Collection(certificate), true);方法,但我尝试使用错误的证书,没有抛出异常。
【问题讨论】:
标签: c# digital-signature x509certificate2 pkcs#7