Create a PKCS#7 signed message in c# with a precomputed signature

我们两清 提交于 2019-12-06 05:26:45

AFAIK you cannot do that with "built-in" .NET classes.

However I have created an example application - Pkcs7SignatureGenerator - for CMS signature creation with Pkcs11Interop (which I am author of) and Bouncy Castle libraries.

In this application Pkcs11Interop library performs signing operation via PKCS#11 API with the private key stored in the hardware device and BouncyCastle library is responsible for construction of a CMS (PKCS#7) signature structure.

I think what you want is the X509Certificate2 class, use the static CreateFromSignedFile function to retrieve the certificate from the signed file, or use CreateFromCertFile to create from the specified certification file:

X509Certificate2 cert = X509Certificate2.CreateFromSignedFile(filename);
CmsSigner signer = new CmsSigner(cert);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!