Debian Codegraph @

manual/Tasks/signjar.html

raw
1 <!DOCTYPE html>
2 <!--
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
9
10 https://www.apache.org/licenses/LICENSE-2.0
11
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 -->
18 <html lang="en">
19
20 <head>
21 <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
22 <title>SignJar Task</title>
23 </head>
24
25 <body>
26
27 <h2 id="signjar">SignJar</h2>
28 <h3>Description</h3>
29 <p>Signing a jar allows users to authenticate the publisher.</p>
30 <p>Signs JAR files with
31 the <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jarsigner.html"
32 target="_top"><kbd>jarsigner</kbd></a> command line tool. It will take a named file in
33 the <var>jar</var> attribute, and an optional <var>destDir</var> or <var>signedJar</var>
34 attribute. Nested paths are also supported; here only an (optional) <var>destDir</var> is
35 allowed. If a destination directory or explicit JAR file name is not provided, JARs are signed in
36 place.</p>
37 <p>Dependency rules</p>
38 <ul>
39 <li>Nonexistent destination JARs are created/signed</li>
40 <li>Out of date destination JARs are created/signed</li>
41 <li>If a destination file and a source file are the same, and <var>lazy</var> is <q>true</q>, the
42 JAR is only signed if it does not contain a signature by this alias.</li>
43 <li>If a destination file and a source file are the same, and <var>lazy</var> is <q>false</q>, the
44 JAR is signed.</li>
45 </ul>
46
47 <h3>Parameters</h3>
48 <table class="attr">
49 <tr>
50 <th scope="col">Attribute</th>
51 <th scope="col">Description</th>
52 <th scope="col">Required</th>
53 </tr>
54 <tr>
55 <td>jar</td>
56 <td>the jar file to sign</td>
57 <td>Yes, unless nested paths have been used</td>
58 </tr>
59 <tr>
60 <td>alias</td>
61 <td>the alias to sign under</td>
62 <td>Yes</td>
63 </tr>
64 <tr>
65 <td>storepass</td>
66 <td>password for keystore integrity. Ant will not use
67 the <code>-storepass</code> command line argument but send the
68 password to jarsigner when it prompts for it.</td>
69 <td>Yes</td>
70 </tr>
71 <tr>
72 <td>keystore</td>
73 <td>keystore location</td>
74 <td>No</td>
75 </tr>
76 <tr>
77 <td>storetype</td>
78 <td>keystore type</td>
79 <td>No</td>
80 </tr>
81 <tr>
82 <td>keypass</td>
83 <td>password for private key (if different)</td>
84 <td>No</td>
85 </tr>
86 <tr>
87 <td>sigfile</td>
88 <td>name of <samp>.SF</samp>/<samp>.DSA</samp> file</td>
89 <td>No</td>
90 </tr>
91 <tr>
92 <td>signedjar</td>
93 <td>name of signed JAR file. This can only be set when the <var>jar</var> attribute is set.</td>
94 <td>No</td>
95 </tr>
96 <tr>
97 <td>verbose</td>
98 <td>(<q>true|false</q>) verbose output when signing</td>
99 <td>No; default <q>false</q></td>
100 </tr>
101 <tr>
102 <td>strict</td>
103 <td>(<q>true|false</q>) strict checking when signing.<br/><em>since Ant 1.9.1</em>.</td>
104 <td>No; default <q>false</q></td>
105 </tr>
106 <tr>
107 <td>internalsf</td>
108 <td>(<q>true|false</q>) include the <samp>.SF</samp> file inside the signature block</td>
109 <td>No; default <q>false</q></td>
110 </tr>
111 <tr>
112 <td>sectionsonly</td>
113 <td>(<q>true|false</q>) don't compute hash of entire manifest</td>
114 <td>No; default <q>false</q></td>
115 </tr>
116 <tr>
117 <td>lazy</td>
118 <td>flag to control whether the presence of a signature file means a JAR is signed. This is only
119 used when the target JAR matches the source JAR</td>
120 <td>No; default <q>false</q></td>
121 </tr>
122 <tr>
123 <td>maxmemory</td>
124 <td>Specifies the maximum memory the <kbd>jarsigner</kbd> JVM will use. Specified in the style
125 of standard Java memory specs (e.g. <q>128m</q> = 128 MBytes)</td>
126 <td>No</td>
127 </tr>
128 <tr>
129 <td>preservelastmodified</td>
130 <td>Give the signed files the same last modified time as the original jar files.</td>
131 <td>No; default <q>false</q>.</td>
132 </tr>
133 <tr>
134 <td>tsaurl</td>
135 <td>URL for a timestamp authority for timestamped JAR files in Java 5+</td>
136 <td>No</td>
137 </tr>
138 <tr>
139 <td>tsacert</td>
140 <td>alias in the keystore for a timestamp authority for timestamped JAR files in Java 5+</td>
141 <td>No</td>
142 </tr>
143 <tr>
144 <td>tsaproxyhost</td>
145 <td>proxy host to be used when connecting to TSA server</td>
146 <td>No</td>
147 </tr>
148 <tr>
149 <td>tsaproxyport</td>
150 <td>proxy port to be used when connecting to TSA server</td>
151 <td>No</td>
152 </tr>
153 <tr>
154 <td>executable</td>
155 <td>Specify a particular <kbd>jarsigner</kbd> executable to use in place of the default binary
156 (found in the same JDK as Apache Ant is running in).<br/>Must support the same command line
157 options as the Sun JDK <kbd>jarsigner</kbd> command. <em>since Ant 1.8.0</em>.</td>
158 <td>No</td>
159 </tr>
160 <tr>
161 <td>force</td>
162 <td>Whether to force signing of the jar file even if it doesn't seem to be out of date or
163 already signed. <em>since Ant 1.8.0</em>.</td>
164 <td>No; default <q>false</q></td>
165 </tr>
166 <tr>
167 <td>sigalg</td>
168 <td>name of signature algorithm</td>
169 <td>No</td>
170 </tr>
171 <tr>
172 <td>digestalg</td>
173 <td>name of digest algorithm</td>
174 <td>No</td>
175 </tr>
176 <tr>
177 <td>tsadigestalg</td>
178 <td>name of TSA digest algorithm. <em>since Ant 1.10.2</em></td>
179 <td>No</td>
180 </tr>
181 <tr>
182 <td>providername</td>
183 <td>name of a cryptographic service provider's name
184 when listed in the security properties file.
185 <em>since Ant 1.10.6</em>.</td>
186 <td>No</td>
187 </tr>
188 <tr>
189 <td>providerclass</td>
190 <td>name of a cryptographic service provider's master
191 class file when the service provider is not listed in the security
192 properties file.
193 <em>since Ant 1.10.6</em>.</td>
194 <td>No</td>
195 </tr>
196 <tr>
197 <td>providerarg</td>
198 <td>Represents an optional string input argument for
199 the constructor of provider_class_name. Ignored
200 if <code>providerclass</code> is not set.
201 <em>since Ant 1.10.6</em>.</td>
202 <td>No</td>
203 </tr>
204 </table>
205 <h3>Parameters as nested elements</h3>
206 <table class="attr">
207 <tr>
208 <th scope="col">Attribute</th>
209 <th scope="col">Description</th>
210 <th scope="col">Required</th>
211 </tr>
212 <tr>
213 <td>path</td>
214 <td>path of JAR files to sign. <em>since Ant 1.7</em></td>
215 <td>No</td>
216 </tr>
217 <tr>
218 <td>fileset</td>
219 <td>fileset of JAR files to sign.</td>
220 <td>No</td>
221 </tr>
222 <tr>
223 <td>mapper</td>
224 <td>A mapper to rename jar files during signing</td>
225 <td>No, and only one can be supplied</td>
226 </tr>
227 <tr>
228 <td>sysproperty</td>
229 <td>JVM system properties, with the syntax of Ant <a href="exec.html#env">environment
230 variables</a></td>
231 <td>No, and only one can be supplied</td>
232 </tr>
233 <tr>
234 <td>arg</td>
235 <td>Use this to specify a <kbd>jarsigner</kbd>
236 <a href="../using.html#arg">command line argument</a> not
237 explicitly supported via an attribute.
238 <em>since Ant 1.10.6</em>.</td>
239 <td>No</td>
240 </tr>
241 </table>
242
243 <h3>Examples</h3>
244 <p>For instructions on generating a code signing certificate, see
245 the <a href="https://docs.oracle.com/javase/8/docs/technotes/tools/windows/keytool.html"
246 target="_top">keytool documentation</a> and/or instructions from your certificate authority.</p>
247
248 <p>Sign the <samp>ant.jar</samp> with alias <q>apache-group</q> accessing the keystore and private
249 key via <q>secret</q> password.</p>
250 <pre>
251 &lt;signjar jar=&quot;${dist}/lib/ant.jar&quot;
252 alias=&quot;apache-group&quot; storepass=&quot;secret&quot;/&gt;</pre>
253
254 <p>Sign all JAR files matching the <samp>dist/**/*.jar</samp> pattern, copying them to the
255 directory <samp>signed</samp> afterwards. The flatten mapper means that they will all be copied to
256 this directory, not to subdirectories.</p>
257 <pre>
258 &lt;signjar destDir="signed"
259 alias="testonly" keystore="testkeystore"
260 storepass="apacheant"
261 preservelastmodified="true"&gt;
262 &lt;path&gt;
263 &lt;fileset dir="dist" includes="**/*.jar"/&gt;
264 &lt;/path&gt;
265 &lt;flattenmapper/&gt;
266 &lt;/signjar&gt;</pre>
267
268 <p>Sign all the JAR files in <samp>dist/**/*.jar</samp> <em>in-situ</em>. Lazy signing is used, so
269 the files will only be signed if they are not already signed.</p>
270 <pre>
271 &lt;signjar alias="testonly" keystore="testkeystore"
272 storepass="apacheant"
273 lazy="true"&gt;
274 &lt;path&gt;
275 &lt;fileset dir="dist" includes="**/*.jar"/&gt;
276 &lt;/path&gt;
277 &lt;/signjar&gt;</pre>
278
279 <p>Sign all the JAR files in <samp>dist/**/*.jar</samp> using the digest algorithm SHA1 and the
280 signature algorithm MD5withRSA. This is especially useful when you want to use the JDK
281 7 <kbd>jarsigner</kbd> (which uses SHA256 and SHA256withRSA as default) to create signed jars that
282 will be deployed on platforms not supporting SHA256 and SHA256withRSA.</p>
283 <pre>
284 &lt;signjar alias="testonly" keystore="testkeystore"
285 storepass="apacheant"
286 sigalg="MD5withRSA"
287 digestalg="SHA1"&gt;
288 &lt;path&gt;
289 &lt;fileset dir="dist" includes="**/*.jar"/&gt;
290 &lt;/path&gt;
291 &lt;/signjar&gt;</pre>
292
293 <h3>About timestamp signing</h3>
294
295 <p>Timestamps record the date and time that a signature took place, allowing the signature to be
296 verified as of that point in time. With trusted timestamping, users can verify that signing
297 occurred before a certificate's expiration or revocation. Without this timestamp, users can only
298 verify the signature as of their current date.</p>
299
300 <p>Timestamped JAR files were introduced in Java 5; they are supported <em>since Ant
301 1.7</em>. Unauthenticated proxies can be used to access TSAs <em>since Ant 1.9.5</em>.</p>
302
303 <p>Common public timestamp authorities include</p>
304 <ul>
305 <li>http://timestamp.verisign.com</li>
306 <li>http://tsa.starfieldtech.com</li>
307 <li>https://timestamp.geotrust.com/tsa</li>
308 <li>Others (see your certificate authority)</li>
309 </ul>
310
311 </body>
312 </html>