我准备了一个应用程序和网站,客户可以在下载之前为这个应用程序设置多个选项。 设置以二进制格式存储在文件末尾(附加),然后将编辑的文件发送给最终用户。 问题是文件“内容”的改变会破坏文件签名 – 是否有机会用任何命令行工具重新签名这个改变的文件? 我试图使用微软的SignTool,但在Linux上无法正常工作。
实际上使用Mono
的signtool 非常简单 , 棘手的部分(在链接的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
其实签署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
你可以试试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
或者如果您使用带密码的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
或者如果你想添加一个时间戳:
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
您可以使用存储在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
签署包含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