SignedCms.ComputeSignature [英] SignedCms.ComputeSignature

查看:121
本文介绍了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">

1 ContentInfo content = new ContentInfo(数据);
2 SignedCms signedMessage = new SignedCms(content);
3 CmsSigner signer = new CmsSigner(signingCert);
4 signedMessage .ComputeSignature(签名者);
5 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

1        ContentInfo content = new ContentInfo(data); 
2        SignedCms signedMessage = new SignedCms(content); 
3        CmsSigner signer = new CmsSigner(signingCert); 
4        signedMessage.ComputeSignature(signer); 
5        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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆