我尝试过通过一个X509Certificate RsaPrivateCrtKeyParameters+ .NET X509Certificate2 + RSACryptoServiceProvider实例导入一个基于Bouncy城堡的.NET实例,并将其保存到证书存储中(.NET的X509Store,My/CurrentUser)。
在证书存储MMC管理单元中,似乎有一个与证书相关联的私钥,并且我已经验证在磁盘上的适当位置创建了一个新的密钥容器,但是当我试图导出证书时,我得到了令人生畏的“注意:找不到关联的私钥。只能导出证书”消息。
如果我运行certutil -user -repairstore我的拇指指纹,我会得到以下错误:
错误:证书公钥与存储的密钥集不匹配
从它发出的其他信息中,我可以清楚地看到公钥不同,算法参数在证书公钥上等于"05 00“,而在容器公钥上则不是。
事实上,我不知道有一个容器公钥的概念,所以我现在非常困惑。有人有这样做的工作代码吗?
发布于 2015-11-16 17:07:31
我在Cabadam的回答中找到了解决方案:https://social.msdn.microsoft.com/Forums/vstudio/en-US/ad01b2eb-1890-431a-86ae-e5da0e02b5b0/cryptographicexception-key-does-not-exist-when-attempting-to-connect-to-remote-service
RSACryptoServiceProvider tempRcsp = (RSACryptoServiceProvider)DotNetUtilities.ToRSA((RsaPrivateCrtKeyParameters)keyPair.Private);
RSACryptoServiceProvider rcsp = new RSACryptoServiceProvider(new CspParameters(1, "Microsoft Strong Cryptographic Provider", new Guid().ToString(), new CryptoKeySecurity(), null));
rcsp.ImportCspBlob(tempRcsp.ExportCspBlob(true));
dotnetCertificate2.PrivateKey = rcsp;
// Save the certificate to the X509Storehttps://stackoverflow.com/questions/33736604
复制相似问题