C# 缺少“管理私钥”选项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14337947/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'MANAGE PRIVATE KEYS' option missing
提问by Alex
I'm developing WCF service with Transport Security hosted on IIS 7.5 under Windows 2008R2. I have a certificate, generated in IIS 7.5 which is stored in Local folder.
我正在 Windows 2008R2 下的 IIS 7.5 上开发带有传输安全性的 WCF 服务。我有一个在 IIS 7.5 中生成的证书,该证书存储在本地文件夹中。
When I use BasicHttpBinding or WSHttpBinding with Transport Security - everything works fine. But when I change it to NetTcp I get an exception :
当我将 BasicHttpBinding 或 WSHttpBinding 与传输安全结合使用时 - 一切正常。但是当我将其更改为 NetTcp 时,出现异常:
CryptographicException 'Keyset does not exist'.
After a bit of googling I found out that the problem can be because my NETSERVICE IIS account doesn't have premission to the private key of my certificate.
经过一番谷歌搜索后,我发现问题可能是因为我的 NETSERVICE IIS 帐户对我的证书的私钥没有权限。
The solution could be to set the rights to accesss in MMC by right-clicking on my certificate and selecting "MANAGE PRIVATE KEYS" option. But there is no such option in the select menu!!! The Certificate was created under administrator account and where I open it - it says, that it has private key. What I'm I doing wrong?
解决方案可能是通过右键单击我的证书并选择“管理私钥”选项来设置 MMC 中的访问权限。但是选择菜单里没有这个选项!!!证书是在管理员帐户和我打开它的地方创建的 - 它说,它有私钥。我做错了什么?
回答by kbeal2k
I had this same problem (Manage Private Keys option missing). In order to get it to appear I had to add the Certificates snap-in using the "Computer account" option instead of the default "My user account"
我遇到了同样的问题(缺少管理私钥选项)。为了让它出现,我必须使用“计算机帐户”选项而不是默认的“我的用户帐户”添加证书管理单元
回答by Manish Jain
Go to server -> click Start -> Run -> type mmc -> enter -> select Certificates snap-in with Local Computer option -> Go to Console Root-> Certificates-> Personal-> Certificates-> Select a cert-> Right click-> Go to All tasks-> Manage Private Keys-> Add permissions
转到服务器 -> 单击开始 -> 运行 -> 键入 mmc -> 输入 -> 选择带有本地计算机选项的证书管理单元 -> 转到控制台根目录 -> 证书 -> 个人 -> 证书 -> 选择一个证书 ->右键单击-> 转到所有任务-> 管理私钥-> 添加权限
回答by Divisadero
There can be one other problem, so I will mention it. Except -pe
argument when creating a certificate using makecert.exe, be sure you are importing the .pfx
file, not the .cer
. If there is not a .pfx
file, use an additional tool such as pvk2pfx.exe
to created.
可能还有一个问题,所以我会提到它。除了-pe
使用 makecert.exe 创建证书时的参数外,请确保您导入的是.pfx
文件,而不是.cer
. 如果没有.pfx
文件,请使用其他工具,例如pvk2pfx.exe
创建。
回答by Dev
Manage Private Keys option was missing when I first tried adding the certificates. Finally corrected it by following two steps.
当我第一次尝试添加证书时,缺少管理私钥选项。最后通过以下两个步骤纠正它。
Ran MMC as an administrator. File-> Add or remove Snap-ins-> Select Certificates -> Click on Add button.This will open a dialog. This snap-in will always manage certificate for : choose Computer account. Select the computer you want this snap-in to manage : choose Local computer. Click Finish. Click ok.
When you import the certificates(All tasks -> Import) in the Personal Folder, Make sure you are importing the .pfx file and NOT the .cer file.
以管理员身份运行 MMC。文件-> 添加或删除管理单元-> 选择证书-> 单击添加按钮。这将打开一个对话框。此管理单元将始终管理以下证书:选择计算机帐户。选择您希望此管理单元管理的计算机:选择本地计算机。单击完成。单击确定。
当您在个人文件夹中导入证书(所有任务 -> 导入)时,请确保您导入的是 .pfx 文件而不是 .cer 文件。
回答by I say Reinstate Monica
The Manage Private Keys Option is only available for certificates with an exportable private key
管理私钥选项仅适用于具有可导出私钥的证书
In my case, I experienced this problem despite configuring the Certificates snap-in to access the COMPUTER account. Further, the suggestion to get a .PFX certificate in this answerisn't an option for me.
就我而言,尽管配置了证书管理单元以访问计算机帐户,但我还是遇到了这个问题。此外,在这个答案中获得 .PFX 证书的建议对我来说不是一个选择。
I solved the problem by specifying that the private key be exportable when creating the certificate request (which I'm doing via the Certificates MMC snap-in):
我通过在创建证书请求时指定私钥可导出来解决这个问题(我通过证书 MMC 管理单元执行此操作):
Even though the certificate I got back from the public CA was a .CER
file, the Manage Private Keys menu option was available for it. I don't know a lot about certificates, but I conclude that the menu option only appears when the private key can be exported. In light of this answer, perhaps certificates in the .PFX format alwaysallow this to be done. Nonetheless, it's good to know it's possible for other certificate formats.
尽管我从公共 CA 取回的证书是一个.CER
文件,但“管理私钥”菜单选项可用于它。我对证书了解不多,但我得出的结论是,只有在可以导出私钥时才会出现菜单选项。根据这个答案,也许 .PFX 格式的证书总是允许这样做。尽管如此,很高兴知道其他证书格式是可能的。
回答by user1511340
- Open the Command Prompt (Run as Administrator)
- Enter and execute command,
certutil-repairstore my "thumbprint" (replace thumbprint with the 32 characters) - If succesful, you will recieve message,
certUtil: -repairstore command completed successfully.
- 打开命令提示符(以管理员身份运行)
- 输入并执行命令,
certutil-repairstore my "thumbprint"(用 32 个字符替换指纹) - 如果成功,您将收到消息,
certUtil:-repairstore 命令已成功完成。
回答by Igor Levicki
In Windows 10 1809, it seems that the Manage Private Keysoption is available only to certificates in the Personal store. The workaround is to drag and drop the certificate there, add permissions as needed and drag it back to where you need it.
在 Windows 10 1809 中,似乎“管理私钥”选项仅适用于个人存储中的证书。解决方法是将证书拖放到那里,根据需要添加权限并将其拖回您需要的位置。