You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

signjar.html 10 KiB

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