我在Jar中有一个应用程序,并用launch4j将其包装在exe中,因此用户可以轻松地在Windows中启动它。我有一个证书,所以我在jar上签名(我不知道这是否真的必要,因为它将包装在exe文件中),我想签名exe文件,但它破坏了可执行文件。
我使用蚂蚁来完成所有过程,看起来像:
<signjar jar="${jar.location}" alias="${key.alias}" storetype="pkcs12" keystore="${key.file}" storepass="${key.password}" tsaurl="https://timestamp.geotrust.com/tsa" />
<launch4j configFile="launch4j_configuration.xml" fileversion="${version}.0" txtfileversion="${build}" productversion="${version}.0" txtproductversion="${build}" outfile="${exe.location}" jar="${jar.location}" />
<signexe file="${exe.location}" alias="${key.alias}" storetype="pkcs12" keystore="${key.file}" storepass="${key.password}" tsaurl="http://timestamp.verisign.com/scripts/timstamp.dll" />
我发现这是因为当您签名exe时,它破坏了jar结构或类似的东西。但是我还看到,在launch4j文件夹中是一个sign4j文件夹,其中包含我认为是可以解决此问题的程序。
我现在的问题是如何使用该程序?以及如何将其集成到ant脚本中以对exe签名?
文件夹中的README.txt文件对我没有帮助。抱歉,这很明显,但我不清楚。另请注意,我正在使用Ubuntu。
我发现您必须以signing命令作为参数来执行sign4j命令。类似于:
sign4j jsign -s keyfile.p12 -a "(codesign_1091_es_sw_kpsc)" --storepass AVERYGOODPASSWORD --storetype pkcs12 -n MyProgram -u https://www.example.com MyProgram.exe
因此,要将其集成到ant中,您需要创建一个exec
任务。例如,类似:
<exec executable="sign4j">
<arg line="java -jar jsign-1.2.jar -s ${key.file} -a ${key.alias} --storepass ${key.password} --storetype pkcs12 ${exe.location}"/>
</exec>
它还可以与其他签名工具一起使用,例如也可以使用Microsoft的authenticode ...
<exec executable="launch4j/sign4j/sign4j.exe">
<arg line="signtool.exe sign /fd SHA256 /f mycert.pfx /p foobar /t http://timestamp.verisign.com/scripts/timstamp.dll dist\myapp.exe"/>
</exec>
我使用如下所示的ant目标来对从jar文件生成的exe进行签名
<target name="signexe" depends="createExe" description="Signing Exe">
<exec executable="C:\Tools\Launch4j\sign4j\sign4j.exe">
<arg line="java -jar C:\3rdParty\jsign\jsign-3.1.jar
--keystore ${keystore.location} --alias ${key.alias} --storepass ${store.password}
--name 'Application Name'
--tsaurl http://timestamp.verisign.com/scripts/timstamp.dll
AppLauncher.exe"/>
</exec>
</target>