如果您决定对您的代码进行签名,您需要以下工具:
- signcode.exe
- makecert.exe
- cert2spc.exe
- pvk2pfx.exe
这些工具最好的下载位置是什么?
有没有方法可以在不下载大量Microsoft Windows SDK的情况下完成签名?
如果您决定对您的代码进行签名,您需要以下工具:
这些工具最好的下载位置是什么?
有没有方法可以在不下载大量Microsoft Windows SDK的情况下完成签名?
首先需要从 Windows SDK 开始。那应该有你所需的大部分内容。
此外,SignCode.exe 已在 .NET 1.1 后弃用。 SignTool.exe 是替代方案。
一般来说,只有少数几个 SDK 工具可以在 Microsoft 的官方软件包之外进行重新分发。它们列在一个名为 redist.txt
的文件中。在我的系统上,在 %ProgramFiles%\Microsoft.NET\SDK\v2.0 64bit
中找到了一个 .NET SDK redist.txt
文件(我假设 x86 系统的文件夹名为“v2.0”)。以下是它的内容:
.NET Framework SDK files
根据软件许可条款, 以下 .EXE 文件可以未经修改地分发:
MageUI.exe Mage.exe Makecert.exe
因此,看起来大部分这些文件将无法进行再分发。所以,我的答案仍然是下载 Windows SDK。请记住,如果你愿意,可以仅安装部分工具;安装程序允许你选择/取消选择任何组件(例如,只有 .NET开发工具)。
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signtool.exe" sign /f cert.pfx /p password target.dll
- user285594我刚刚安装了Windows 8的Windows SDK,但是我仍然找不到SignTool.exe
或SignCode.exe
。
直到我意识到微软已经改变了安装路径。现在它被安装在以下某一个位置:
C:\Program Files (x86)\Windows Kits\8.1\bin\x64
C:\Program Files (x86)\Windows Kits\8.1\bin\x86
C:\Program Files (x86)\Windows Kits\8.0\bin\x64
C:\Program Files (x86)\Windows Kits\8.0\bin\x86
编辑 在Windows 10上,二进制文件可以在以下位置找到:
C:\Program Files (x86)\Windows Kits\10\bin\x86
我尝试了下面的方法,它可以工作,但是它不会获取到SignCode.exe(已被弃用并由SignTool.exe替换)
您可以通过安装Visual Studio安装中的C++ Windows开发工具(我的版本是古老的2005年版)来获取SignTool.exe。更多详细信息请参见Lindersoft.com。
如何将PFX/P12文件转换为SPC/PVK格式
导出带有私钥的证书。
使用以下选项的导出向导:
Export Private Key (Yes)
DO NOT TICK include all certificates in the certification path if possible
TICK enable strong protection
DO NOT TICK delete private key
前提条件:OpenSSL 0.9.8或更高版本。建议使用OpenSSL 1.x。
注意:如果您正在运行Windows操作系统,可以在此处下载OpenSSL。否则,您可以直接从OpenSSL网站获取已编译的二进制文件,或者查阅您的操作系统包管理功能。
私钥(PVK)
Extract your Private Key from the PFX/P12 file to PEM format.
openssl pkcs12 -in PFX_FILE -nocerts -nodes -out PEM_KEY_FILE
Note: The PFX/P12 password will be asked. This is the password you gave the file upon exporting it.
Convert PEM Private Key to PVK format.
OpenSSL 0.9.8 series:
pvk -in PEM_KEY_FILE -topvk -out PVK_FILE
OpenSSL 1.x series:
openssl rsa -in PEM_KEY_FILE -outform PVK -pvk-strong -out PVK_FILE
Note #1: In order to use pvk for OpenSSL 0.9.8 series, you must download PVK Transform.
Note #2: A PEM passphrase may be asked. This will be the password/passphrase that you will use to sign your code.
软件发行商证书(SPC)
Extract Certificate from P12/PFX file.
openssl pkcs12 -in PFX_FILE -nokeys -out CERT_PEM_FILE
Convert Certificate to SPC format.
openssl crl2pkcs7 -nocrl -certfile CERT_PEM_FILE -outform DER -out SPC_FILE
注意:如果您已经从IE之外的其他浏览器导出了您的证书,请确保在CERT_PEM_FILE中仅存在您的证书,否则代码签名将无法正常工作!
示例转换
PVK openssl pkcs12 -in my_pfx_file.pfx -nocerts -nodes -out rsa.pem openssl rsa -in rsa.pem -outform PVK -pvk-strong -out mykey.pvk
SPC openssl pkcs12 -in my_pfx_file.pfx -nokeys -nodes -out cert.pem openssl crl2pkcs7 -nocrl -certfile cert.pem -outform DER -out cert.spc
这些信息由Komodo提供。
我相信前三个是.NET Framework SDK的一部分,而最后一个则在Windows Driver Kit中。
我找不到一个文件清单,列出pvk2pfx.exe作为平台SDK(现在显然是Windows SDK)的一部分,但那是我最初认为它来自的地方。
步骤1:下载:
http://download.microsoft.com/download/A/6/A/A6AC035D-DA3F-4F0C-ADA4-37C8E5D34E3D/winsdk_web.exe
或者
http://www.microsoft.com/en-us/download/details.aspx?id=8279
步骤二:
C:\Users\user1>"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\signto
ol.exe"