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

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

问题描述

我们刚刚将Visual Studio 2008项目升级到了Visual Studio2010.我们所有的程序集均使用进行了严格签名. 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 实用程序(强名称工具),以按照错误消息的提示向强名称" 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 <KeyFile> <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 SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.exe.此位置很可能不在您的标准环境的搜索路径中.但是,Visual Studio安装的开发人员命令提示符"会添加通常包含正确位置的其他信息.

sn is usually installed as part of a Windows SDK. For example C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\sn.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.

基于您的帖子,看起来像

Based on your post that would look like

sn -i companyname.pfx VS_KEY_3E185446540E7F7A

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并选择install来重新安装了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天全站免登陆