SignedCms.ComputeSignature [英] SignedCms.ComputeSignature
问题描述
你好,
我写了一个小程序来签名和加密文件。在x86上一切正常,但在x64上我得到了
System.Security.Cryptography.CryptographicException:找不到证书和解密私钥。
在System.Security.Cryptography。 Pkcs.PkcsUtils.CreateSignerEncodeInfo(CmsSigner签名者,布尔静默)
System.Security.Cryptography.Pkcs.SignedCms.Sign(CmsSigner签名者,布尔静默)
System.Security.Cryptography.Pkcs.SignedCms.ComputeSignature( CmsSigner signer,Boolean silent)
关键代码是
-family:Courier New; font-size:11px">
| ContentInfo content = new ContentInfo(数据); |
| SignedCms signedMessage = new SignedCms(content); |
| CmsSigner signer = new CmsSigner(signingCert); |
| signedMessage .ComputeSignature(签名者); |
| byte [] signedBytes = signedMessage.Encode(); |
CreateSignerEncodeInfo()是一个P / Invokes的.NET方法本机CryptoAPI功能可以完成工作。您获得的异常表明64位Windows本机加密支持功能有问题。究竟是什么问题很难找到。我不羡慕你的问题。
Hello,
i've written a small program to sign and encrypt files. On x86 everything works fine, but on x64 I get
System.Security.Cryptography.CryptographicException: The certificate and the private key for decryption were not found.
at System.Security.Cryptography.Pkcs.PkcsUtils.CreateSignerEncodeInfo(CmsSigner signer, Boolean silent)
at System.Security.Cryptography.Pkcs.SignedCms.Sign(CmsSigner signer, Boolean silent)
at System.Security.Cryptography.Pkcs.SignedCms.ComputeSignature(CmsSigner signer, Boolean silent)
The critical code is
ContentInfo content = new ContentInfo(data); | |
SignedCms signedMessage = new SignedCms(content); | |
CmsSigner signer = new CmsSigner(signingCert); | |
signedMessage.ComputeSignature(signer); | |
byte[] signedBytes = signedMessage.Encode(); |
CreateSignerEncodeInfo() is a .NET method that P/Invokes to the native CryptoAPI functions to get the job done. The exception you are getting is indicating that there's something wrong with the 64-bit Windows native cryptography support functions. What exactly is wrong is going to be hard to find out. I don't envy your problem.
这篇关于SignedCms.ComputeSignature的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!