首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在.NET 4中,在根目录中插入证书(带有私有密钥),LocalMachine证书存储失败

在.NET 4中,在根目录中插入证书(带有私有密钥),LocalMachine证书存储失败
EN

Stack Overflow用户
提问于 2010-09-02 17:07:58
回答 6查看 24.1K关注 0票数 18

我在本地计算机的根证书存储中插入带有privatekey的新CA证书时遇到问题。

这就是发生的事情:

//This doesn't help either.
new StorePermission (PermissionState.Unrestricted) { Flags = StorePermissionFlags.AddToStore }.Assert();
var store = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
privkey.PersistKeyInCsp = true;
//This shouldn't be necessary doesn't make a difference what so ever.
RSACryptoServiceProvider.UseMachineKeyStore = true;
cert.PrivateKey = privkey;
store.Open (OpenFlags.MaxAllowed);
store.Add (cert);
store.Close ();

插入证书后,一切看起来都很棒:(请参见!)

注意: is说它有一个私有密钥。

所以你会说你可以用FindPrivateKey找到它

C:\Users\Administrator\Desktop>FindPrivateKey.exe Root LocalMachine -t "54 11 b1 f4 31 99 19 d3 5a f0 5f 01 95 fc aa 6f 71 12 13 eb"
FindPrivateKey failed for the following reason:
Unable to obtain private key file name

Use /? option for help 

很可爱..。但这是错误的!!(2只愚蠢的狗参考)

证书导出对话框给出了一条非常好的消息:

在使用以下代码片段模拟管理员时运行此代码:click here

我只想知道为什么?

(在Windows Server2008 R2和Windows7上测试)

我会被诅咒的!

当我把它编译成v3.5时,它就能工作了!

该怎么办呢?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3625624

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档