使用sign4j和jsign在ant中签署launch4j可执行文件

Pho*_*ixS 3 ant sign launch4j

我在Jar中有一个应用程序,我用launch4j将它包装在一个exe中,因此用户很容易启动它(在windows中).我有一个证书,所以我签署了jar(我不知道这是否真的有必要,因为它将被包装在exe中)并且我想签署exe但它破坏了可执行文件.

我用ant来制作所有的过程,看起来像:

<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" />
Run Code Online (Sandbox Code Playgroud)

我发现这是因为当你签署exe时它破坏了jar结构或类似的东西.但我也看到,在launch4j文件夹中是一个sign4j文件夹,其中包含我认为解决此问题的程序.

我现在的问题是如何使用这个程序?我怎样才能将它集成到ant脚本中来签署exe?

文件夹中的README.txt文件对我没有帮助.对不起,如果这个显而易见但对我来说不明确.另请注意,我正在使用Ubuntu.

Pho*_*ixS 5

我发现你必须以sign命令作为参数执行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
Run Code Online (Sandbox Code Playgroud)

因此,要将其集成到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>
Run Code Online (Sandbox Code Playgroud)

它也适用于其他签名工具,例如来自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>
Run Code Online (Sandbox Code Playgroud)