如何正确签署可执行文件

joe*_*joe 3 c# uac visual-studio-2010 digital-signature

所以我做了一个小工具,一个控制台应用程序,当在Win7上运行时带来了安全盒(UAC).我尝试使用以下步骤在VS 2010中签署此EXE文件:

1-项目属性
2-签名
3-创建新密钥,如下所示

在此输入图像描述

密钥文件已成功创建,您可以在下面的捕获中看到.

在此输入图像描述

问题:

文件仍然被安全框阻止,当我使用signtool.exe检查文件是否签名时,它告诉我,没有找到签名.如果我遵循了错误的步骤,请纠正我.

在此输入图像描述

spe*_*der 7

大会签名!= Authenticode签名.

要使用signtool为authenticode签名程序集,您需要来自受信任的颁发机构的代码签名证书.

然后,您可以发出以下post-build命令来签署可执行文件:

"signtool.exe" sign /f "$(SolutionDir)myCertificate.pfx" /p certPassword /d "description" /du "http://myinfourl" /t "http://timeserver.from.cert.authority/" $(TargetPath)
Run Code Online (Sandbox Code Playgroud)

关于Authenticode代码签名您需要了解的一切

  • 工作得很好,而且上面的命令中许多参数都是可选的。这就是我使用的:signtool sign /f MyCert.pfx /p MyPassword MyApp.exe (2认同)
  • 没有 GUI 方法可以做到这一点吗? (2认同)

PPa*_*ann 7

基本上你有 2 个选项,使用你手动执行或通过批处理文件执行的命令

signtool.exe sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /f "D:\Source\Certificates\CodeSign.pfx" /as /p MyPassword "{path to exe}"
Run Code Online (Sandbox Code Playgroud)

一段时间后变得有点令人沮丧 最好将它添加到 Build Events 的项目选项页面上。

在您的帖子构建中,您将输入

call "C:\Program Files (x86)\Windows Kits\10\bin\x64\signtool.exe" sign /tr http://timestamp.digicert.com /td sha256 /fd sha256 /f "D:\Source\Certificates\CodeSign.pfx" /p MyPassword  $(TargetPath)
Run Code Online (Sandbox Code Playgroud)

$(TargetPath)将填充您编译的 exe 或 dll 的路径。

现在每次编译时都会得到一个签名文件。

看起来像这样: 项目属性页