无法导入密钥文件“blah.pfx" - 错误“密钥文件可能受密码保护" [英] Cannot import the keyfile 'blah.pfx' - error 'The keyfile may be password protected'

查看:89
本文介绍了无法导入密钥文件“blah.pfx" - 错误“密钥文件可能受密码保护"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们刚刚将 Visual Studio 2008 项目升级到 Visual Studio 2010.我们所有的程序集都使用 进行强签名Verisign 代码签名证书.自升级以来,我们不断收到以下错误:

We just upgraded our Visual Studio 2008 projects to Visual Studio 2010. All of our assemblies were strong signed using a Verisign code signing certificate. Since the upgrade we continuously get the following error:

无法导入以下密钥文件:companyname.pfx.密钥文件可能受密码保护.要更正此问题,请尝试再次导入证书或使用以下密钥容器名称手动将证书安装到强名称 CSP:VS_KEY_3E185446540E7F7A

Cannot import the following key file: companyname.pfx. The key file may be password protected. To correct this, try to import the certificate again or manually install the certificate to the Strong Name CSP with the following key container name: VS_KEY_3E185446540E7F7A

这种情况发生在一些开发人员机器上,而不是其他机器上.用于解决此问题的一些方法有时会奏效,包括:

This happens on some developer machines and not others. Some methods used to fix this that worked some of the time include:

  • 从 Windows 资源管理器重新安装密钥文件(右键单击 PFX 文件并单击安装)
  • 第一次在新机器上安装 Visual Studio 2010 会在您第一次打开项目时提示您输入密码,然后它就可以工作了.在从 Visual Studio 2008 升级的计算机上,您没有此选项.

我尝试使用 SN.EXE 实用程序(强Name Tool) 以使用强名称 CSP 注册密钥,如错误消息所示,但是每当我使用 Visual Studio 2010 随附的版本运行带有任何选项的工具时,SN.EXE 只会列出其命令行参数,而不是执行任何操作.无论我提供什么论据,都会发生这种情况.

I've tried using the SN.EXE utility (Strong Name Tool) to register the key with the Strong Name CSP as the error message suggests, but whenever I run the tool with any options using the version that came with Visual Studio 2010, SN.EXE just lists its command line arguments instead of doing anything. This happens regardless of what arguments I supply.

为什么会发生这种情况,有哪些明确的解决步骤?我即将放弃 ClickOnce 安装和 Microsoft 代码签名.

Why is this happening, and what are clear steps to fix it? I'm about to give up on ClickOnce installs and Microsoft code signing.

推荐答案

我也遇到了这个问题.我可以通过运行
sn -i 来解决这个问题.<ContainerName>(将密钥对安装到命名容器中).

I was running into this problem as well. I was able to resolve the issue by running
sn -i <KeyFile> <ContainerName> (installs key pair into a named container).

sn 通常作为 Windows SDK 的一部分安装.例如 C:Program Files (x86)Microsoft SDKsWindowsv8.0AinNETFX 4.0 Toolssn.exe.此位置很可能不在您的标准环境的搜索路径上.但是,Visual Studio 安装的开发人员命令提示符"添加了通常包含正确位置的附加信息.

sn is usually installed as part of a Windows SDK. For example C:Program Files (x86)Microsoft SDKsWindowsv8.0AinNETFX 4.0 Toolssn.exe. Most likely this location is not on the search path for your standard environment. However, the "Developer Command Prompt" installed by Visual Studio adds additional information that usually includes the correct location.

根据您的帖子看起来像

sn -i companyname.pfx VS_KEY_3E185446540E7F7A

这必须从您的 PFX 文件的位置运行,如果您在 VS 2010 中加载了解决方案,您只需右键单击解决方案资源管理器中的 pfx 文件,然后选择打开命令提示符,这将启动 .net 2010 cmd提示工具在正确的目录中.

This must be run from the location of your PFX file, if you have the solution loaded in VS 2010 you can simply right click on the pfx file from the solution explorer and choose Open Command Prompt which will launch the .net 2010 cmd prompt tool in the correct directory.

在运行此 sn 命令之前,我确实通过右键单击并选择安装来重新安装 pfx,但是这不起作用.需要注意的是,可能是两者的结合提供了解决方案.

Before running this sn command I did re-install the pfx by right clicking on it and choosing install however that did not work. Just something to note as it might be the combination of both that provided the solution.

希望这有助于解决您的问题.

Hope this helps solve your problem.

这篇关于无法导入密钥文件“blah.pfx" - 错误“密钥文件可能受密码保护"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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