问题描述
嗨!
我有一个"真实的"来自CA的代码签名证书。 使用Visual Studio 2013,在我的项目的"签名"选项卡中,我可以从文件中加载它,并显示正确的信息。
I have a "real" code-signing certificate from a CA. Using Visual Studio 2013, in the "Signing" tab of my project, I can load it from a file, and the correct information is displayed.
然而,当我尝试构建我的项目,我得到:"签名时发生错误:指定了无效的提供者类型。"
However, when I attempt to build my project, I get: "An error occurred while signing: Invalid provider type specified."
另一个证据:如果我检查"签署程序集"并从列表中选择此证书,系统提示我输入私钥密码,然后出现错误:"找不到用于解密的证书和私钥"。
An additional piece of evidence: if I check "Sign the assembly" and select this certificate from the list, I am prompted for the private key password, and then I get an error: "Cannot find the certificate and private key for decryption".
帮助?
非常感谢!
- Lev
推荐答案
- >无法找到用于解密的证书和私钥
-->Cannot find the certificate and private key for decryption
从MSDN中的这篇文章:
https://msdn.microsoft.com/en-us/ library / aa730868(v = vs.80).aspx#rsvssign_topic3 ,你可以找到:
From this article in MSDN: https://msdn.microsoft.com/en-us/library/aa730868(v=vs.80).aspx#rsvssign_topic3, you could find this:
.pfx文件不能包含证书链信息。 (如果.pfx文件确实包含此信息,则会发生以下导入错误:" 无法找到用于解密的证书和私钥 。)
签名时,.pfx文件不能包含证书链接信息,如果你在.pfx文件中有,你可以删除链接信息通过运行证书管理器管理单元(Certmgr.msc)从密钥文件导入,将pfx文件导入
个人证书存储区,然后导出它而不包括证书链信息。执行以下操作。
When the signing, the .pfx file can't contain certificate chaining information, if you have it in the .pfx file, You can remove chaining information from the key file by running the Certificate Manager snap-in (Certmgr.msc), importing the pfx file into the personal certificate store, and then exporting it without including the certificate chain information. do the following.
- 在开始菜单上,点击运行,然后输入
mmc ,然后点击确定。将出现 Console1 对话框。 - 在文件菜单上,单击添加/删除管理单元。
将出现"添加/删除管理单元"对话框。 - 单击添加。将显示添加独立管理单元对话框。
- 单击证书,然后单击添加。将显示
证书管理单元对话框。 - 选择我的用户帐户,单击完成,然后单击
关闭,然后点击确定关闭对话框。 - 展开证书 - 当前用户,展开个人,然后展开
证书。 - 右键单击证书节点,然后从上下文菜单中选择
所有任务和导入。 - 出现"证书导入向导";点击下一步。
- 在要导入的文件步骤中,浏览并选择.pfx文件,然后点击
下一步. - 输入私钥密码信息,选中将此密钥标记为可导出选项,然后点击
下一步。 - 在证书存储步骤中,使用默认值放入个人证书存储区,单击
下一步,然后单击完成 。 - 证书现已导入并准备导出。选择并右键单击此证书,然后从上下文菜单中选择
所有任务和导出。 - 证书导出向导对话框出现;点击
下一步。 - 在导出私钥步骤中,选择是选项以导出私有键,然后点击
下一步。 - 在导出文件格式步骤中,确保选项包含证书路径中的所有证书未选中,请点击
下一步。 - 在密码步骤中,输入所需的密码信息,然后点击
下一步。 - 在要导出的文件步骤中,指定文件名,单击
下一步,然后单击完成。 - 这应显示导出成功对话框;点击
确定。
- On the Start menu, click Run, type mmc, and then click OK. The Console1 dialog box appears.
- On the File menu, click Add/Remove Snap-in.The Add/Remove Snap-in dialog box appears.
- Click Add. The Add Standalone Snap-in dialog box appears.
- Click Certificates, and then click Add. TheCertificates snap-in dialog box appears.
- Select My User account, click Finish, clickClose, and then click OK to close the dialog boxes.
- Expand Certificates - Current User, expand Personal and then expandCertificates.
- Right click on the Certificates node and from the context menu selectAll Tasks and Import.
- The Certificate Import Wizard appears; click Next.
- At the File to Import step, browse and select the .pfx file and then clickNext.
- Enter private key password information, check the option to mark this key as exportable, and then clickNext.
- At the Certificate Store step, go with the defaults to place into the Personal Certificate store, clickNext, and then click Finish.
- The certificate is now imported and ready for export. Select and right click on this certificate and, from the context menu, selectAll Tasks and Export.
- The Certificate Export Wizard dialog appears; click Next.
- At the Export Private Key step, select the option Yes to export the private key and then clickNext.
- At the Export File Format step, make sure the option to include all certificates in the certificate path is unchecked and clickNext.
- At the Password step, enter desired password information and clickNext.
- At the File to Export step, specify the file name, click Next, and then click Finish.
- This should display the export was successful dialog; click OK.
如果您对此问题有任何其他疑虑,请随时告诉我们。
If you have any other concern regarding this issue, please feel free to let me know.
最好的问候,
Youjun Tang
Best regards,
Youjun Tang
这篇关于使用真实证书签署ClickOnce清单时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!