我准备了一个应用程序和网站,客户可以在下载之前为其设置多个选项。设置以二进制格式存储在文件末尾(附加),然后编辑后的文件发送给最终用户。问题在于文件“内容”的更改会破坏文件签名 - 是否有机会使用任何命令行工具重新签署此更改的文件?我试图使用微软的SignTool,但它在Linux上无法正常工作。在基于Linux的发行版上签署Windows应用程序
回答
它实际上是quite straight forward使用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
这是为我工作的解决方案。 signcode工具没有签名文件(虽然它报告签名成功) – treaz
这对于在Mageia Linux下用NSIS和Ant签名我的Windows安装程序(包装Java软件)很有用。非常感谢:) – gouessej
我很高兴我找到了这个伟大的解决方案!我实际上想在Windows中使用微软的signtool.exe来签署我的代码,所以我在阅读你的答案后在Windows上的Ubuntu上使用了Bash。如果其他人在同一条船上,这里是简要说明https://blog.synapp.nz/2017/06/16/code-signing-a-windows-application-on-linux-on-windows/ –
- 1. Windows应用程序签署
- 2. 在windows上运行android应用程序,在linux上开发
- 3. 在Windows和Linux上部署C#Windows窗体应用程序
- 4. 在Linux上签署NSIS安装程序
- 5. 在Linux上部署PyQt5应用程序
- 6. 开发和部署Linux应用程序的基础知识
- 7. solusOs - 是基于什么Linux发行版?
- 8. 在Linux发行版中分发二进制应用程序
- 9. 如何签署Windows Store应用程序?
- 10. 无法在Windows 7上部署基于VB6的安装程序
- 11. 在Appfog上部署基于Deployd(deployd.com)的Node.js应用程序
- 12. 如何在Tomcat上部署基于EJB的应用程序
- 13. 从基于WSGI的web应用程序在Linux上执行进程
- 14. 在Linux上开发asp.net应用程序的windows服务器
- 15. 在Mac上为Facebook应用程序签署Android应用程序
- 16. 适用于Windows和Linux的应用程序开发
- 17. 在Linux机器上从Windows上运行GTK +应用程序
- 18. 在Windows中分发基于wxHaskell的应用程序
- 19. 我可以在Windows上开发.NET应用程序和部署Linux和Mac版本?
- 20. 签署和发布Android应用程序
- 21. 发布windows应用程序 - ClickOnce部署
- 22. 如何在Linux发行版中托管asp.net Web应用程序
- 23. 在Linux上开发Spotify应用程序
- 24. 在Windows和Linux上运行的Visual Java应用程序
- 25. 使现有的C#Windows应用程序在Linux上运行
- 26. 构建Qt应用程序用于Windows Phone的Linux上
- 27. 签署应用程序,但不在Android市场上发布
- 28. 在Linux和Windows主机上开发Android应用程序
- 29. 在Windows和Linux上开发Web应用程序
- 30. 该应用程序在Windows中运行,但不在Linux上
你有使用这个工具的个人经验吗?您提到的那篇文章是[超过2年](https://developer.mozilla.org/en-US/docs/Signing_an_executable_with_Authenticode$history),所以有些保证它仍然是最新的会很好。 –
@RobW我已经使用Mono 3.2.5使用该命令签署了可执行文件,它运行良好(实际上我只是测试过)。我现在无法测试从Windows导出证书的确切步骤,因为我不在Mac上,但我知道给出的流程与我最近使用的非常相似。 –
感谢您的确认!不要担心证书,OpenSSL能够将任何东西转换为任何东西。 –