blob: 62a2a3f829c4723ab547966eb4827185f955cc3f [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001.'" t
2." Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
3." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4."
5." This code is free software; you can redistribute it and/or modify it
6." under the terms of the GNU General Public License version 2 only, as
7." published by the Free Software Foundation.
8."
9." This code is distributed in the hope that it will be useful, but WITHOUT
10." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12." version 2 for more details (a copy is included in the LICENSE file that
13." accompanied this code).
14."
15." You should have received a copy of the GNU General Public License version
16." 2 along with this work; if not, write to the Free Software Foundation,
17." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18."
19." Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20." CA 95054 USA or visit www.sun.com if you need additional information or
21." have any questions.
22." `
23.TH jarsigner 1 "07 Aug 2006"
24." Generated by html2man
25
26.LP
27.SH NAME
28jarsigner \- JAR Signing and Verification Tool
29.LP
30.RS 3
31
32.LP
33.LP
34Generates signatures for Java ARchive (JAR) files, and verifies the signatures of signed JAR files.
35.LP
36.RE
37.SH "SYNOPSIS"
38.LP
39
40.LP
41.nf
42\f3
43.fl
44\fP\f3jarsigner\fP [ options ] jar\-file alias
45.fl
46\f3jarsigner\fP \-verify [ options ] jar\-file
47.fl
48.fi
49
50.LP
51.SH "DESCRIPTION"
52.LP
53
54.LP
55.LP
56The \f3jarsigner\fP tool is used for two purposes:
57.LP
58.RS 3
59.TP 3
601.
61to sign Java ARchive (JAR) files, and
62.TP 3
632.
64to verify the signatures and integrity of signed JAR files.
65.RE
66
67.LP
68.LP
69The JAR feature enables the packaging of class files, images, sounds, and other digital data in a single file for faster and easier distribution. A tool named \f3jar\fP enables developers to produce JAR files. (Technically, any zip file can also be considered a JAR file, although when created by \f3jar\fP or processed by \f3jarsigner\fP, JAR files also contain a META\-INF/MANIFEST.MF file.)
70.LP
71.LP
72A \f2digital signature\fP is a string of bits that is computed from some data (the data being "signed") and the private key of an entity (a person, company, etc.). Like a handwritten signature, a digital signature has many useful characteristics:
73.LP
74.RS 3
75.TP 2
76o
77Its authenticity can be verified, via a computation that uses the public key corresponding to the private key used to generate the signature.
78.TP 2
79o
80It cannot be forged, assuming the private key is kept secret.
81.TP 2
82o
83It is a function of the data signed and thus can't be claimed to be the signature for other data as well.
84.TP 2
85o
86The signed data cannot be changed; if it is, the signature will no longer verify as being authentic.
87.RE
88
89.LP
90.LP
91In order for an entity's signature to be generated for a file, the entity must first have a public/private key pair associated with it, and also one or more certificates authenticating its public key. A \f2certificate\fP is a digitally signed statement from one entity, saying that the public key of some other entity has a particular value.
92.LP
93.LP
94\f3jarsigner\fP uses key and certificate information from a \f2keystore\fP to generate digital signatures for JAR files. A keystore is a database of private keys and their associated X.509 certificate chains authenticating the corresponding public keys. The \f3keytool\fP utility is used to create and administer keystores.
95.LP
96.LP
97\f3jarsigner\fP uses an entity's private key to generate a signature. The signed JAR file contains, among other things, a copy of the certificate from the keystore for the public key corresponding to the private key used to sign the file. \f3jarsigner\fP can verify the digital signature of the signed JAR file using the certificate inside it (in its signature block file).
98.LP
99.LP
100Starting in J2SE 5.0, \f3jarsigner\fP can generate signatures that include a timestamp, thus enabling systems/deployer (including Java Plug\-in) to check whether the JAR file was signed while the signing certificate was still valid. In addition, APIs were added in J2SE 5.0 to allow applications to obtain the timestamp information.
101.LP
102.LP
103At this time, \f3jarsigner\fP can only sign JAR files created by the SDK \f3jar\fP tool or zip files. (JAR files are the same as zip files, except they also have a META\-INF/MANIFEST.MF file. Such a file will automatically be created when \f3jarsigner\fP signs a zip file.)
104.LP
105.LP
106The default \f3jarsigner\fP behavior is to \f2sign\fP a JAR (or zip) file. Use the \f2\-verify\fP option to instead have it \f2verify\fP a signed JAR file.
107.LP
108.SS
109Compatibility with JDK 1.1
110.LP
111.RS 3
112
113.LP
114.LP
115The \f3keytool\fP and \f3jarsigner\fP tools completely replace the \f3javakey\fP tool provided in JDK 1.1. These new tools provide more features than \f3javakey\fP, including the ability to protect the keystore and private keys with passwords, and the ability to verify signatures in addition to generating them.
116.LP
117.LP
118The new keystore architecture replaces the identity database that \f3javakey\fP created and managed. There is no backwards compatibility between the keystore format and the database format used by \f3javakey\fP in 1.1. However,
119.LP
120.RS 3
121.TP 2
122o
123It is possible to import the information from an identity database into a keystore, via the \f3keytool\fP \f2\-identitydb\fP command.
124.TP 2
125o
126\f3jarsigner\fP can sign JAR files also previously signed using \f3javakey\fP.
127.TP 2
128o
129\f3jarsigner\fP can verify JAR files signed using \f3javakey\fP. Thus, it recognizes and can work with signer aliases that are from a JDK 1.1 identity database rather than a Java 2 SDK keystore.
130.RE
131
132.LP
133.LP
134The following table explains how JAR files that were signed in JDK 1.1.x are treated in the Java 2 platform.
135.LP
136.LP
137.TS
138.if \n+(b.=1 .nr d. \n(.c-\n(c.-1
139.de 35
140.ps \n(.s
141.vs \n(.vu
142.in \n(.iu
143.if \n(.u .fi
144.if \n(.j .ad
145.if \n(.j=0 .na
146..
147.nf
148.nr #~ 0
149.if n .nr #~ 0.6n
150.ds #d .d
151.if \(ts\n(.z\(ts\(ts .ds #d nl
152.fc
153.nr 33 \n(.s
154.rm 80 81 82 83 84
155.nr 34 \n(.lu
156.eo
157.am 82
158.br
159.di a+
160.35
161.ft \n(.f
162.ll \n(34u*1u/6u
163.if \n(.l<\n(82 .ll \n(82u
164.in 0
165\f3Trusted Identity imported into Java 2 Platform keystore from 1.1 database (4)\fP
166.br
167.di
168.nr a| \n(dn
169.nr a- \n(dl
170..
171.ec \
172.eo
173.am 83
174.br
175.di b+
176.35
177.ft \n(.f
178.ll \n(34u*1u/6u
179.if \n(.l<\n(83 .ll \n(83u
180.in 0
181\f3Policy File grants privileges to Identity/Alias\fP
182.br
183.di
184.nr b| \n(dn
185.nr b- \n(dl
186..
187.ec \
188.eo
189.am 84
190.br
191.di c+
192.35
193.ft \n(.f
194.ll \n(34u*1u/6u
195.if \n(.l<\n(84 .ll \n(84u
196.in 0
197Default privileges granted to all code.
198.br
199.di
200.nr c| \n(dn
201.nr c- \n(dl
202..
203.ec \
204.eo
205.am 84
206.br
207.di d+
208.35
209.ft \n(.f
210.ll \n(34u*1u/6u
211.if \n(.l<\n(84 .ll \n(84u
212.in 0
213Default privileges granted to all code.
214.br
215.di
216.nr d| \n(dn
217.nr d- \n(dl
218..
219.ec \
220.eo
221.am 84
222.br
223.di e+
224.35
225.ft \n(.f
226.ll \n(34u*1u/6u
227.if \n(.l<\n(84 .ll \n(84u
228.in 0
229Default privileges granted to all code.
230.br
231.di
232.nr e| \n(dn
233.nr e- \n(dl
234..
235.ec \
236.eo
237.am 84
238.br
239.di f+
240.35
241.ft \n(.f
242.ll \n(34u*1u/6u
243.if \n(.l<\n(84 .ll \n(84u
244.in 0
245Default privileges granted to all code. (3)
246.br
247.di
248.nr f| \n(dn
249.nr f- \n(dl
250..
251.ec \
252.eo
253.am 84
254.br
255.di g+
256.35
257.ft \n(.f
258.ll \n(34u*1u/6u
259.if \n(.l<\n(84 .ll \n(84u
260.in 0
261Default privileges granted to all code. (1,3)
262.br
263.di
264.nr g| \n(dn
265.nr g- \n(dl
266..
267.ec \
268.eo
269.am 84
270.br
271.di h+
272.35
273.ft \n(.f
274.ll \n(34u*1u/6u
275.if \n(.l<\n(84 .ll \n(84u
276.in 0
277Default privileges granted to all code plus privileges granted in policy file.
278.br
279.di
280.nr h| \n(dn
281.nr h- \n(dl
282..
283.ec \
284.eo
285.am 84
286.br
287.di i+
288.35
289.ft \n(.f
290.ll \n(34u*1u/6u
291.if \n(.l<\n(84 .ll \n(84u
292.in 0
293Default privileges granted to all code plus privileges granted in policy file. (2)
294.br
295.di
296.nr i| \n(dn
297.nr i- \n(dl
298..
299.ec \
300.35
301.nf
302.ll \n(34u
303.nr 80 0
304.nr 38 \w\f3JAR File Type\fP
305.if \n(80<\n(38 .nr 80 \n(38
306.nr 38 \wSigned JAR
307.if \n(80<\n(38 .nr 80 \n(38
308.nr 38 \wUnsigned JAR
309.if \n(80<\n(38 .nr 80 \n(38
310.nr 38 \wSigned JAR
311.if \n(80<\n(38 .nr 80 \n(38
312.nr 38 \wSigned JAR
313.if \n(80<\n(38 .nr 80 \n(38
314.nr 38 \wSigned JAR
315.if \n(80<\n(38 .nr 80 \n(38
316.nr 38 \wSigned JAR
317.if \n(80<\n(38 .nr 80 \n(38
318.nr 38 \wSigned JAR
319.if \n(80<\n(38 .nr 80 \n(38
320.nr 38 \wSigned JAR
321.if \n(80<\n(38 .nr 80 \n(38
322.nr 38 \wSigned JAR
323.if \n(80<\n(38 .nr 80 \n(38
324.nr 38 \wSigned JAR
325.if \n(80<\n(38 .nr 80 \n(38
326.80
327.rm 80
328.nr 81 0
329.nr 38 \w\f3Identity in 1.1 database\fP
330.if \n(81<\n(38 .nr 81 \n(38
331.nr 38 \wNO
332.if \n(81<\n(38 .nr 81 \n(38
333.nr 38 \wNO
334.if \n(81<\n(38 .nr 81 \n(38
335.nr 38 \wNO
336.if \n(81<\n(38 .nr 81 \n(38
337.nr 38 \wYES/Untrusted
338.if \n(81<\n(38 .nr 81 \n(38
339.nr 38 \wYES/Untrusted
340.if \n(81<\n(38 .nr 81 \n(38
341.nr 38 \wNO
342.if \n(81<\n(38 .nr 81 \n(38
343.nr 38 \wYES/Trusted
344.if \n(81<\n(38 .nr 81 \n(38
345.nr 38 \wYES/Trusted
346.if \n(81<\n(38 .nr 81 \n(38
347.nr 38 \wYES/Trusted
348.if \n(81<\n(38 .nr 81 \n(38
349.nr 38 \wYES/Trusted
350.if \n(81<\n(38 .nr 81 \n(38
351.81
352.rm 81
353.nr 82 0
354.nr 38 \wNO
355.if \n(82<\n(38 .nr 82 \n(38
356.nr 38 \wNO
357.if \n(82<\n(38 .nr 82 \n(38
358.nr 38 \wYES
359.if \n(82<\n(38 .nr 82 \n(38
360.nr 38 \wNO
361.if \n(82<\n(38 .nr 82 \n(38
362.nr 38 \wNO
363.if \n(82<\n(38 .nr 82 \n(38
364.nr 38 \wYES
365.if \n(82<\n(38 .nr 82 \n(38
366.nr 38 \wYES
367.if \n(82<\n(38 .nr 82 \n(38
368.nr 38 \wNO
369.if \n(82<\n(38 .nr 82 \n(38
370.nr 38 \wYES
371.if \n(82<\n(38 .nr 82 \n(38
372.nr 38 \wNO
373.if \n(82<\n(38 .nr 82 \n(38
374.82
375.rm 82
376.nr 38 \n(a-
377.if \n(82<\n(38 .nr 82 \n(38
378.nr 83 0
379.nr 38 \wNO
380.if \n(83<\n(38 .nr 83 \n(38
381.nr 38 \wNO
382.if \n(83<\n(38 .nr 83 \n(38
383.nr 38 \wNO
384.if \n(83<\n(38 .nr 83 \n(38
385.nr 38 \wNO
386.if \n(83<\n(38 .nr 83 \n(38
387.nr 38 \wYES
388.if \n(83<\n(38 .nr 83 \n(38
389.nr 38 \wYES
390.if \n(83<\n(38 .nr 83 \n(38
391.nr 38 \wYES
392.if \n(83<\n(38 .nr 83 \n(38
393.nr 38 \wNO
394.if \n(83<\n(38 .nr 83 \n(38
395.nr 38 \wNO
396.if \n(83<\n(38 .nr 83 \n(38
397.nr 38 \wYES
398.if \n(83<\n(38 .nr 83 \n(38
399.83
400.rm 83
401.nr 38 \n(b-
402.if \n(83<\n(38 .nr 83 \n(38
403.nr 84 0
404.nr 38 \w\f3Privileges Granted\fP
405.if \n(84<\n(38 .nr 84 \n(38
406.nr 38 \wAll privileges
407.if \n(84<\n(38 .nr 84 \n(38
408.nr 38 \wAll privileges (1)
409.if \n(84<\n(38 .nr 84 \n(38
410.nr 38 \wAll privileges (1)
411.if \n(84<\n(38 .nr 84 \n(38
412.84
413.rm 84
414.nr 38 \n(c-
415.if \n(84<\n(38 .nr 84 \n(38
416.nr 38 \n(d-
417.if \n(84<\n(38 .nr 84 \n(38
418.nr 38 \n(e-
419.if \n(84<\n(38 .nr 84 \n(38
420.nr 38 \n(f-
421.if \n(84<\n(38 .nr 84 \n(38
422.nr 38 \n(g-
423.if \n(84<\n(38 .nr 84 \n(38
424.nr 38 \n(h-
425.if \n(84<\n(38 .nr 84 \n(38
426.nr 38 \n(i-
427.if \n(84<\n(38 .nr 84 \n(38
428.35
429.nf
430.ll \n(34u
431.nr 38 1n
432.nr 79 0
433.nr 40 \n(79+(0*\n(38)
434.nr 80 +\n(40
435.nr 41 \n(80+(3*\n(38)
436.nr 81 +\n(41
437.nr 42 \n(81+(3*\n(38)
438.nr 82 +\n(42
439.nr 43 \n(82+(3*\n(38)
440.nr 83 +\n(43
441.nr 44 \n(83+(3*\n(38)
442.nr 84 +\n(44
443.nr TW \n(84
444.if t .if \n(TW>\n(.li .tm Table at line 161 file Input is too wide - \n(TW units
445.fc  
446.nr #T 0-1
447.nr #a 0-1
448.eo
449.de T#
450.ds #d .d
451.if \(ts\n(.z\(ts\(ts .ds #d nl
452.mk ##
453.nr ## -1v
454.ls 1
455.ls
456..
457.ec
458.ne \n(a|u+\n(.Vu
459.ne \n(b|u+\n(.Vu
460.if (\n(a|+\n(#^-1v)>\n(#- .nr #- +(\n(a|+\n(#^-\n(#--1v)
461.if (\n(b|+\n(#^-1v)>\n(#- .nr #- +(\n(b|+\n(#^-\n(#--1v)
462.ta \n(80u \n(81u \n(82u \n(83u \n(84u
463.nr 31 \n(.f
464.nr 35 1m
465\&\h'|\n(40u'\f3JAR File Type\fP\h'|\n(41u'\f3Identity in 1.1 database\fP\h'|\n(42u'\h'|\n(43u'\h'|\n(44u'\f3Privileges Granted\fP
466.mk ##
467.nr 31 \n(##
468.sp |\n(##u-1v
469.nr 37 \n(42u
470.in +\n(37u
471.a+
472.in -\n(37u
473.mk 32
474.if \n(32>\n(31 .nr 31 \n(32
475.sp |\n(##u-1v
476.nr 37 \n(43u
477.in +\n(37u
478.b+
479.in -\n(37u
480.mk 32
481.if \n(32>\n(31 .nr 31 \n(32
482.sp |\n(31u
483.ne \n(c|u+\n(.Vu
484.if (\n(c|+\n(#^-1v)>\n(#- .nr #- +(\n(c|+\n(#^-\n(#--1v)
485.ta \n(80u \n(81u \n(82u \n(83u \n(84u
486.nr 31 \n(.f
487.nr 35 1m
488\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
489.mk ##
490.nr 31 \n(##
491.sp |\n(##u-1v
492.nr 37 \n(44u
493.in +\n(37u
494.c+
495.in -\n(37u
496.mk 32
497.if \n(32>\n(31 .nr 31 \n(32
498.sp |\n(31u
499.ne \n(d|u+\n(.Vu
500.if (\n(d|+\n(#^-1v)>\n(#- .nr #- +(\n(d|+\n(#^-\n(#--1v)
501.ta \n(80u \n(81u \n(82u \n(83u \n(84u
502.nr 31 \n(.f
503.nr 35 1m
504\&\h'|\n(40u'Unsigned JAR\h'|\n(41u'NO\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
505.mk ##
506.nr 31 \n(##
507.sp |\n(##u-1v
508.nr 37 \n(44u
509.in +\n(37u
510.d+
511.in -\n(37u
512.mk 32
513.if \n(32>\n(31 .nr 31 \n(32
514.sp |\n(31u
515.ne \n(e|u+\n(.Vu
516.if (\n(e|+\n(#^-1v)>\n(#- .nr #- +(\n(e|+\n(#^-\n(#--1v)
517.ta \n(80u \n(81u \n(82u \n(83u \n(84u
518.nr 31 \n(.f
519.nr 35 1m
520\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'YES\h'|\n(43u'NO\h'|\n(44u'
521.mk ##
522.nr 31 \n(##
523.sp |\n(##u-1v
524.nr 37 \n(44u
525.in +\n(37u
526.e+
527.in -\n(37u
528.mk 32
529.if \n(32>\n(31 .nr 31 \n(32
530.sp |\n(31u
531.ne \n(f|u+\n(.Vu
532.if (\n(f|+\n(#^-1v)>\n(#- .nr #- +(\n(f|+\n(#^-\n(#--1v)
533.ta \n(80u \n(81u \n(82u \n(83u \n(84u
534.nr 31 \n(.f
535.nr 35 1m
536\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Untrusted\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
537.mk ##
538.nr 31 \n(##
539.sp |\n(##u-1v
540.nr 37 \n(44u
541.in +\n(37u
542.f+
543.in -\n(37u
544.mk 32
545.if \n(32>\n(31 .nr 31 \n(32
546.sp |\n(31u
547.ne \n(g|u+\n(.Vu
548.if (\n(g|+\n(#^-1v)>\n(#- .nr #- +(\n(g|+\n(#^-\n(#--1v)
549.ta \n(80u \n(81u \n(82u \n(83u \n(84u
550.nr 31 \n(.f
551.nr 35 1m
552\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Untrusted\h'|\n(42u'NO\h'|\n(43u'YES\h'|\n(44u'
553.mk ##
554.nr 31 \n(##
555.sp |\n(##u-1v
556.nr 37 \n(44u
557.in +\n(37u
558.g+
559.in -\n(37u
560.mk 32
561.if \n(32>\n(31 .nr 31 \n(32
562.sp |\n(31u
563.ne \n(h|u+\n(.Vu
564.if (\n(h|+\n(#^-1v)>\n(#- .nr #- +(\n(h|+\n(#^-\n(#--1v)
565.ta \n(80u \n(81u \n(82u \n(83u \n(84u
566.nr 31 \n(.f
567.nr 35 1m
568\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'YES\h'|\n(43u'YES\h'|\n(44u'
569.mk ##
570.nr 31 \n(##
571.sp |\n(##u-1v
572.nr 37 \n(44u
573.in +\n(37u
574.h+
575.in -\n(37u
576.mk 32
577.if \n(32>\n(31 .nr 31 \n(32
578.sp |\n(31u
579.ne \n(i|u+\n(.Vu
580.if (\n(i|+\n(#^-1v)>\n(#- .nr #- +(\n(i|+\n(#^-\n(#--1v)
581.ta \n(80u \n(81u \n(82u \n(83u \n(84u
582.nr 31 \n(.f
583.nr 35 1m
584\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'YES\h'|\n(43u'YES\h'|\n(44u'
585.mk ##
586.nr 31 \n(##
587.sp |\n(##u-1v
588.nr 37 \n(44u
589.in +\n(37u
590.i+
591.in -\n(37u
592.mk 32
593.if \n(32>\n(31 .nr 31 \n(32
594.sp |\n(31u
595.ta \n(80u \n(81u \n(82u \n(83u \n(84u
596.nr 31 \n(.f
597.nr 35 1m
598\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'All privileges
599.ta \n(80u \n(81u \n(82u \n(83u \n(84u
600.nr 31 \n(.f
601.nr 35 1m
602\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'YES\h'|\n(43u'NO\h'|\n(44u'All privileges (1)
603.ta \n(80u \n(81u \n(82u \n(83u \n(84u
604.nr 31 \n(.f
605.nr 35 1m
606\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'NO\h'|\n(43u'YES\h'|\n(44u'All privileges (1)
607.fc
608.nr T. 1
609.T# 1
610.35
611.rm a+
612.rm b+
613.rm c+
614.rm d+
615.rm e+
616.rm f+
617.rm g+
618.rm h+
619.rm i+
620.TE
621.if \n-(b.=0 .nr c. \n(.c-\n(d.-42
622
623.LP
624.LP
625Notes:
626.LP
627.RS 3
628.TP 3
6291.
630If an identity/alias is mentioned in the policy file, it must be imported into the keystore for the policy file to have any effect on privileges granted.
631.TP 3
6322.
633The policy file/keystore combination has precedence over a trusted identity in the identity database.
634.TP 3
6353.
636Untrusted identities are ignored in the Java 2 platform.
637.TP 3
6384.
639Only trusted identities can be imported into Java 2 SDK keystores.
640.RE
641
642.LP
643.SS
644Keystore Aliases
645.LP
646.RS 3
647
648.LP
649.LP
650All keystore entities are accessed via unique \f2aliases\fP.
651.LP
652.LP
653When using \f3jarsigner\fP to sign a JAR file, you must specify the alias for the keystore entry containing the private key needed to generate the signature. For example, the following will sign the JAR file named "MyJARFile.jar", using the private key associated with the alias "duke" in the keystore named "mystore" in the "working" directory. Since no output file is specified, it overwrites MyJARFile.jar with the signed JAR file.
654.LP
655.nf
656\f3
657.fl
658 jarsigner \-keystore /working/mystore \-storepass myspass
659.fl
660 \-keypass dukekeypasswd MyJARFile.jar duke
661.fl
662\fP
663.fi
664
665.LP
666.LP
667Keystores are protected with a password, so the store password (in this case "myspass") must be specified. You will be prompted for it if you don't specify it on the command line. Similarly, private keys are protected in a keystore with a password, so the private key's password (in this case "dukekeypasswd") must be specified, and you will be prompted for it if you don't specify it on the command line and it isn't the same as the store password.
668.LP
669.RE
670.SS
671Keystore Location
672.LP
673.RS 3
674
675.LP
676.LP
677\f3jarsigner\fP has a \f2\-keystore\fP option for specifying the URL of the keystore to be used. The keystore is by default stored in a file named \f2.keystore\fP in the user's home directory, as determined by the \f2user.home\fP system property. On Solaris systems \f2user.home\fP defaults to the user's home directory.
678.LP
679.LP
680Note that the input stream from the \f2\-keystore\fP option is passed to the \f2KeyStore.load\fP method. If \f2NONE\fP is specified as the URL, then a null stream is passed to the \f2KeyStore.load\fP method. \f2NONE\fP should be specified if the \f2KeyStore\fP is not file\-based, for example, if it resides on a hardware token device.
681.LP
682.RE
683.SS
684Keystore Implementation
685.LP
686.RS 3
687
688.LP
689.LP
690The \f2KeyStore\fP class provided in the \f2java.security\fP package supplies well\-defined interfaces to access and modify the information in a keystore. It is possible for there to be multiple different concrete implementations, where each implementation is that for a particular \f2type\fP of keystore.
691.LP
692.LP
693Currently, there are two command\-line tools that make use of keystore implementations (\f3keytool\fP and \f3jarsigner\fP), and also a GUI\-based tool named \f3Policy Tool\fP. Since \f2KeyStore\fP is publicly available, Java 2 SDK users can write additional security applications that use it.
694.LP
695.LP
696There is a built\-in default implementation, provided by Sun Microsystems. It implements the keystore as a file, utilizing a proprietary keystore type (format) named "JKS". It protects each private key with its individual password, and also protects the integrity of the entire keystore with a (possibly different) password.
697.LP
698.LP
699Keystore implementations are provider\-based. More specifically, the application interfaces supplied by \f2KeyStore\fP are implemented in terms of a "Service Provider Interface" (SPI). That is, there is a corresponding abstract \f2KeystoreSpi\fP class, also in the \f2java.security\fP package, which defines the Service Provider Interface methods that "providers" must implement. (The term "provider" refers to a package or a set of packages that supply a concrete implementation of a subset of services that can be accessed by the Java Security API.) Thus, to provide a keystore implementation, clients must implement a provider and supply a KeystoreSpi subclass implementation, as described in
700.na
701\f2How to Implement a Provider for the Java Cryptography Architecture\fP @
702.fi
703http://java.sun.com/javase/6/docs/technotes/guides/security/HowToImplAProvider.html.
704.LP
705.LP
706Applications can choose different \f2types\fP of keystore implementations from different providers, using the "getInstance" factory method supplied in the \f2KeyStore\fP class. A keystore type defines the storage and data format of the keystore information, and the algorithms used to protect private keys in the keystore and the integrity of the keystore itself. Keystore implementations of different types are not compatible.
707.LP
708.LP
709\f3keytool\fP works on any file\-based keystore implementation. (It treats the keytore location that is passed to it at the command line as a filename and converts it to a FileInputStream, from which it loads the keystore information.) The \f3jarsigner\fP and \f3policytool\fP tools, on the other hand, can read a keystore from any location that can be specified using a URL.
710.LP
711.LP
712For \f3jarsigner\fP and \f3keytool\fP, you can specify a keystore type at the command line, via the \f2\-storetype\fP option. For \f3Policy Tool\fP, you can specify a keystore type via the "Change Keystore" command in the Edit menu.
713.LP
714.LP
715If you don't explicitly specify a keystore type, the tools choose a keystore implementation based simply on the value of the \f2keystore.type\fP property specified in the security properties file. The security properties file is called \f2java.security\fP, and it resides in the SDK security properties directory, \f2java.home\fP/lib/security, where \f2java.home\fP is the runtime environment's directory (the \f2jre\fP directory in the SDK or the top\-level directory of the Java 2 Runtime Environment).
716.LP
717.LP
718Each tool gets the \f2keystore.type\fP value and then examines all the currently\-installed providers until it finds one that implements keystores of that type. It then uses the keystore implementation from that provider.
719.LP
720.LP
721The \f2KeyStore\fP class defines a static method named \f2getDefaultType\fP that lets applications and applets retrieve the value of the \f2keystore.type\fP property. The following line of code creates an instance of the default keystore type (as specified in the \f2keystore.type\fP property):
722.LP
723.nf
724\f3
725.fl
726 KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
727.fl
728\fP
729.fi
730
731.LP
732.LP
733The default keystore type is "jks" (the proprietary type of the keystore implementation provided by Sun). This is specified by the following line in the security properties file:
734.LP
735.nf
736\f3
737.fl
738 keystore.type=jks
739.fl
740\fP
741.fi
742
743.LP
744.LP
745Note: Case doesn't matter in keystore type designations. For example, "JKS" would be considered the same as "jks".
746.LP
747.LP
748To have the tools utilize a keystore implementation other than the default, change that line to specify a different keystore type. For example, if you have a provider package that supplies a keystore implementation for a keystore type called "pkcs12", change the line to
749.LP
750.nf
751\f3
752.fl
753 keystore.type=pkcs12
754.fl
755\fP
756.fi
757
758.LP
759.LP
760Note that if you us the PKCS#11 provider package, you should refer to the
761.na
762\f2KeyTool and JarSigner\fP @
763.fi
764http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#keytooljarsigner section of the Java PKCS#11 Reference Guide for details.
765.LP
766.RE
767.RE
768.SS
769Supported Algorithms
770.LP
771.RS 3
772
773.LP
774.LP
775By default, \f3jarsigner\fP signs a JAR file using either
776.LP
777.RS 3
778.TP 2
779o
780DSA (Digital Signature Algorithm) with the SHA\-1 digest algorithm, or
781.TP 2
782o
783the RSA algorithm with the MD5 digest algorithm.
784.RE
785
786.LP
787.LP
788That is, if the signer's public and private keys are DSA keys, \f3jarsigner\fP will sign the JAR file using the "SHA1withDSA" algorithm. If the signer's keys are RSA keys, \f3jarsigner\fP will attempt to sign the JAR file using the "MD5withRSA" algorithm.
789.LP
790.LP
791These default signature algorithms can be overridden using the \f2\-sigalg\fP option.
792.LP
793.RE
794.SS
795The Signed JAR File
796.LP
797.RS 3
798
799.LP
800.LP
801When \f3jarsigner\fP is used to sign a JAR file, the output signed JAR file is exactly the same as the input JAR file, except that it has two additional files placed in the META\-INF directory:
802.LP
803.RS 3
804.TP 2
805o
806a signature file, with a .SF extension, and
807.TP 2
808o
809a signature block file, with a .DSA extension.
810.RE
811
812.LP
813.LP
814The base file names for these two files come from the value of the \f2\-sigFile\fP option. For example, if the option appears as
815.LP
816.nf
817\f3
818.fl
819 \-sigFile MKSIGN
820.fl
821\fP
822.fi
823
824.LP
825.LP
826the files are named "MKSIGN.SF" and "MKSIGN.DSA".
827.LP
828.LP
829If no \f2\-sigfile\fP option appears on the command line, the base file name for the .SF and .DSA files will be the first 8 characters of the alias name specified on the command line, all converted to upper case. If the alias name has fewer than 8 characters, the full alias name is used. If the alias name contains any characters that are not allowed in a signature file name, each such character is converted to an underscore ("_") character in forming the file name. Legal characters include letters, digits, underscores, and hyphens.
830.LP
831\f3The Signature (.SF) File\fP
832.LP
833.RS 3
834
835.LP
836.LP
837A signature file (the .SF file) looks similar to the manifest file that is always included in a JAR file when \f3jarsigner\fP is used to sign the file. That is, for each source file included in the JAR file, the .SF file has three lines, just as in the manifest file, listing the following:
838.LP
839.RS 3
840.TP 2
841o
842the file name,
843.TP 2
844o
845the name of the digest algorithm used (SHA), and
846.TP 2
847o
848a SHA digest value.
849.RE
850
851.LP
852.LP
853In the manifest file, the SHA digest value for each source file is the digest (hash) of the binary data in the source file. In the .SF file, on the other hand, the digest value for a given source file is the hash of the three lines in the manifest file for the source file.
854.LP
855.LP
856The signature file also, by default, includes a header containing a hash of the whole manifest file. The presence of the header enables verification optimization, as described in JAR File Verification.
857.LP
858.RE
859\f3The Signature Block (.DSA) File\fP
860.LP
861.RS 3
862
863.LP
864.LP
865The .SF file is signed and the signature is placed in the .DSA file. The .DSA file also contains, encoded inside it, the certificate or certificate chain from the keystore which authenticates the public key corresponding to the private key used for signing.
866.LP
867.RE
868.RE
869.SS
870Signature Timestamp
871.LP
872.RS 3
873
874.LP
875.LP
876As of the J2SE 5.0 release, the \f2jarsigner\fP tool can now generate and store a signature timestamp when signing a JAR file. In addition, \f2jarsigner\fP supports alternative signing mechanisms. This behavior is optional and is controlled by the user at the time of signing through these options:
877.LP
878.RS 3
879.TP 2
880o
881\f2\-tsa url\fP
882.TP 2
883o
884\f2\-tsacert alias\fP
885.TP 2
886o
887\f2\-altsigner class\fP
888.TP 2
889o
890\f2\-altsignerpath classpathlist\fP
891.RE
892
893.LP
894.LP
895Each of these options is detailed in the Options section below.
896.LP
897.RE
898.SS
899JAR File Verification
900.LP
901.RS 3
902
903.LP
904.LP
905A successful JAR file verification occurs if the signature(s) are valid, and none of the files that were in the JAR file when the signatures were generated have been changed since then. JAR file verification involves the following steps:
906.LP
907.RS 3
908.TP 3
9091.
910Verify the signature of the .SF file itself.
911.LP
912That is, the verification ensures that the signature stored in each signature block (.DSA) file was in fact generated using the private key corresponding to the public key whose certificate (or certificate chain) also appears in the .DSA file. It also ensures that the signature is a valid signature of the corresponding signature (.SF) file, and thus the .SF file has not been tampered with.
913.TP 3
9142.
915Verify the digest listed in each entry in the .SF file with each corresponding section in the manifest.
916.LP
917The .SF file by default includes a header containing a hash of the entire manifest file. When the header is present, then the verification can check to see whether or not the hash in the header indeed matches the hash of the manifest file. If that is the case, verification proceeds to the next step.
918.LP
919If that is not the case, a less optimized verification is required to ensure that the hash in each source file information section in the .SF file equals the hash of its corresponding section in the manifest file (see The Signature (.SF) File).
920.LP
921One reason the hash of the manifest file that is stored in the .SF file header may not equal the hash of the current manifest file would be because one or more files were added to the JAR file (using the \f2jar\fP tool) after the signature (and thus the .SF file) was generated. When the \f2jar\fP tool is used to add files, the manifest file is changed (sections are added to it for the new files), but the .SF file is not. A verification is still considered successful if none of the files that were in the JAR file when the signature was generated have been changed since then, which is the case if the hashes in the non\-header sections of the .SF file equal the hashes of the corresponding sections in the manifest file.
922.TP 3
9233.
924Read each file in the JAR file that has an entry in the .SF file. While reading, compute the file's digest, and then compare the result with the digest for this file in the manifest section. The digests should be the same, or verification fails.
925.RE
926
927.LP
928.LP
929If any serious verification failures occur during the verification process, the process is stopped and a security exception is thrown. It is caught and displayed by \f3jarsigner\fP.
930.LP
931.RE
932.SS
933Multiple Signatures for a JAR File
934.LP
935.RS 3
936
937.LP
938.LP
939A JAR file can be signed by multiple people simply by running the \f3jarsigner\fP tool on the file multiple times, specifying the alias for a different person each time, as in:
940.LP
941.nf
942\f3
943.fl
944 jarsigner myBundle.jar susan
945.fl
946 jarsigner myBundle.jar kevin
947.fl
948\fP
949.fi
950
951.LP
952.LP
953When a JAR file is signed multiple times, there are multiple .SF and .DSA files in the resulting JAR file, one pair for each signature. Thus, in the example above, the output JAR file includes files with the following names:
954.LP
955.nf
956\f3
957.fl
958 SUSAN.SF
959.fl
960 SUSAN.DSA
961.fl
962 KEVIN.SF
963.fl
964 KEVIN.DSA
965.fl
966\fP
967.fi
968
969.LP
970.LP
971Note: It is also possible for a JAR file to have mixed signatures, some generated by the JDK 1.1 \f3javakey\fP tool and others by \f3jarsigner\fP. That is, \f3jarsigner\fP can be used to sign JAR files already previously signed using \f3javakey\fP.
972.LP
973.RE
974.SH "OPTIONS"
975.LP
976
977.LP
978.LP
979The various \f3jarsigner\fP options are listed and described below. Note:
980.LP
981.RS 3
982.TP 2
983o
984All option names are preceded by a minus sign (\-).
985.TP 2
986o
987The options may be provided in any order.
988.TP 2
989o
990Items in italics (option values) represent the actual values that must be supplied.
991.TP 2
992o
993The \f2\-keystore\fP, \f2\-storepass\fP, \f2\-keypass\fP, \f2\-sigfile\fP, \f2\-sigalg\fP, \f2\-digestalg\fP, and \f2\-signedjar\fP options are only relevant when signing a JAR file, not when verifying a signed JAR file. Similarly, an alias is only specified on the command line when signing a JAR file.
994.RE
995
996.LP
997.RS 3
998.TP 3
999\-keystore url
1000Specifies the URL that tells the keystore location. This defaults to the file \f2.keystore\fP in the user's home directory, as determined by the "user.home" system property.
1001.LP
1002A keystore is required when signing, so you must explicitly specify one if the default keystore does not exist (or you want to use one other than the default).
1003.LP
1004A keystore is \f2not\fP required when verifying, but if one is specified, or the default exists, and the \f2\-verbose\fP option was also specified, additional information is output regarding whether or not any of the certificates used to verify the JAR file are contained in that keystore.
1005.LP
1006Note: the \f2\-keystore\fP argument can actually be a file name (and path) specification rather than a URL, in which case it will be treated the same as a "file:" URL. That is,
1007.nf
1008\f3
1009.fl
1010 \-keystore \fP\f4filePathAndName\fP\f3
1011.fl
1012\fP
1013.fi
1014is treated as equivalent to
1015.nf
1016\f3
1017.fl
1018 \-keystore file:\fP\f4filePathAndName\fP\f3
1019.fl
1020\fP
1021.fi
1022If the Sun PKCS#11 provider has been configured in the \f2java.security\fP security properties file (located in the JRE's \f2$JAVA_HOME/lib/security\fP directory), then keytool and jarsigner can operate on the PKCS#11 token by specifying these options:
1023.RS 3
1024.TP 2
1025o
1026\f2\-keystore NONE\fP
1027.TP 2
1028o
1029\f2\-storetype PKCS11\fP
1030.RE
1031For example, this command lists the contents of the configured PKCS#11 token:
1032.RS 3
1033
1034.LP
1035.nf
1036\f3
1037.fl
1038 jarsigner \-keystore NONE \-storetype PKCS11 \-list
1039.fl
1040
1041.fl
1042\fP
1043.fi
1044.RE
1045.TP 3
1046\-storetype storetype
1047Specifies the type of keystore to be instantiated. The default keystore type is the one that is specified as the value of the "keystore.type" property in the security properties file, which is returned by the static \f2getDefaultType\fP method in \f2java.security.KeyStore\fP.
1048.LP
1049The PIN for a PCKS#11 token can also be specified using the \f2\-storepass\fP option. If none has been specified, keytool and jarsigner will prompt for the token PIN. If the token has a protected authentication path (such as a dedicated PIN\-pad or a biometric reader), then the \f2\-protected\fP option must be specified and no password options can be specified.
1050.TP 3
1051\-storepass password
1052Specifies the password which is required to access the keystore. This is only needed when signing (not verifying) a JAR file. In that case, if a \f2\-storepass\fP option is not provided at the command line, the user is prompted for the password.
1053.LP
1054Note: The password shouldn't be specified on the command line or in a script unless it is for testing purposes, or you are on a secure system. Also, when typing in a password at the password prompt, the password is echoed (displayed exactly as typed), so be careful not to type it in front of anyone.
1055.TP 3
1056\-keypass password
1057Specifies the password used to protect the private key of the keystore entry addressed by the alias specified on the command line. The password is required when using \f3jarsigner\fP to sign a JAR file. If no password is provided on the command line, and the required password is different from the store password, the user is prompted for it.
1058.LP
1059Note: The password shouldn't be specified on the command line or in a script unless it is for testing purposes, or you are on a secure system. Also, when typing in a password at the password prompt, the password is echoed (displayed exactly as typed), so be careful not to type it in front of anyone.
1060.TP 3
1061\-sigfile file
1062Specifies the base file name to be used for the generated .SF and .DSA files. For example, if \f2file\fP is "DUKESIGN", the generated .SF and .DSA files will be named "DUKESIGN.SF" and "DUKESIGN.DSA", and will be placed in the "META\-INF" directory of the signed JAR file.
1063.LP
1064The characters in \f2file\fP must come from the set "a\-zA\-Z0\-9_\-". That is, only letters, numbers, underscore, and hyphen characters are allowed. Note: All lowercase characters will be converted to uppercase for the .SF and .DSA file names.
1065.LP
1066If no \f2\-sigfile\fP option appears on the command line, the base file name for the .SF and .DSA files will be the first 8 characters of the alias name specified on the command line, all converted to upper case. If the alias name has fewer than 8 characters, the full alias name is used. If the alias name contains any characters that are not legal in a signature file name, each such character is converted to an underscore ("_") character in forming the file name.
1067.TP 3
1068\-sigalg algorithm
1069.RS 3
1070
1071.LP
1072Specifies the name of the signature algorithm to use to sign the JAR file.
1073.LP
1074See
1075.na
1076\f2Appendix A\fP @
1077.fi
1078http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#appa of the Java Cryptography Architecture for a list of standard signature algorithm names. This algorithm must be compatible with the private key used to sign the JAR file. If this option is not specified, SHA1withDSA or MD5withRSA will be used depending on the type of private key. There must either be a statically installed provider supplying an implementation of the specified algorithm or the user must specify one with the \f2\-providerClass\fP option, otherwise the command will not succeed.
1079.LP
1080.RE
1081.TP 3
1082\-digestalg algorithm
1083.RS 3
1084Specifies the name of the message digest algorithm to use when digesting the entries of a jar file.
1085.LP
1086See
1087.na
1088\f2Appendix A\fP @
1089.fi
1090http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#appa of the Java Cryptography Architecture for a list of standard message digest algorithm names. If this option is not specified, SHA\-1 will be used. There must either be a statically installed provider supplying an implementation of the specified algorithm or the user must specify one with the \f2\-providerClass\fP option, otherwise the command will not succeed.
1091.LP
1092.RE
1093.TP 3
1094\-signedjar file
1095Specifies the name to be used for the signed JAR file.
1096.LP
1097If no name is specified on the command line, the name used is the same as the input JAR file name (the name of the JAR file to be signed); in other words, that file is overwritten with the signed JAR file.
1098.TP 3
1099\-verify
1100If this appears on the command line, the specified JAR file will be verified, not signed. If the verification is successful, "jar verified" will be displayed. If you try to verify an unsigned JAR file, or a JAR file signed with an unsupported algorithm (e.g., RSA when you don't have an RSA provider installed), the following is displayed: "jar is unsigned. (signatures missing or not parsable)"
1101.LP
1102It is possible to verify JAR files signed using either \f3jarsigner\fP or the JDK 1.1 \f3javakey\fP tool, or both.
1103.LP
1104For further information on verification, see JAR File Verification.
1105.TP 3
1106\-certs
1107If this appears on the command line, along with the \f2\-verify\fP and \f2\-verbose\fP options, the output includes certificate information for each signer of the JAR file. This information includes
1108.RS 3
1109.TP 2
1110o
1111the name of the type of certificate (stored in the .DSA file) that certifies the signer's public key
1112.TP 2
1113o
1114if the certificate is an X.509 certificate (more specifically, an instance of \f2java.security.cert.X509Certificate\fP): the distinguished name of the signer
1115.RE
1116.LP
1117The keystore is also examined. If no keystore value is specified on the command line, the default keystore file (if any) will be checked. If the public key certificate for a signer matches an entry in the keystore, then the following information will also be displayed:
1118.RS 3
1119.TP 2
1120o
1121in parentheses, the alias name for the keystore entry for that signer. If the signer actually comes from a JDK 1.1 identity database instead of from a keystore, the alias name will appear in brackets instead of parentheses.
1122.RE
1123.TP 3
1124\-verbose
1125If this appears on the command line, it indicates "verbose" mode, which causes \f3jarsigner\fP to output extra information as to the progress of the JAR signing or verification.
1126.TP 3
1127\-internalsf
1128In the past, the .DSA (signature block) file generated when a JAR file was signed used to include a complete encoded copy of the .SF file (signature file) also generated. This behavior has been changed. To reduce the overall size of the output JAR file, the .DSA file by default doesn't contain a copy of the .SF file anymore. But if \f2\-internalsf\fP appears on the command line, the old behavior is utilized. \f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP
1129.TP 3
1130\-sectionsonly
1131If this appears on the command line, the .SF file (signature file) generated when a JAR file is signed does \f2not\fP include a header containing a hash of the whole manifest file. It just contains information and hashes related to each individual source file included in the JAR file, as described in The Signature (.SF) File .
1132.LP
1133By default, this header is added, as an optimization. When the header is present, then whenever the JAR file is verified, the verification can first check to see whether or not the hash in the header indeed matches the hash of the whole manifest file. If so, verification proceeds to the next step. If not, it is necessary to do a less optimized verification that the hash in each source file information section in the .SF file equals the hash of its corresponding section in the manifest file.
1134.LP
1135For further information, see JAR File Verification.
1136.LP
1137\f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP
1138.TP 3
1139\-protected
1140Either \f2true\fP or \f2false\fP. This value should be specified as \f2true\fP if a password must be given via a protected authentication path such as a dedicated PIN reader.
1141.RE
1142.RS 3
1143.TP 3
1144\-provider provider\-class\-name
1145Used to specify the name of cryptographic service provider's master class file when the service provider is not listed in the security properties file, \f2java.security\fP.
1146.LP
1147Used in conjunction with the \f2\-providerArg\fP \f2ConfigFilePath\fP option, keytool and jarsigner will install the provider dynamically (where \f2ConfigFilePath\fP is the path to the token configuration file). Here's an example of a command to list a PKCS#11 keystore when the Sun PKCS#11 provider has not been configured in the security properties file.
1148.RS 3
1149
1150.LP
1151.nf
1152\f3
1153.fl
1154jarsigner \-keystore NONE \-storetype PKCS11 \\
1155.fl
1156 \-providerClass sun.security.pkcs11.SunPKCS11 \\
1157.fl
1158 \-providerArg /foo/bar/token.config \\
1159.fl
1160 \-list
1161.fl
1162\fP
1163.fi
1164.RE
1165.TP 3
1166\-providerName providerName
1167If more than one provider has been configured in the \f2java.security\fP security properties file, you can use the \f2\-providerName\fP option to target a specific provider instance. The argument to this option is the name of the provider.
1168.LP
1169For the Sun PKCS#11 provider, \f2providerName\fP is of the form \f2SunPKCS11\-\fP\f2TokenName\fP, where \f2TokenName\fP is the name suffix that the provider instance has been configured with, as detailed in the
1170.na
1171\f2configuration attributes table\fP @
1172.fi
1173http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#KeyToolJarSigner#ATTRS. For example, the following command lists the contents of the PKCS#11 keystore provider instance with name suffix \f2SmartCard\fP:
1174.RS 3
1175
1176.LP
1177.nf
1178\f3
1179.fl
1180jarsigner \-keystore NONE \-storetype PKCS11 \\
1181.fl
1182 \-providerName SunPKCS11\-SmartCard \\
1183.fl
1184 \-list
1185.fl
1186\fP
1187.fi
1188.RE
1189.TP 3
1190\-Jjavaoption
1191Passes through the specified \f2javaoption\fP string directly to the Java interpreter. (\f3jarsigner\fP is actually a "wrapper" around the interpreter.) This option should not contain any spaces. It is useful for adjusting the execution environment or memory usage. For a list of possible interpreter options, type \f2java \-h\fP or \f2java \-X\fP at the command line.
1192.LP
1193.TP 3
1194\-tsa url
1195If \f2"\-tsa http://example.tsa.url"\fP appears on the command line when signing a JAR file then a timestamp is generated for the signature. The URL, \f2http://example.tsa.url\fP, identifies the location of the Time Stamping Authority (TSA). It overrides any URL found via the \f2\-tsacert\fP option. The \f2\-tsa\fP option does not require the TSA's public key certificate to be present in the keystore.
1196.LP
1197To generate the timestamp, \f2jarsigner\fP communicates with the TSA using the Time\-Stamp Protocol (TSP) defined in
1198.na
1199\f2RFC 3161\fP @
1200.fi
1201http://www.ietf.org/rfc/rfc3161.txt. If successful, the timestamp token returned by the TSA is stored along with the signature in the signature block file.
1202.LP
1203.TP 3
1204\-tsacert alias
1205If \f2"\-tsacert alias"\fP appears on the command line when signing a JAR file then a timestamp is generated for the signature. The \f2alias\fP identifies the TSA's public key certificate in the keystore that is currently in effect. The entry's certificate is examined for a Subject Information Access extension that contains a URL identifying the location of the TSA.
1206.LP
1207The TSA's public key certificate must be present in the keystore when using \f2\-tsacert\fP.
1208.LP
1209.TP 3
1210\-altsigner class
1211Specifies that an alternative signing mechanism be used. The fully\-qualified class name identifies a class file that extends the \f2com.sun.jarsigner.ContentSigner abstract class\fP. The path to this class file is defined by the \f2\-altsignerpath\fP option. If the \f2\-altsigner\fP option is used, \f2jarsigner\fP uses the signing mechanism provided by the specified class. Otherwise, \f2jarsigner\fP uses its default signing mechanism.
1212.LP
1213For example, to use the signing mechanism provided by a class named \f2com.sun.sun.jarsigner.AuthSigner\fP, use the \f2jarsigner\fP option \f2"\-altsigner com.sun.jarsigner.AuthSigner"\fP
1214.LP
1215.TP 3
1216\-altsignerpath classpathlist
1217Specifies the path to the class file (the class file name is specified with the \f2\-altsigner\fP option described above) and any JAR files it depends on. If the class file is in a JAR file, then this specifies the path to that JAR file, as shown in the example below.
1218.LP
1219An absolute path or a path relative to the current directory may be specified. If \f2classpathlist\fP contains multiple paths or JAR files, they should be separated with a colon (\f2:\fP) on Solaris and a semi\-colon (\f2;\fP) on Windows. This option is not necessary if the class is already in the search path.
1220.LP
1221Example of specifying the path to a jar file that contains the class file:
1222.RS 3
1223
1224.LP
1225.LP
1226\f2\-altsignerpath /home/user/lib/authsigner.jar\fP
1227.LP
1228.RE
1229.LP
1230Note that the JAR file name is included.
1231.LP
1232Example of specifying the path to the jar file that contains the class file:
1233.RS 3
1234.LP
1235\f2\-altsignerpath /home/user/classes/com/sun/tools/jarsigner/\fP
1236.LP
1237.RE
1238.LP
1239Note that the JAR file name is omitted.
1240.RE
1241.SH "EXAMPLES"
1242.LP
1243
1244.LP
1245.SS
1246Signing a JAR File
1247.LP
1248.RS 3
1249
1250.LP
1251.LP
1252Suppose you have a JAR file named "bundle.jar" and you'd like to sign it using the private key of the user whose keystore alias is "jane" in the keystore named "mystore" in the "working" directory. Suppose the keystore password is "myspass" and the password for \f2jane\fP's private key is "j638klm". You can use the following to sign the JAR file and name the signed JAR file "sbundle.jar":
1253.LP
1254.nf
1255\f3
1256.fl
1257 jarsigner \-keystore /working/mystore \-storepass myspass
1258.fl
1259 \-keypass j638klm \-signedjar sbundle.jar bundle.jar jane
1260.fl
1261\fP
1262.fi
1263
1264.LP
1265.LP
1266Note that there is no \f2\-sigfile\fP specified in the command above, so the generated .SF and .DSA files to be placed in the signed JAR file will have default names based on the alias name. That is, they will be named \f2JANE.SF\fP and \f2JANE.DSA\fP.
1267.LP
1268.LP
1269If you want to be prompted for the store password and the private key password, you could shorten the above command to
1270.LP
1271.nf
1272\f3
1273.fl
1274 jarsigner \-keystore /working/mystore
1275.fl
1276 \-signedjar sbundle.jar bundle.jar jane
1277.fl
1278\fP
1279.fi
1280
1281.LP
1282.LP
1283If the keystore to be used is the default keystore (the one named ".keystore" in your home directory), you don't need to specify a keystore, as in:
1284.LP
1285.nf
1286\f3
1287.fl
1288 jarsigner \-signedjar sbundle.jar bundle.jar jane
1289.fl
1290\fP
1291.fi
1292
1293.LP
1294.LP
1295Finally, if you want the signed JAR file to simply overwrite the input JAR file (\f2bundle.jar\fP), you don't need to specify a \f2\-signedjar\fP option:
1296.LP
1297.nf
1298\f3
1299.fl
1300 jarsigner bundle.jar jane
1301.fl
1302\fP
1303.fi
1304.RE
1305
1306.LP
1307.SS
1308Verifying a Signed JAR File
1309.LP
1310.RS 3
1311
1312.LP
1313.LP
1314To verify a signed JAR file, that is, to verify that the signature is valid and the JAR file has not been tampered with, use a command such as the following:
1315.LP
1316.nf
1317\f3
1318.fl
1319 jarsigner \-verify sbundle.jar
1320.fl
1321\fP
1322.fi
1323
1324.LP
1325.LP
1326If the verification is successful,
1327.LP
1328.nf
1329\f3
1330.fl
1331 jar verified.
1332.fl
1333\fP
1334.fi
1335
1336.LP
1337.LP
1338is displayed. Otherwise, an error message appears.
1339.LP
1340.LP
1341You can get more information if you use the \f2\-verbose\fP option. A sample use of \f3jarsigner\fP with the \f2\-verbose\fP option is shown below, along with sample output:
1342.LP
1343.nf
1344\f3
1345.fl
1346 jarsigner \-verify \-verbose sbundle.jar
1347.fl
1348
1349.fl
1350 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
1351.fl
1352 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
1353.fl
1354 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
1355.fl
1356 smk 2752 Fri Sep 26 16:12:30 PDT 1997 AclEx.class
1357.fl
1358 smk 849 Fri Sep 26 16:12:46 PDT 1997 test.class
1359.fl
1360
1361.fl
1362 s = signature was verified
1363.fl
1364 m = entry is listed in manifest
1365.fl
1366 k = at least one certificate was found in keystore
1367.fl
1368
1369.fl
1370 jar verified.
1371.fl
1372\fP
1373.fi
1374
1375.LP
1376.SS
1377Verification with Certificate Information
1378.LP
1379.LP
1380If you specify the \f2\-certs\fP option when verifying, along with the \f2\-verify\fP and \f2\-verbose\fP options, the output includes certificate information for each signer of the JAR file, including the certificate type, the signer distinguished name information (iff it's an X.509 certificate), and, in parentheses, the keystore alias for the signer if the public key certificate in the JAR file matches that in a keystore entry. For example,
1381.LP
1382.nf
1383\f3
1384.fl
1385 jarsigner \-keystore /working/mystore \-verify \-verbose \-certs myTest.jar
1386.fl
1387
1388.fl
1389 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
1390.fl
1391 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
1392.fl
1393 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
1394.fl
1395 208 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST.SF
1396.fl
1397 1087 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST.DSA
1398.fl
1399 smk 2752 Fri Sep 26 16:12:30 PDT 1997 Tst.class
1400.fl
1401
1402.fl
1403 X.509, CN=Test Group, OU=Java Software, O=Sun Microsystems, L=CUP, S=CA, C=US (javatest)
1404.fl
1405 X.509, CN=Jane Smith, OU=Java Software, O=Sun, L=cup, S=ca, C=us (jane)
1406.fl
1407
1408.fl
1409 s = signature was verified
1410.fl
1411 m = entry is listed in manifest
1412.fl
1413 k = at least one certificate was found in keystore
1414.fl
1415
1416.fl
1417 jar verified.
1418.fl
1419\fP
1420.fi
1421
1422.LP
1423.LP
1424If the certificate for a signer is not an X.509 certificate, there is no distinguished name information. In that case, just the certificate type and the alias are shown. For example, if the certificate is a PGP certificate, and the alias is "bob", you'd get
1425.LP
1426.nf
1427\f3
1428.fl
1429 PGP, (bob)
1430.fl
1431\fP
1432.fi
1433
1434.LP
1435.SS
1436Verification of a JAR File that Includes Identity Database Signers
1437.LP
1438.LP
1439If a JAR file has been signed using the JDK 1.1 \f3javakey\fP tool, and thus the signer is an alias in an identity database, the verification output includes an "i" symbol. If the JAR file has been signed by both an alias in an identity database and an alias in a keystore, both "k" and "i" appear.
1440.LP
1441.LP
1442When the \f2\-certs\fP option is used, any identity database aliases are shown in square brackets rather than the parentheses used for keystore aliases. For example:
1443.LP
1444.nf
1445\f3
1446.fl
1447 jarsigner \-keystore /working/mystore \-verify \-verbose \-certs writeFile.jar
1448.fl
1449
1450.fl
1451 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
1452.fl
1453 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
1454.fl
1455 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
1456.fl
1457 199 Fri Sep 27 12:22:30 PDT 1997 META\-INF/DUKE.SF
1458.fl
1459 1013 Fri Sep 27 12:22:30 PDT 1997 META\-INF/DUKE.DSA
1460.fl
1461 smki 2752 Fri Sep 26 16:12:30 PDT 1997 writeFile.html
1462.fl
1463
1464.fl
1465 X.509, CN=Jane Smith, OU=Java Software, O=Sun, L=cup, S=ca, C=us (jane)
1466.fl
1467 X.509, CN=Duke, OU=Java Software, O=Sun, L=cup, S=ca, C=us [duke]
1468.fl
1469
1470.fl
1471 s = signature was verified
1472.fl
1473 m = entry is listed in manifest
1474.fl
1475 k = at least one certificate was found in keystore
1476.fl
1477 i = at least one certificate was found in identity scope
1478.fl
1479
1480.fl
1481 jar verified.
1482.fl
1483\fP
1484.fi
1485
1486.LP
1487.LP
1488Note that the alias "duke" is in brackets to denote that it is an identity database alias, not a keystore alias.
1489.LP
1490.RE
1491.SH "SEE ALSO"
1492.LP
1493
1494.LP
1495.RS 3
1496.TP 2
1497o
1498jar tool documentation
1499.TP 2
1500o
1501keytool tool documentation
1502.TP 2
1503o
1504the
1505.na
1506\f4Security\fP @
1507.fi
1508http://java.sun.com/docs/books/tutorial/security1.2/index.html trail of the
1509.na
1510\f4Java Tutorial\fP @
1511.fi
1512http://java.sun.com/docs/books/tutorial/trailmap.html for examples of the use of the \f3jarsigner\fP tool
1513.RE
1514
1515.LP
1516
1517.LP
1518