Skip to content

Commit 44d0abe

Browse files
authored
Add cherry-pickable shim for hsm signing (#1330)
1 parent d3560c1 commit 44d0abe

File tree

5 files changed

+77
-12
lines changed

5 files changed

+77
-12
lines changed

ant/lib/jsign-4.2.jar

-1.17 MB
Binary file not shown.

ant/lib/jsign-7.1.jar

2.01 MB
Binary file not shown.

ant/signing.xml

+54
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,60 @@
77
<!-- Fallback code-signing properties -->
88
<property file="ant/private/private.properties"/>
99

10+
<!-- Locate first jsign-x.x.x.jar sorted name desc -->
11+
<target name="find-jsign">
12+
<sort id="jsign.sorted">
13+
<fileset dir="${basedir}/ant/lib/">
14+
<include name="jsign*.jar"/>
15+
</fileset>
16+
<reverse xmlns="antlib:org.apache.tools.ant.types.resources.comparators"/>
17+
</sort>
18+
<first id="jsign.first">
19+
<resources refid="jsign.sorted"/>
20+
</first>
21+
<pathconvert property="jsign.path" refid="jsign.first">
22+
<identitymapper/>
23+
</pathconvert>
24+
25+
<echo message="Found jsign: ${jsign.path}"/>
26+
</target>
27+
28+
<!-- File signing via hsm with timestamp -->
29+
<target name="sign-file-hsm" if="hsm.storetype" depends="find-jsign">
30+
<property description="suppress property warning" name="sign.file" value="something went wrong"/>
31+
32+
<!-- Handle quoting via backwards-compatible shim (for cherry-pick) -->
33+
<condition property="sign.file.quoted" value="&quot;${sign.file}&quot;">
34+
<contains string="${sign.file}" substring="&quot;"/>
35+
</condition>
36+
<property description="fallback value" name="sign.file.quoted" value="${sign.file}"/>
37+
38+
<property description="suppress property warning" name="hsm.storetype" value="something went wrong"/>
39+
<echo level="info">Signing with hsm: ${hsm.keystore}</echo>
40+
<java jar="${jsign.path}" fork="true" failonerror="true">
41+
<arg value="--name"/>
42+
<arg value="${project.name}"/>
43+
<arg value="--url"/>
44+
<arg value="${vendor.website}"/>
45+
<arg value="--replace"/>
46+
<arg value="--alg"/>
47+
<arg value="${hsm.algorithm}"/>
48+
<arg value="--storetype"/>
49+
<arg value="${hsm.storetype}"/>
50+
<arg value="--keystore"/>
51+
<arg value="${hsm.keystore}"/>
52+
<arg value="--alias"/>
53+
<arg value="${hsm.alias}"/>
54+
<arg value="--storepass"/>
55+
<arg value="${hsm.storepass}"/>
56+
<arg value="--tsaurl"/>
57+
<arg value="${hsm.tsaurl}"/>
58+
<arg value="--certfile"/>
59+
<arg value="${hsm.certfile}"/>
60+
<arg line="${sign.file.quoted}"/>
61+
</java>
62+
</target>
63+
1064
<target name="sign-jar">
1165
<antcall target="sign-jar-tsa">
1266
<param name="sign.jar.file" value="${sign.jar.file}"/>

ant/windows/installer.xml

+10-12
Original file line numberDiff line numberDiff line change
@@ -72,18 +72,6 @@
7272
</antcall>
7373
</target>
7474

75-
<target name="find-jsign">
76-
<!-- Locate jsign -->
77-
<path id="jsign.found">
78-
<first>
79-
<fileset dir="${basedir}/ant/lib/">
80-
<include name="jsign*.jar"/>
81-
</fileset>
82-
</first>
83-
</path>
84-
<pathconvert property="jsign.path" refid="jsign.found"/>
85-
</target>
86-
8775
<target name="find-nsisbin" depends="nsisbin-from-unix,nsisbin-from-32,nsisbin-from-64"/>
8876

8977
<!-- Linux makensis -->
@@ -112,6 +100,16 @@
112100
<antcall target="sign-win-self">
113101
<param name="sign.win.file" value="${sign.win.file}"/>
114102
</antcall>
103+
104+
<!-- Handle property name via backwards-compatible shim (for cherry-pick) -->
105+
<condition property="sign.win.file" value="${sign.exe.file}">
106+
<isset property="sign.exe.file"/>
107+
</condition>
108+
109+
<!-- Honor "hsm.storetype" -->
110+
<antcall target="sign-file-hsm">
111+
<param name="sign.file" value="${sign.win.file}"/>
112+
</antcall>
115113
</target>
116114

117115
<target name="copy-dlls" if="target.os.windows">

build.xml

+13
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@
3030
</and>
3131
</condition>
3232

33+
<!-- Handle codesign.mac backwards-compatible shim (for cherry-pick) -->
34+
<condition property="codesign.mac" value="true">
35+
<and>
36+
<or>
37+
<isset property="target.os.mac"/>
38+
<isset property="target.platform.mac"/>
39+
</or>
40+
<or>
41+
<isset property="signing.tsaurl"/>
42+
<isset property="hsm.storetype"/>
43+
</or>
44+
</and>
45+
</condition>
3346
<echo message="Building ${project.filename} using JDK ${ant.java.version}"/>
3447
</target>
3548

0 commit comments

Comments
 (0)