blob: 1e418598035631b0b71a39053622bfb11fcd23a2 [file] [log] [blame]
duke6e45e102007-12-01 00:00:00 +00001.'" t
2."
3." Copyright 2000-2006 Sun Microsystems, Inc. All Rights Reserved.
4." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5."
6." This code is free software; you can redistribute it and/or modify it
7." under the terms of the GNU General Public License version 2 only, as
8." published by the Free Software Foundation.
9."
10." This code is distributed in the hope that it will be useful, but WITHOUT
11." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12." FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13." version 2 for more details (a copy is included in the LICENSE file that
14." accompanied this code).
15."
16." You should have received a copy of the GNU General Public License version
17." 2 along with this work; if not, write to the Free Software Foundation,
18." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19."
20." Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21." CA 95054 USA or visit www.sun.com if you need additional information or
22." have any questions.
23."
24." `
25.TH jarsigner 1 "07 Aug 2006"
26." Generated by html2man
27
28.LP
29.SH NAME
30jarsigner \- JAR Signing and Verification Tool
31.LP
32.RS 3
33
34.LP
35.LP
36Generates signatures for Java ARchive (JAR) files, and verifies the signatures of signed JAR files.
37.LP
38.RE
39.SH "SYNOPSIS"
40.LP
41
42.LP
43.nf
44\f3
45.fl
46\fP\f3jarsigner\fP [ options ] jar\-file alias
47.fl
48\f3jarsigner\fP \-verify [ options ] jar\-file
49.fl
50.fi
51
52.LP
53.SH "DESCRIPTION"
54.LP
55
56.LP
57.LP
58The \f3jarsigner\fP tool is used for two purposes:
59.LP
60.RS 3
61.TP 3
621.
63to sign Java ARchive (JAR) files, and
64.TP 3
652.
66to verify the signatures and integrity of signed JAR files.
67.RE
68
69.LP
70.LP
71The 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.)
72.LP
73.LP
74A \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:
75.LP
76.RS 3
77.TP 2
78o
79Its authenticity can be verified, via a computation that uses the public key corresponding to the private key used to generate the signature.
80.TP 2
81o
82It cannot be forged, assuming the private key is kept secret.
83.TP 2
84o
85It is a function of the data signed and thus can't be claimed to be the signature for other data as well.
86.TP 2
87o
88The signed data cannot be changed; if it is, the signature will no longer verify as being authentic.
89.RE
90
91.LP
92.LP
93In 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.
94.LP
95.LP
96\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.
97.LP
98.LP
99\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).
100.LP
101.LP
102Starting 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.
103.LP
104.LP
105At 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.)
106.LP
107.LP
108The 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.
109.LP
110.SS
111Compatibility with JDK 1.1
112.LP
113.RS 3
114
115.LP
116.LP
117The \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.
118.LP
119.LP
120The 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,
121.LP
122.RS 3
123.TP 2
124o
125It is possible to import the information from an identity database into a keystore, via the \f3keytool\fP \f2\-identitydb\fP command.
126.TP 2
127o
128\f3jarsigner\fP can sign JAR files also previously signed using \f3javakey\fP.
129.TP 2
130o
131\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.
132.RE
133
134.LP
135.LP
136The following table explains how JAR files that were signed in JDK 1.1.x are treated in the Java 2 platform.
137.LP
138.LP
139.TS
140.if \n+(b.=1 .nr d. \n(.c-\n(c.-1
141.de 35
142.ps \n(.s
143.vs \n(.vu
144.in \n(.iu
145.if \n(.u .fi
146.if \n(.j .ad
147.if \n(.j=0 .na
148..
149.nf
150.nr #~ 0
151.if n .nr #~ 0.6n
152.ds #d .d
153.if \(ts\n(.z\(ts\(ts .ds #d nl
154.fc
155.nr 33 \n(.s
156.rm 80 81 82 83 84
157.nr 34 \n(.lu
158.eo
159.am 82
160.br
161.di a+
162.35
163.ft \n(.f
164.ll \n(34u*1u/6u
165.if \n(.l<\n(82 .ll \n(82u
166.in 0
167\f3Trusted Identity imported into Java 2 Platform keystore from 1.1 database (4)\fP
168.br
169.di
170.nr a| \n(dn
171.nr a- \n(dl
172..
173.ec \
174.eo
175.am 83
176.br
177.di b+
178.35
179.ft \n(.f
180.ll \n(34u*1u/6u
181.if \n(.l<\n(83 .ll \n(83u
182.in 0
183\f3Policy File grants privileges to Identity/Alias\fP
184.br
185.di
186.nr b| \n(dn
187.nr b- \n(dl
188..
189.ec \
190.eo
191.am 84
192.br
193.di c+
194.35
195.ft \n(.f
196.ll \n(34u*1u/6u
197.if \n(.l<\n(84 .ll \n(84u
198.in 0
199Default privileges granted to all code.
200.br
201.di
202.nr c| \n(dn
203.nr c- \n(dl
204..
205.ec \
206.eo
207.am 84
208.br
209.di d+
210.35
211.ft \n(.f
212.ll \n(34u*1u/6u
213.if \n(.l<\n(84 .ll \n(84u
214.in 0
215Default privileges granted to all code.
216.br
217.di
218.nr d| \n(dn
219.nr d- \n(dl
220..
221.ec \
222.eo
223.am 84
224.br
225.di e+
226.35
227.ft \n(.f
228.ll \n(34u*1u/6u
229.if \n(.l<\n(84 .ll \n(84u
230.in 0
231Default privileges granted to all code.
232.br
233.di
234.nr e| \n(dn
235.nr e- \n(dl
236..
237.ec \
238.eo
239.am 84
240.br
241.di f+
242.35
243.ft \n(.f
244.ll \n(34u*1u/6u
245.if \n(.l<\n(84 .ll \n(84u
246.in 0
247Default privileges granted to all code. (3)
248.br
249.di
250.nr f| \n(dn
251.nr f- \n(dl
252..
253.ec \
254.eo
255.am 84
256.br
257.di g+
258.35
259.ft \n(.f
260.ll \n(34u*1u/6u
261.if \n(.l<\n(84 .ll \n(84u
262.in 0
263Default privileges granted to all code. (1,3)
264.br
265.di
266.nr g| \n(dn
267.nr g- \n(dl
268..
269.ec \
270.eo
271.am 84
272.br
273.di h+
274.35
275.ft \n(.f
276.ll \n(34u*1u/6u
277.if \n(.l<\n(84 .ll \n(84u
278.in 0
279Default privileges granted to all code plus privileges granted in policy file.
280.br
281.di
282.nr h| \n(dn
283.nr h- \n(dl
284..
285.ec \
286.eo
287.am 84
288.br
289.di i+
290.35
291.ft \n(.f
292.ll \n(34u*1u/6u
293.if \n(.l<\n(84 .ll \n(84u
294.in 0
295Default privileges granted to all code plus privileges granted in policy file. (2)
296.br
297.di
298.nr i| \n(dn
299.nr i- \n(dl
300..
301.ec \
302.35
303.nf
304.ll \n(34u
305.nr 80 0
306.nr 38 \w\f3JAR File Type\fP
307.if \n(80<\n(38 .nr 80 \n(38
308.nr 38 \wSigned JAR
309.if \n(80<\n(38 .nr 80 \n(38
310.nr 38 \wUnsigned 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.nr 38 \wSigned JAR
327.if \n(80<\n(38 .nr 80 \n(38
328.80
329.rm 80
330.nr 81 0
331.nr 38 \w\f3Identity in 1.1 database\fP
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 \wNO
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 \wYES/Untrusted
342.if \n(81<\n(38 .nr 81 \n(38
343.nr 38 \wNO
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.nr 38 \wYES/Trusted
352.if \n(81<\n(38 .nr 81 \n(38
353.81
354.rm 81
355.nr 82 0
356.nr 38 \wNO
357.if \n(82<\n(38 .nr 82 \n(38
358.nr 38 \wNO
359.if \n(82<\n(38 .nr 82 \n(38
360.nr 38 \wYES
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 \wNO
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 \wYES
369.if \n(82<\n(38 .nr 82 \n(38
370.nr 38 \wNO
371.if \n(82<\n(38 .nr 82 \n(38
372.nr 38 \wYES
373.if \n(82<\n(38 .nr 82 \n(38
374.nr 38 \wNO
375.if \n(82<\n(38 .nr 82 \n(38
376.82
377.rm 82
378.nr 38 \n(a-
379.if \n(82<\n(38 .nr 82 \n(38
380.nr 83 0
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 \wNO
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 \wYES
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 \wNO
398.if \n(83<\n(38 .nr 83 \n(38
399.nr 38 \wYES
400.if \n(83<\n(38 .nr 83 \n(38
401.83
402.rm 83
403.nr 38 \n(b-
404.if \n(83<\n(38 .nr 83 \n(38
405.nr 84 0
406.nr 38 \w\f3Privileges Granted\fP
407.if \n(84<\n(38 .nr 84 \n(38
408.nr 38 \wAll privileges
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.nr 38 \wAll privileges (1)
413.if \n(84<\n(38 .nr 84 \n(38
414.84
415.rm 84
416.nr 38 \n(c-
417.if \n(84<\n(38 .nr 84 \n(38
418.nr 38 \n(d-
419.if \n(84<\n(38 .nr 84 \n(38
420.nr 38 \n(e-
421.if \n(84<\n(38 .nr 84 \n(38
422.nr 38 \n(f-
423.if \n(84<\n(38 .nr 84 \n(38
424.nr 38 \n(g-
425.if \n(84<\n(38 .nr 84 \n(38
426.nr 38 \n(h-
427.if \n(84<\n(38 .nr 84 \n(38
428.nr 38 \n(i-
429.if \n(84<\n(38 .nr 84 \n(38
430.35
431.nf
432.ll \n(34u
433.nr 38 1n
434.nr 79 0
435.nr 40 \n(79+(0*\n(38)
436.nr 80 +\n(40
437.nr 41 \n(80+(3*\n(38)
438.nr 81 +\n(41
439.nr 42 \n(81+(3*\n(38)
440.nr 82 +\n(42
441.nr 43 \n(82+(3*\n(38)
442.nr 83 +\n(43
443.nr 44 \n(83+(3*\n(38)
444.nr 84 +\n(44
445.nr TW \n(84
446.if t .if \n(TW>\n(.li .tm Table at line 161 file Input is too wide - \n(TW units
447.fc  
448.nr #T 0-1
449.nr #a 0-1
450.eo
451.de T#
452.ds #d .d
453.if \(ts\n(.z\(ts\(ts .ds #d nl
454.mk ##
455.nr ## -1v
456.ls 1
457.ls
458..
459.ec
460.ne \n(a|u+\n(.Vu
461.ne \n(b|u+\n(.Vu
462.if (\n(a|+\n(#^-1v)>\n(#- .nr #- +(\n(a|+\n(#^-\n(#--1v)
463.if (\n(b|+\n(#^-1v)>\n(#- .nr #- +(\n(b|+\n(#^-\n(#--1v)
464.ta \n(80u \n(81u \n(82u \n(83u \n(84u
465.nr 31 \n(.f
466.nr 35 1m
467\&\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
468.mk ##
469.nr 31 \n(##
470.sp |\n(##u-1v
471.nr 37 \n(42u
472.in +\n(37u
473.a+
474.in -\n(37u
475.mk 32
476.if \n(32>\n(31 .nr 31 \n(32
477.sp |\n(##u-1v
478.nr 37 \n(43u
479.in +\n(37u
480.b+
481.in -\n(37u
482.mk 32
483.if \n(32>\n(31 .nr 31 \n(32
484.sp |\n(31u
485.ne \n(c|u+\n(.Vu
486.if (\n(c|+\n(#^-1v)>\n(#- .nr #- +(\n(c|+\n(#^-\n(#--1v)
487.ta \n(80u \n(81u \n(82u \n(83u \n(84u
488.nr 31 \n(.f
489.nr 35 1m
490\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
491.mk ##
492.nr 31 \n(##
493.sp |\n(##u-1v
494.nr 37 \n(44u
495.in +\n(37u
496.c+
497.in -\n(37u
498.mk 32
499.if \n(32>\n(31 .nr 31 \n(32
500.sp |\n(31u
501.ne \n(d|u+\n(.Vu
502.if (\n(d|+\n(#^-1v)>\n(#- .nr #- +(\n(d|+\n(#^-\n(#--1v)
503.ta \n(80u \n(81u \n(82u \n(83u \n(84u
504.nr 31 \n(.f
505.nr 35 1m
506\&\h'|\n(40u'Unsigned JAR\h'|\n(41u'NO\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
507.mk ##
508.nr 31 \n(##
509.sp |\n(##u-1v
510.nr 37 \n(44u
511.in +\n(37u
512.d+
513.in -\n(37u
514.mk 32
515.if \n(32>\n(31 .nr 31 \n(32
516.sp |\n(31u
517.ne \n(e|u+\n(.Vu
518.if (\n(e|+\n(#^-1v)>\n(#- .nr #- +(\n(e|+\n(#^-\n(#--1v)
519.ta \n(80u \n(81u \n(82u \n(83u \n(84u
520.nr 31 \n(.f
521.nr 35 1m
522\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'YES\h'|\n(43u'NO\h'|\n(44u'
523.mk ##
524.nr 31 \n(##
525.sp |\n(##u-1v
526.nr 37 \n(44u
527.in +\n(37u
528.e+
529.in -\n(37u
530.mk 32
531.if \n(32>\n(31 .nr 31 \n(32
532.sp |\n(31u
533.ne \n(f|u+\n(.Vu
534.if (\n(f|+\n(#^-1v)>\n(#- .nr #- +(\n(f|+\n(#^-\n(#--1v)
535.ta \n(80u \n(81u \n(82u \n(83u \n(84u
536.nr 31 \n(.f
537.nr 35 1m
538\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Untrusted\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
539.mk ##
540.nr 31 \n(##
541.sp |\n(##u-1v
542.nr 37 \n(44u
543.in +\n(37u
544.f+
545.in -\n(37u
546.mk 32
547.if \n(32>\n(31 .nr 31 \n(32
548.sp |\n(31u
549.ne \n(g|u+\n(.Vu
550.if (\n(g|+\n(#^-1v)>\n(#- .nr #- +(\n(g|+\n(#^-\n(#--1v)
551.ta \n(80u \n(81u \n(82u \n(83u \n(84u
552.nr 31 \n(.f
553.nr 35 1m
554\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Untrusted\h'|\n(42u'NO\h'|\n(43u'YES\h'|\n(44u'
555.mk ##
556.nr 31 \n(##
557.sp |\n(##u-1v
558.nr 37 \n(44u
559.in +\n(37u
560.g+
561.in -\n(37u
562.mk 32
563.if \n(32>\n(31 .nr 31 \n(32
564.sp |\n(31u
565.ne \n(h|u+\n(.Vu
566.if (\n(h|+\n(#^-1v)>\n(#- .nr #- +(\n(h|+\n(#^-\n(#--1v)
567.ta \n(80u \n(81u \n(82u \n(83u \n(84u
568.nr 31 \n(.f
569.nr 35 1m
570\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'YES\h'|\n(43u'YES\h'|\n(44u'
571.mk ##
572.nr 31 \n(##
573.sp |\n(##u-1v
574.nr 37 \n(44u
575.in +\n(37u
576.h+
577.in -\n(37u
578.mk 32
579.if \n(32>\n(31 .nr 31 \n(32
580.sp |\n(31u
581.ne \n(i|u+\n(.Vu
582.if (\n(i|+\n(#^-1v)>\n(#- .nr #- +(\n(i|+\n(#^-\n(#--1v)
583.ta \n(80u \n(81u \n(82u \n(83u \n(84u
584.nr 31 \n(.f
585.nr 35 1m
586\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'YES\h'|\n(43u'YES\h'|\n(44u'
587.mk ##
588.nr 31 \n(##
589.sp |\n(##u-1v
590.nr 37 \n(44u
591.in +\n(37u
592.i+
593.in -\n(37u
594.mk 32
595.if \n(32>\n(31 .nr 31 \n(32
596.sp |\n(31u
597.ta \n(80u \n(81u \n(82u \n(83u \n(84u
598.nr 31 \n(.f
599.nr 35 1m
600\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'All privileges
601.ta \n(80u \n(81u \n(82u \n(83u \n(84u
602.nr 31 \n(.f
603.nr 35 1m
604\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'YES\h'|\n(43u'NO\h'|\n(44u'All privileges (1)
605.ta \n(80u \n(81u \n(82u \n(83u \n(84u
606.nr 31 \n(.f
607.nr 35 1m
608\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'NO\h'|\n(43u'YES\h'|\n(44u'All privileges (1)
609.fc
610.nr T. 1
611.T# 1
612.35
613.rm a+
614.rm b+
615.rm c+
616.rm d+
617.rm e+
618.rm f+
619.rm g+
620.rm h+
621.rm i+
622.TE
623.if \n-(b.=0 .nr c. \n(.c-\n(d.-42
624
625.LP
626.LP
627Notes:
628.LP
629.RS 3
630.TP 3
6311.
632If 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.
633.TP 3
6342.
635The policy file/keystore combination has precedence over a trusted identity in the identity database.
636.TP 3
6373.
638Untrusted identities are ignored in the Java 2 platform.
639.TP 3
6404.
641Only trusted identities can be imported into Java 2 SDK keystores.
642.RE
643
644.LP
645.SS
646Keystore Aliases
647.LP
648.RS 3
649
650.LP
651.LP
652All keystore entities are accessed via unique \f2aliases\fP.
653.LP
654.LP
655When 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.
656.LP
657.nf
658\f3
659.fl
660 jarsigner \-keystore /working/mystore \-storepass myspass
661.fl
662 \-keypass dukekeypasswd MyJARFile.jar duke
663.fl
664\fP
665.fi
666
667.LP
668.LP
669Keystores 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.
670.LP
671.RE
672.SS
673Keystore Location
674.LP
675.RS 3
676
677.LP
678.LP
679\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.
680.LP
681.LP
682Note 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.
683.LP
684.RE
685.SS
686Keystore Implementation
687.LP
688.RS 3
689
690.LP
691.LP
692The \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.
693.LP
694.LP
695Currently, 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.
696.LP
697.LP
698There 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.
699.LP
700.LP
701Keystore 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
702.na
703\f2How to Implement a Provider for the Java Cryptography Architecture\fP @
704.fi
705http://java.sun.com/javase/6/docs/technotes/guides/security/HowToImplAProvider.html.
706.LP
707.LP
708Applications 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.
709.LP
710.LP
711\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.
712.LP
713.LP
714For \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.
715.LP
716.LP
717If 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).
718.LP
719.LP
720Each 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.
721.LP
722.LP
723The \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):
724.LP
725.nf
726\f3
727.fl
728 KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
729.fl
730\fP
731.fi
732
733.LP
734.LP
735The 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:
736.LP
737.nf
738\f3
739.fl
740 keystore.type=jks
741.fl
742\fP
743.fi
744
745.LP
746.LP
747Note: Case doesn't matter in keystore type designations. For example, "JKS" would be considered the same as "jks".
748.LP
749.LP
750To 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
751.LP
752.nf
753\f3
754.fl
755 keystore.type=pkcs12
756.fl
757\fP
758.fi
759
760.LP
761.LP
762Note that if you us the PKCS#11 provider package, you should refer to the
763.na
764\f2KeyTool and JarSigner\fP @
765.fi
766http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#keytooljarsigner section of the Java PKCS#11 Reference Guide for details.
767.LP
768.RE
769.RE
770.SS
771Supported Algorithms
772.LP
773.RS 3
774
775.LP
776.LP
777By default, \f3jarsigner\fP signs a JAR file using either
778.LP
779.RS 3
780.TP 2
781o
782DSA (Digital Signature Algorithm) with the SHA\-1 digest algorithm, or
783.TP 2
784o
785the RSA algorithm with the MD5 digest algorithm.
786.RE
787
788.LP
789.LP
790That 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.
791.LP
792.LP
793These default signature algorithms can be overridden using the \f2\-sigalg\fP option.
794.LP
795.RE
796.SS
797The Signed JAR File
798.LP
799.RS 3
800
801.LP
802.LP
803When \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:
804.LP
805.RS 3
806.TP 2
807o
808a signature file, with a .SF extension, and
809.TP 2
810o
811a signature block file, with a .DSA extension.
812.RE
813
814.LP
815.LP
816The base file names for these two files come from the value of the \f2\-sigFile\fP option. For example, if the option appears as
817.LP
818.nf
819\f3
820.fl
821 \-sigFile MKSIGN
822.fl
823\fP
824.fi
825
826.LP
827.LP
828the files are named "MKSIGN.SF" and "MKSIGN.DSA".
829.LP
830.LP
831If 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.
832.LP
833\f3The Signature (.SF) File\fP
834.LP
835.RS 3
836
837.LP
838.LP
839A 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:
840.LP
841.RS 3
842.TP 2
843o
844the file name,
845.TP 2
846o
847the name of the digest algorithm used (SHA), and
848.TP 2
849o
850a SHA digest value.
851.RE
852
853.LP
854.LP
855In 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.
856.LP
857.LP
858The 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.
859.LP
860.RE
861\f3The Signature Block (.DSA) File\fP
862.LP
863.RS 3
864
865.LP
866.LP
867The .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.
868.LP
869.RE
870.RE
871.SS
872Signature Timestamp
873.LP
874.RS 3
875
876.LP
877.LP
878As 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:
879.LP
880.RS 3
881.TP 2
882o
883\f2\-tsa url\fP
884.TP 2
885o
886\f2\-tsacert alias\fP
887.TP 2
888o
889\f2\-altsigner class\fP
890.TP 2
891o
892\f2\-altsignerpath classpathlist\fP
893.RE
894
895.LP
896.LP
897Each of these options is detailed in the Options section below.
898.LP
899.RE
900.SS
901JAR File Verification
902.LP
903.RS 3
904
905.LP
906.LP
907A 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:
908.LP
909.RS 3
910.TP 3
9111.
912Verify the signature of the .SF file itself.
913.LP
914That 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.
915.TP 3
9162.
917Verify the digest listed in each entry in the .SF file with each corresponding section in the manifest.
918.LP
919The .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.
920.LP
921If 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).
922.LP
923One 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.
924.TP 3
9253.
926Read 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.
927.RE
928
929.LP
930.LP
931If 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.
932.LP
933.RE
934.SS
935Multiple Signatures for a JAR File
936.LP
937.RS 3
938
939.LP
940.LP
941A 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:
942.LP
943.nf
944\f3
945.fl
946 jarsigner myBundle.jar susan
947.fl
948 jarsigner myBundle.jar kevin
949.fl
950\fP
951.fi
952
953.LP
954.LP
955When 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:
956.LP
957.nf
958\f3
959.fl
960 SUSAN.SF
961.fl
962 SUSAN.DSA
963.fl
964 KEVIN.SF
965.fl
966 KEVIN.DSA
967.fl
968\fP
969.fi
970
971.LP
972.LP
973Note: 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.
974.LP
975.RE
976.SH "OPTIONS"
977.LP
978
979.LP
980.LP
981The various \f3jarsigner\fP options are listed and described below. Note:
982.LP
983.RS 3
984.TP 2
985o
986All option names are preceded by a minus sign (\-).
987.TP 2
988o
989The options may be provided in any order.
990.TP 2
991o
992Items in italics (option values) represent the actual values that must be supplied.
993.TP 2
994o
995The \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.
996.RE
997
998.LP
999.RS 3
1000.TP 3
1001\-keystore url
1002Specifies 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.
1003.LP
1004A 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).
1005.LP
1006A 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.
1007.LP
1008Note: 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,
1009.nf
1010\f3
1011.fl
1012 \-keystore \fP\f4filePathAndName\fP\f3
1013.fl
1014\fP
1015.fi
1016is treated as equivalent to
1017.nf
1018\f3
1019.fl
1020 \-keystore file:\fP\f4filePathAndName\fP\f3
1021.fl
1022\fP
1023.fi
1024If 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:
1025.RS 3
1026.TP 2
1027o
1028\f2\-keystore NONE\fP
1029.TP 2
1030o
1031\f2\-storetype PKCS11\fP
1032.RE
1033For example, this command lists the contents of the configured PKCS#11 token:
1034.RS 3
1035
1036.LP
1037.nf
1038\f3
1039.fl
1040 jarsigner \-keystore NONE \-storetype PKCS11 \-list
1041.fl
1042
1043.fl
1044\fP
1045.fi
1046.RE
1047.TP 3
1048\-storetype storetype
1049Specifies 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.
1050.LP
1051The 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.
1052.TP 3
1053\-storepass password
1054Specifies 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.
1055.LP
1056Note: 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.
1057.TP 3
1058\-keypass password
1059Specifies 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.
1060.LP
1061Note: 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.
1062.TP 3
1063\-sigfile file
1064Specifies 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.
1065.LP
1066The 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.
1067.LP
1068If 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.
1069.TP 3
1070\-sigalg algorithm
1071.RS 3
1072
1073.LP
1074Specifies the name of the signature algorithm to use to sign the JAR file.
1075.LP
1076See
1077.na
1078\f2Appendix A\fP @
1079.fi
1080http://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.
1081.LP
1082.RE
1083.TP 3
1084\-digestalg algorithm
1085.RS 3
1086Specifies the name of the message digest algorithm to use when digesting the entries of a jar file.
1087.LP
1088See
1089.na
1090\f2Appendix A\fP @
1091.fi
1092http://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.
1093.LP
1094.RE
1095.TP 3
1096\-signedjar file
1097Specifies the name to be used for the signed JAR file.
1098.LP
1099If 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.
1100.TP 3
1101\-verify
1102If 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)"
1103.LP
1104It is possible to verify JAR files signed using either \f3jarsigner\fP or the JDK 1.1 \f3javakey\fP tool, or both.
1105.LP
1106For further information on verification, see JAR File Verification.
1107.TP 3
1108\-certs
1109If 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
1110.RS 3
1111.TP 2
1112o
1113the name of the type of certificate (stored in the .DSA file) that certifies the signer's public key
1114.TP 2
1115o
1116if the certificate is an X.509 certificate (more specifically, an instance of \f2java.security.cert.X509Certificate\fP): the distinguished name of the signer
1117.RE
1118.LP
1119The 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:
1120.RS 3
1121.TP 2
1122o
1123in 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.
1124.RE
1125.TP 3
1126\-verbose
1127If 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.
1128.TP 3
1129\-internalsf
1130In 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
1131.TP 3
1132\-sectionsonly
1133If 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 .
1134.LP
1135By 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.
1136.LP
1137For further information, see JAR File Verification.
1138.LP
1139\f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP
1140.TP 3
1141\-protected
1142Either \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.
1143.RE
1144.RS 3
1145.TP 3
1146\-provider provider\-class\-name
1147Used 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.
1148.LP
1149Used 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.
1150.RS 3
1151
1152.LP
1153.nf
1154\f3
1155.fl
1156jarsigner \-keystore NONE \-storetype PKCS11 \\
1157.fl
1158 \-providerClass sun.security.pkcs11.SunPKCS11 \\
1159.fl
1160 \-providerArg /foo/bar/token.config \\
1161.fl
1162 \-list
1163.fl
1164\fP
1165.fi
1166.RE
1167.TP 3
1168\-providerName providerName
1169If 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.
1170.LP
1171For 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
1172.na
1173\f2configuration attributes table\fP @
1174.fi
1175http://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:
1176.RS 3
1177
1178.LP
1179.nf
1180\f3
1181.fl
1182jarsigner \-keystore NONE \-storetype PKCS11 \\
1183.fl
1184 \-providerName SunPKCS11\-SmartCard \\
1185.fl
1186 \-list
1187.fl
1188\fP
1189.fi
1190.RE
1191.TP 3
1192\-Jjavaoption
1193Passes 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.
1194.LP
1195.TP 3
1196\-tsa url
1197If \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.
1198.LP
1199To generate the timestamp, \f2jarsigner\fP communicates with the TSA using the Time\-Stamp Protocol (TSP) defined in
1200.na
1201\f2RFC 3161\fP @
1202.fi
1203http://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.
1204.LP
1205.TP 3
1206\-tsacert alias
1207If \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.
1208.LP
1209The TSA's public key certificate must be present in the keystore when using \f2\-tsacert\fP.
1210.LP
1211.TP 3
1212\-altsigner class
1213Specifies 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.
1214.LP
1215For 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
1216.LP
1217.TP 3
1218\-altsignerpath classpathlist
1219Specifies 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.
1220.LP
1221An 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.
1222.LP
1223Example of specifying the path to a jar file that contains the class file:
1224.RS 3
1225
1226.LP
1227.LP
1228\f2\-altsignerpath /home/user/lib/authsigner.jar\fP
1229.LP
1230.RE
1231.LP
1232Note that the JAR file name is included.
1233.LP
1234Example of specifying the path to the jar file that contains the class file:
1235.RS 3
1236.LP
1237\f2\-altsignerpath /home/user/classes/com/sun/tools/jarsigner/\fP
1238.LP
1239.RE
1240.LP
1241Note that the JAR file name is omitted.
1242.RE
1243.SH "EXAMPLES"
1244.LP
1245
1246.LP
1247.SS
1248Signing a JAR File
1249.LP
1250.RS 3
1251
1252.LP
1253.LP
1254Suppose 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":
1255.LP
1256.nf
1257\f3
1258.fl
1259 jarsigner \-keystore /working/mystore \-storepass myspass
1260.fl
1261 \-keypass j638klm \-signedjar sbundle.jar bundle.jar jane
1262.fl
1263\fP
1264.fi
1265
1266.LP
1267.LP
1268Note 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.
1269.LP
1270.LP
1271If you want to be prompted for the store password and the private key password, you could shorten the above command to
1272.LP
1273.nf
1274\f3
1275.fl
1276 jarsigner \-keystore /working/mystore
1277.fl
1278 \-signedjar sbundle.jar bundle.jar jane
1279.fl
1280\fP
1281.fi
1282
1283.LP
1284.LP
1285If 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:
1286.LP
1287.nf
1288\f3
1289.fl
1290 jarsigner \-signedjar sbundle.jar bundle.jar jane
1291.fl
1292\fP
1293.fi
1294
1295.LP
1296.LP
1297Finally, 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:
1298.LP
1299.nf
1300\f3
1301.fl
1302 jarsigner bundle.jar jane
1303.fl
1304\fP
1305.fi
1306.RE
1307
1308.LP
1309.SS
1310Verifying a Signed JAR File
1311.LP
1312.RS 3
1313
1314.LP
1315.LP
1316To 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:
1317.LP
1318.nf
1319\f3
1320.fl
1321 jarsigner \-verify sbundle.jar
1322.fl
1323\fP
1324.fi
1325
1326.LP
1327.LP
1328If the verification is successful,
1329.LP
1330.nf
1331\f3
1332.fl
1333 jar verified.
1334.fl
1335\fP
1336.fi
1337
1338.LP
1339.LP
1340is displayed. Otherwise, an error message appears.
1341.LP
1342.LP
1343You 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:
1344.LP
1345.nf
1346\f3
1347.fl
1348 jarsigner \-verify \-verbose sbundle.jar
1349.fl
1350
1351.fl
1352 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
1353.fl
1354 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
1355.fl
1356 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
1357.fl
1358 smk 2752 Fri Sep 26 16:12:30 PDT 1997 AclEx.class
1359.fl
1360 smk 849 Fri Sep 26 16:12:46 PDT 1997 test.class
1361.fl
1362
1363.fl
1364 s = signature was verified
1365.fl
1366 m = entry is listed in manifest
1367.fl
1368 k = at least one certificate was found in keystore
1369.fl
1370
1371.fl
1372 jar verified.
1373.fl
1374\fP
1375.fi
1376
1377.LP
1378.SS
1379Verification with Certificate Information
1380.LP
1381.LP
1382If 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,
1383.LP
1384.nf
1385\f3
1386.fl
1387 jarsigner \-keystore /working/mystore \-verify \-verbose \-certs myTest.jar
1388.fl
1389
1390.fl
1391 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
1392.fl
1393 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
1394.fl
1395 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
1396.fl
1397 208 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST.SF
1398.fl
1399 1087 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST.DSA
1400.fl
1401 smk 2752 Fri Sep 26 16:12:30 PDT 1997 Tst.class
1402.fl
1403
1404.fl
1405 X.509, CN=Test Group, OU=Java Software, O=Sun Microsystems, L=CUP, S=CA, C=US (javatest)
1406.fl
1407 X.509, CN=Jane Smith, OU=Java Software, O=Sun, L=cup, S=ca, C=us (jane)
1408.fl
1409
1410.fl
1411 s = signature was verified
1412.fl
1413 m = entry is listed in manifest
1414.fl
1415 k = at least one certificate was found in keystore
1416.fl
1417
1418.fl
1419 jar verified.
1420.fl
1421\fP
1422.fi
1423
1424.LP
1425.LP
1426If 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
1427.LP
1428.nf
1429\f3
1430.fl
1431 PGP, (bob)
1432.fl
1433\fP
1434.fi
1435
1436.LP
1437.SS
1438Verification of a JAR File that Includes Identity Database Signers
1439.LP
1440.LP
1441If 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.
1442.LP
1443.LP
1444When 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:
1445.LP
1446.nf
1447\f3
1448.fl
1449 jarsigner \-keystore /working/mystore \-verify \-verbose \-certs writeFile.jar
1450.fl
1451
1452.fl
1453 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
1454.fl
1455 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
1456.fl
1457 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
1458.fl
1459 199 Fri Sep 27 12:22:30 PDT 1997 META\-INF/DUKE.SF
1460.fl
1461 1013 Fri Sep 27 12:22:30 PDT 1997 META\-INF/DUKE.DSA
1462.fl
1463 smki 2752 Fri Sep 26 16:12:30 PDT 1997 writeFile.html
1464.fl
1465
1466.fl
1467 X.509, CN=Jane Smith, OU=Java Software, O=Sun, L=cup, S=ca, C=us (jane)
1468.fl
1469 X.509, CN=Duke, OU=Java Software, O=Sun, L=cup, S=ca, C=us [duke]
1470.fl
1471
1472.fl
1473 s = signature was verified
1474.fl
1475 m = entry is listed in manifest
1476.fl
1477 k = at least one certificate was found in keystore
1478.fl
1479 i = at least one certificate was found in identity scope
1480.fl
1481
1482.fl
1483 jar verified.
1484.fl
1485\fP
1486.fi
1487
1488.LP
1489.LP
1490Note that the alias "duke" is in brackets to denote that it is an identity database alias, not a keystore alias.
1491.LP
1492.RE
1493.SH "SEE ALSO"
1494.LP
1495
1496.LP
1497.RS 3
1498.TP 2
1499o
1500jar tool documentation
1501.TP 2
1502o
1503keytool tool documentation
1504.TP 2
1505o
1506the
1507.na
1508\f4Security\fP @
1509.fi
1510http://java.sun.com/docs/books/tutorial/security1.2/index.html trail of the
1511.na
1512\f4Java Tutorial\fP @
1513.fi
1514http://java.sun.com/docs/books/tutorial/trailmap.html for examples of the use of the \f3jarsigner\fP tool
1515.RE
1516
1517.LP
1518
1519.LP
1520