在基于Linux的发行版上签署Windows应用程序

Tom*_*iak 23 linux windows exe sign certificate

我准备了一个应用程序和网站,客户可以在下载之前为此应用程序设置多个选项.设置以二进制格式存储在文件末尾(附加),然后编辑的文件将发送给最终用户.问题是文件"内容"的更改将破坏文件签名 - 是否有机会使用任何命令行工具重新签名此更改的文件?我曾尝试使用微软的SignTool,但它在Linux上无法正常运行.

EFe*_*des 33

你可以尝试osslsigncode

要签署EXE或MSI文件,您现在可以执行以下操作:

osslsigncode sign -certs <cert-file> -key <der-key-file> \
        -n "Your Application" -i http://www.yourwebsite.com/ \
        -in yourapp.exe -out yourapp-signed.exe
Run Code Online (Sandbox Code Playgroud)

或者如果您使用带密码的PEM或PVK密钥文件以及PEM证书:

osslsigncode sign -certs <cert-file> \
        -key <key-file> -pass <key-password> \
        -n "Your Application" -i http://www.yourwebsite.com/ \
        -in yourapp.exe -out yourapp-signed.exe
Run Code Online (Sandbox Code Playgroud)

或者如果您还想添加时间戳:

osslsigncode sign -certs <cert-file> -key <key-file> \
        -n "Your Application" -i http://www.yourwebsite.com/ \
        -t http://timestamp.verisign.com/scripts/timstamp.dll \
        -in yourapp.exe -out yourapp-signed.exe
Run Code Online (Sandbox Code Playgroud)

您可以使用存储在PKCS#12容器中的证书和密钥:

osslsigncode sign -pkcs12 <pkcs12-file> -pass <pkcs12-password> \
        -n "Your Application" -i http://www.yourwebsite.com/ \
        -in yourapp.exe -out yourapp-signed.exe
Run Code Online (Sandbox Code Playgroud)

要签署包含java类文件的CAB文件:

osslsigncode sign -certs <cert-file> -key <key-file> \
        -n "Your Application" -i http://www.yourwebsite.com/ \
        -jp low \
        -in yourapp.cab -out yourapp-signed.cab
Run Code Online (Sandbox Code Playgroud)


Joa*_*son 24

使用signtool 实际上很直接Mono ; 棘手的部分(在链接的Mozilla文章中有更详细的描述)是将证书以正确的格式从Windows复制到Linux.

将Windows PFX证书文件转换为PVK和SPC文件时,只需将证书从Windows复制到Linux即可完成一次;

openssl pkcs12 -in authenticode.pfx -nocerts -nodes -out key.pem
openssl rsa -in key.pem -outform PVK -pvk-strong -out authenticode.pvk
openssl pkcs12 -in authenticode.pfx -nokeys -nodes -out cert.pem
openssl crl2pkcs7 -nocrl -certfile cert.pem -outform DER -out authenticode.spc
Run Code Online (Sandbox Code Playgroud)

实际上签署exe是直截了当的;

signcode \
 -spc authenticode.spc \
 -v authenticode.pvk \
 -a sha1 -$ commercial \
 -n My\ Application \
 -i http://www.example.com/ \
 -t http://timestamp.verisign.com/scripts/timstamp.dll \
 -tr 10 \
 MyApp.exe
Run Code Online (Sandbox Code Playgroud)