Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typo3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual studio 签名时出错:未能对file.exe进行签名。SignTool错误:未找到满足所有给定条件的证书_Visual Studio_Clickonce_Sign_Signtool - Fatal编程技术网

Visual studio 签名时出错:未能对file.exe进行签名。SignTool错误:未找到满足所有给定条件的证书

Visual studio 签名时出错:未能对file.exe进行签名。SignTool错误:未找到满足所有给定条件的证书,visual-studio,clickonce,sign,signtool,Visual Studio,Clickonce,Sign,Signtool,好吧,这真的很奇怪。我有一个TFS构建,它对一个文件进行了签名,我得到了上面的信息。如果我查看构建日志,它说它成功地对我的文件进行了签名并加上了时间戳,那么有一个.proj文件手动调用signtool,但在下面的另一个步骤中,我不确定具体在哪里-我假设是在ClickOnce签名中,我得到了错误 我可以使用与构建使用的参数相同的Signtool对文件进行签名,因此我认为可能需要导入证书,因此我打开了mmc,添加了证书管理单元,使用本地计算机安装了导入向导TFS build运行在与我不同的帐户下,我

好吧,这真的很奇怪。我有一个TFS构建,它对一个文件进行了签名,我得到了上面的信息。如果我查看构建日志,它说它成功地对我的文件进行了签名并加上了时间戳,那么有一个.proj文件手动调用signtool,但在下面的另一个步骤中,我不确定具体在哪里-我假设是在ClickOnce签名中,我得到了错误

我可以使用与构建使用的参数相同的Signtool对文件进行签名,因此我认为可能需要导入证书,因此我打开了mmc,添加了证书管理单元,使用本地计算机安装了导入向导TFS build运行在与我不同的帐户下,我不知道该帐户的密码,因此我认为在计算机级别安装它可以工作。我浏览了该文件,并在受信任的根证书颁发机构中成功导入了该文件,请参见以下内容:

但当我构建时仍然会出现错误。signtool是从TFS生成中调用的.proj文件调用的,但在ClickOnce期间生成会再次调用。通过VS屏幕导入证书后,我现在看到:

并获取以下错误:

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (2718): Unable to find code signing certificate in the current user’s Windows certificate store. To correct this, either disable signing of the ClickOnce manifest or install the certificate into the certificate store.
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (2718): Cannot import the following key file: . The key file may be password protected. To correct this, try to import the certificate again or import the certificate manually into the current user’s personal certificate store.
C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets (2718): Importing key file "les.pfx" was canceled.
证书与.csproj位于同一文件夹中,并且正在导入到存储中

Here's the cert info and the Thumbprint matches what's in the .csproj file:

你知道我在这里遗漏了什么吗?

根据错误消息,你必须将证书导入代理计算机的个人存储。当您从个人存储中引用证书时,它不会要求输入密码,因此您可以访问代码签名证书

如果使用ClickOnce生成多个项目,则必须将证书导入到每个项目中

请尝试使用Visual Studio命令提示符在生成代理计算机中导入证书:

单击开始→ 所有程序→ Microsoft Visual Studio→ Visual Studio 工具→ VisualStudio命令提示符。 键入以下命令示例:

sn -i "c:\Pathtofile\.pfx" VS_KEY_C1D3ACB8FBF1AGK4
注意:带有-i参数的sn.exe会将中的密钥对安装到名为的密钥容器中

将pfx文件重新导入Visual Studio。 您还可以尝试创建PowerShell脚本,并在生成定义中运行预生成脚本以导入证书

PowerShell脚本示例供您参考:

$pfxpath = 'pathtoees.pfx'
$password = 'password'

Add-Type -AssemblyName System.Security
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxpath, $password, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]"PersistKeySet")
$store = new-object system.security.cryptography.X509Certificates.X509Store -argumentlist "MY", CurrentUser
$store.Open([System.Security.Cryptography.X509Certificates.OpenFlags]"ReadWrite")
$store.Add($cert)
$store.Close()
参考以下线程:

最后一节介绍如何使用存储中的证书