System.Security.Cryptography.Pkcs.EnvelopedCms.GetCspParams return 异常 "Cannot find object or property."
System.Security.Cryptography.Pkcs.EnvelopedCms.GetCspParams return exception "Cannot find object or property."
我在尝试解密文件时遇到异常:
var encData = File.ReadAllBytes(encFile);
var file = File.ReadAllBytes(encFile);
ContentInfo cinf = new ContentInfo(file);
var ec = new EnvelopedCms(cinf);
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
ec.Decode(encData);
ec.Decrypt(store.Certificates);
我完全知道 List store.Certificates
中存在适当的证书,为什么会抛出异常?
这段代码在我添加那个新证书之前就已经工作了,除了散列算法之外与以前没有区别...
更新:完全调用堆栈异常是
at System.Security.Cryptography.Pkcs.EnvelopedCms.GetCspParams(RecipientInfo recipientInfo, X509Certificate2Collection extraStore, CMSG_DECRYPT_PARAM& cmsgDecryptParam)
at System.Security.Cryptography.Pkcs.EnvelopedCms.DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection extraStore)
at System.Security.Cryptography.Pkcs.EnvelopedCms.Decrypt(X509Certificate2Collection extraStore)
此异常的原因 - 不支持哈希算法 - 在俄罗斯标准 GOST R 34.11-2012 或 STREEBOG 中定义。所以因为我有 CryptoPro 许可证,所以我使用 cryptcp.exe 和命令行参数 ...
我在尝试解密文件时遇到异常:
var encData = File.ReadAllBytes(encFile);
var file = File.ReadAllBytes(encFile);
ContentInfo cinf = new ContentInfo(file);
var ec = new EnvelopedCms(cinf);
X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser);
store.Open(OpenFlags.ReadOnly);
ec.Decode(encData);
ec.Decrypt(store.Certificates);
我完全知道 List store.Certificates
中存在适当的证书,为什么会抛出异常?
这段代码在我添加那个新证书之前就已经工作了,除了散列算法之外与以前没有区别...
更新:完全调用堆栈异常是
at System.Security.Cryptography.Pkcs.EnvelopedCms.GetCspParams(RecipientInfo recipientInfo, X509Certificate2Collection extraStore, CMSG_DECRYPT_PARAM& cmsgDecryptParam)
at System.Security.Cryptography.Pkcs.EnvelopedCms.DecryptContent(RecipientInfoCollection recipientInfos, X509Certificate2Collection extraStore)
at System.Security.Cryptography.Pkcs.EnvelopedCms.Decrypt(X509Certificate2Collection extraStore)
此异常的原因 - 不支持哈希算法 - 在俄罗斯标准 GOST R 34.11-2012 或 STREEBOG 中定义。所以因为我有 CryptoPro 许可证,所以我使用 cryptcp.exe 和命令行参数 ...