1jarsigner(1)                    Security Tools                    jarsigner(1)
2
3
4

NAME

6       jarsigner - Signs and verifies Java Archive (JAR) files.
7

SYNOPSIS

9       jarsigner [ options ] jar-file alias
10
11       jarsigner -verify [ options ] jar-file [alias ...]
12
13
14       options
15              The command-line options. See Options.
16
17       -verify
18              The -verify option can take zero or more keystore alias names
19              after the JAR file name. When the -verify option is specified,
20              the jarsigner command checks that the certificate used to verify
21              each signed entry in the JAR file matches one of the keystore
22              aliases. The aliases are defined in the keystore specified by
23              -keystore or the default keystore.
24
25              If you also specified the -strict option, and the jarsigner
26              command detected severe warnings, the message, "jar verified,
27              with signer errors" is displayed.
28
29       jar-file
30              The JAR file to be signed.
31
32              If you also specified the -strict option, and the jarsigner
33              command detected severe warnings, the message, "jar signed, with
34              signer errors" is displayed.
35
36       alias  The aliases are defined in the keystore specified by -keystore
37              or the default keystore.
38

DESCRIPTION

40       The jarsigner tool has two purposes:
41
42       · To sign Java Archive (JAR) files.
43
44       · To verify the signatures and integrity of signed JAR files.
45
46       The JAR feature enables the packaging of class files, images, sounds,
47       and other digital data in a single file for faster and easier
48       distribution. A tool named jar enables developers to produce JAR files.
49       (Technically, any zip file can also be considered a JAR file, although
50       when created by the jar command or processed by the jarsigner command,
51       JAR files also contain a META-INF/MANIFEST.MF file.)
52
53       A digital signature is a string of bits that is computed from some data
54       (the data being signed) and the private key of an entity (a person,
55       company, and so on). Similar to a handwritten signature, a digital
56       signature has many useful characteristics:
57
58       · Its authenticity can be verified by a computation that uses the
59         public key corresponding to the private key used to generate the
60         signature.
61
62       · It cannot be forged, assuming the private key is kept secret.
63
64       · It is a function of the data signed and thus cannot be claimed to be
65         the signature for other data as well.
66
67       · The signed data cannot be changed. If the data is changed, then the
68         signature cannot be verified as authentic.
69
70       To generate an entity's signature for a file, the entity must first
71       have a public/private key pair associated with it and one or more
72       certificates that authenticate its public key. A certificate is a
73       digitally signed statement from one entity that says that the public
74       key of another entity has a particular value.
75
76       The jarsigner command uses key and certificate information from a
77       keystore to generate digital signatures for JAR files. A keystore is a
78       database of private keys and their associated X.509 certificate chains
79       that authenticate the corresponding public keys. The keytool command is
80       used to create and administer keystores.
81
82       The jarsigner command uses an entity's private key to generate a
83       signature. The signed JAR file contains, among other things, a copy of
84       the certificate from the keystore for the public key corresponding to
85       the private key used to sign the file. The jarsigner command can verify
86       the digital signature of the signed JAR file using the certificate
87       inside it (in its signature block file).
88
89       The jarsigner command can generate signatures that include a time stamp
90       that lets a systems or deployer (including Java Plug-in) to check
91       whether the JAR file was signed while the signing certificate was still
92       valid. In addition, APIs allow applications to obtain the timestamp
93       information.
94
95       At this time, the jarsigner command can only sign JAR files created by
96       the jar command or zip files. JAR files are the same as zip files,
97       except they also have a META-INF/MANIFEST.MF file. A META-
98       INF/MANIFEST.MF file is created when the jarsigner command signs a zip
99       file.
100
101       The default jarsigner command behavior is to sign a JAR or zip file.
102       Use the -verify option to verify a signed JAR file.
103
104       The jarsigner command also attempts to validate the signer's
105       certificate after signing or verifying. If there is a validation error
106       or any other problem, the command generates warning messages. If you
107       specify the -strict option, then the command treats severe warnings as
108       errors. See Errors and Warnings.
109
110   KEYSTORE ALIASES
111       All keystore entities are accessed with unique aliases.
112
113       When you use the jarsigner command to sign a JAR file, you must specify
114       the alias for the keystore entry that contains the private key needed
115       to generate the signature. For example, the following command signs the
116       JAR file named MyJARFile.jar with the private key associated with the
117       alias duke in the keystore named mystore in the working directory.
118       Because no output file is specified, it overwrites MyJARFile.jar with
119       the signed JAR file.
120
121       jarsigner -keystore /working/mystore -storepass <keystore password>
122             -keypass <private key password> MyJARFile.jar duke
123
124       Keystores are protected with a password, so the store password must be
125       specified. You are prompted for it when you do not specify it on the
126       command line. Similarly, private keys are protected in a keystore with
127       a password, so the private key's password must be specified, and you
128       are prompted for the password when you do not specify it on the command
129       line and it is not the same as the store password.
130
131   KEYSTORE LOCATION
132       The jarsigner command has a -keystore option for specifying the URL of
133       the keystore to be used. The keystore is by default stored in a file
134       named .keystore in the user's home directory, as determined by the
135       user.home system property.
136
137       On Oracle Solaris systems, user.home defaults to the user's home
138       directory.
139
140       The input stream from the -keystore option is passed to the
141       KeyStore.load method. If NONE is specified as the URL, then a null
142       stream is passed to the KeyStore.load method. NONE should be specified
143       when the KeyStore class is not file based, for example, when it resides
144       on a hardware token device.
145
146   KEYSTORE IMPLEMENTATION
147       The KeyStore class provided in the java.security package supplies a
148       number of well-defined interfaces to access and modify the information
149       in a keystore. You can have multiple different concrete
150       implementations, where each implementation is for a particular type of
151       keystore.
152
153       Currently, there are two command-line tools that use keystore
154       implementations (keytool and jarsigner), and a GUI-based tool named
155       Policy Tool. Because the KeyStore class is publicly available, JDK
156       users can write additional security applications that use it.
157
158       There is a built-in default implementation provided by Oracle that
159       implements the keystore as a file, that uses a proprietary keystore
160       type (format) named JKS. The built-in implementation protects each
161       private key with its individual password and protects the integrity of
162       the entire keystore with a (possibly different) password.
163
164       Keystore implementations are provider-based, which means the
165       application interfaces supplied by the KeyStore class are implemented
166       in terms of a Service Provider Interface (SPI). There is a
167       corresponding abstract KeystoreSpi class, also in the java.security
168       package, that defines the Service Provider Interface methods that
169       providers must implement. The term provider refers to a package or a
170       set of packages that supply a concrete implementation of a subset of
171       services that can be accessed by the Java Security API. To provide a
172       keystore implementation, clients must implement a provider and supply a
173       KeystoreSpi subclass implementation, as described in How to Implement a
174       Provider in the Java Cryptography Architecture at
175       http://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/HowToImplAProvider.html
176
177       Applications can choose different types of keystore implementations
178       from different providers, with the getInstance factory method in the
179       KeyStore class. A keystore type defines the storage and data format of
180       the keystore information and the algorithms used to protect private
181       keys in the keystore and the integrity of the keystore itself. Keystore
182       implementations of different types are not compatible.
183
184       The jarsigner and policytool commands can read file-based keystores
185       from any location that can be specified using a URL. In addition, these
186       commands can read non-file-based keystores such as those provided by
187       MSCAPI on Windows and PKCS11 on all platforms.
188
189       For the jarsigner and keytool commands, you can specify a keystore type
190       at the command line with the -storetype option. For Policy Tool, you
191       can specify a keystore type with the Edit command in the KeyStore menu.
192
193       If you do not explicitly specify a keystore type, then the tools choose
194       a keystore implementation based on the value of the keystore.type
195       property specified in the security properties file. The security
196       properties file is called java.security, and it resides in the JDK
197       security properties directory, java.home/lib/security, where java.home
198       is the runtime environment's directory. The jre directory in the JDK or
199       the top-level directory of the Java Runtime Environment (JRE).
200
201       Each tool gets the keystore.type value and then examines all the
202       installed providers until it finds one that implements keystores of
203       that type. It then uses the keystore implementation from that provider.
204
205       The KeyStore class defines a static method named getDefaultType that
206       lets applications and applets retrieve the value of the keystore.type
207       property. The following line of code creates an instance of the default
208       keystore type as specified in the keystore.type property:
209
210       KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
211
212       The default keystore type is jks (the proprietary type of the keystore
213       implementation provided by Oracle). This is specified by the following
214       line in the security properties file:
215
216       keystore.type=jks
217
218       Case does not matter in keystore type designations. For example, JKS is
219       the same as jks.
220
221       To have the tools use a keystore implementation other than the default,
222       change that line to specify a different keystore type. For example, if
223       you have a provider package that supplies a keystore implementation for
224       a keystore type called pkcs12, then change the line to the following:
225
226       keystore.type=pkcs12
227
228       Note: If you use the PKCS 11 provider package, then see "KeyTool" and
229       "JarSigner" in Java PKCS #11 Reference Guide at
230       http://docs.oracle.com/javase/7/docs/technotes/guides/security/p11guide.html
231
232   SUPPORTED ALGORITHMS
233       By default, the jarsigner command signs a JAR file using one of the
234       following algorithms:
235
236       · Digital Signature Algorithm (DSA) with the SHA1 digest algorithm
237
238       · RSA algorithm with the SHA256 digest algorithm
239
240       · Elliptic Curve (EC) cryptography algorithm with the SHA256 with
241         Elliptic Curve Digital Signature Algorithm (ECDSA).
242
243       If the signer's public and private keys are DSA keys, then jarsigner
244       signs the JAR file with the SHA1withDSA algorithm. If the signer's keys
245       are RSA keys, then jarsigner attempts to sign the JAR file with the
246       SHA256withRSA algorithm. If the signer's keys are EC keys, then
247       jarsigner signs the JAR file with the SHA256withECDSA algorithm.
248
249       These default signature algorithms can be overridden using the -sigalg
250       option.
251
252   THE SIGNED JAR FILE
253       When the jarsigner command is used to sign a JAR file, the output
254       signed JAR file is exactly the same as the input JAR file, except that
255       it has two additional files placed in the META-INF directory:
256
257       · A signature file with an .SF extension
258
259       · A signature block file with a .DSA, .RSA, or .EC extension
260
261       The base file names for these two files come from the value of the
262       -sigFile option. For example, when the option is -sigFile MKSIGN, the
263       files are named MKSIGN.SF and MKSIGN.DSA
264
265       If no -sigfile option appears on the command line, then the base file
266       name for the .SF and .DSA files is the first 8 characters of the alias
267       name specified on the command line, all converted to uppercase. If the
268       alias name has fewer than 8 characters, then the full alias name is
269       used. If the alias name contains any characters that are not allowed in
270       a signature file name, then each such character is converted to an
271       underscore (_) character in forming the file name. Valid characters
272       include letters, digits, underscores, and hyphens.
273
274       Signature File
275
276       A signature file (.SF file) looks similar to the manifest file that is
277       always included in a JAR file when the jarsigner command is used to
278       sign the file. For each source file included in the JAR file, the .SF
279       file has three lines, such as in the manifest file, that list the
280       following:
281
282       · File name
283
284       · Name of the digest algorithm (SHA)
285
286       · SHA digest value
287
288       In the manifest file, the SHA digest value for each source file is the
289       digest (hash) of the binary data in the source file. In the .SF file,
290       the digest value for a specified source file is the hash of the three
291       lines in the manifest file for the source file.
292
293       The signature file, by default, includes a header with a hash of the
294       whole manifest file. The header also contains a hash of the manifest
295       header. The presence of the header enables verification optimization.
296       See JAR File Verification.
297
298       Signature Block File
299
300       The .SF file is signed and the signature is placed in the signature
301       block file. This file also contains, encoded inside it, the certificate
302       or certificate chain from the keystore that authenticates the public
303       key corresponding to the private key used for signing. The file has the
304       extension .DSA, .RSA, or .EC, depending on the digest algorithm used.
305
306   SIGNATURE TIME STAMP
307       The jarsigner command can generate and store a signature time stamp
308       when signing a JAR file. In addition, jarsigner supports alternative
309       signing mechanisms. This behavior is optional and is controlled by the
310       user at the time of signing through these options. See Options.
311
312       -tsa url
313       -tsacert alias
314       -altsigner class
315       -altsignerpath classpathlist
316       -tsapolicyid policyid
317
318
319   JAR FILE VERIFICATION
320       A successful JAR file verification occurs when the signatures are
321       valid, and none of the files that were in the JAR file when the
322       signatures were generated have changed since then. JAR file
323       verification involves the following steps:
324
325       1.  Verify the signature of the .SF file.
326
327           The verification ensures that the signature stored in each
328           signature block (.DSA) file was generated using the private key
329           corresponding to the public key whose certificate (or certificate
330           chain) also appears in the .DSA file. It also ensures that the
331           signature is a valid signature of the corresponding signature (.SF)
332           file, and thus the .SF file was not tampered with.
333
334       2.  Verify the digest listed in each entry in the .SF file with each
335           corresponding section in the manifest.
336
337           The .SF file by default includes a header that contains a hash of
338           the entire manifest file. When the header is present, the
339           verification can check to see whether or not the hash in the header
340           matches the hash of the manifest file. If there is a match, then
341           verification proceeds to the next step.
342
343           If there is no match, then a less optimized verification is
344           required to ensure that the hash in each source file information
345           section in the .SF file equals the hash of its corresponding
346           section in the manifest file. See Signature File.
347
348           One reason the hash of the manifest file that is stored in the .SF
349           file header might not equal the hash of the current manifest file
350           is that one or more files were added to the JAR file (with the jar
351           tool) after the signature and .SF file were generated. When the jar
352           tool is used to add files, the manifest file is changed by adding
353           sections to it for the new files, but the .SF file is not changed.
354           A verification is still considered successful when none of the
355           files that were in the JAR file when the signature was generated
356           have been changed since then. This happens when the hashes in the
357           non-header sections of the .SF file equal the hashes of the
358           corresponding sections in the manifest file.
359
360       3.  Read each file in the JAR file that has an entry in the .SF file.
361           While reading, compute the file's digest and compare the result
362           with the digest for this file in the manifest section. The digests
363           should be the same or verification fails.
364
365           If any serious verification failures occur during the verification
366           process, then the process is stopped and a security exception is
367           thrown. The jarsigner command catches and displays the exception.
368
369       Note: You should read any addition warnings (or errors if you specified
370       the -strict option), as well as the content of the certificate (by
371       specifying the -verbose and -certs options) to determine if the
372       signature can be trusted.
373
374   MULTIPLE SIGNATURES FOR A JAR FILE
375       A JAR file can be signed by multiple people by running the jarsigner
376       command on the file multiple times and specifying the alias for a
377       different person each time, as follows:
378
379       jarsigner myBundle.jar susan
380       jarsigner myBundle.jar kevin
381
382       When a JAR file is signed multiple times, there are multiple .SF and
383       .DSA files in the resulting JAR file, one pair for each signature. In
384       the previous example, the output JAR file includes files with the
385       following names:
386
387       SUSAN.SF
388       SUSAN.DSA
389       KEVIN.SF
390       KEVIN.DSA
391
392       Note: It is also possible for a JAR file to have mixed signatures, some
393       generated by the JDK 1.1 by the javakey command and others by
394       jarsigner. The jarsigner command can be used to sign JAR files that are
395       already signed with the javakey command.
396

OPTIONS

398       The following sections describe the various jarsigner options. Be aware
399       of the following standards:
400
401       · All option names are preceded by a minus sign (-).
402
403       · The options can be provided in any order.
404
405       · Items that are in italics or underlined (option values) represent the
406         actual values that must be supplied.
407
408       · The -storepass, -keypass, -sigfile, -sigalg, -digestalg, -signedjar,
409         and TSA-related options are only relevant when signing a JAR file;
410         they are not relevant when verifying a signed JAR file. The -keystore
411         option is relevant for signing and verifying a JAR file. In addition,
412         aliases are specified when signing and verifying a JAR file.
413
414       -keystore url
415         Specifies the URL that tells the keystore location. This defaults to
416         the file .keystore in the user's home directory, as determined by the
417         user.home system property.
418
419         A keystore is required when signing. You must explicitly specify a
420         keystore when the default keystore does not exist or if you want to
421         use one other than the default.
422
423         A keystore is not required when verifying, but if one is specified or
424         the default exists and the -verbose option was also specified, then
425         additional information is output regarding whether or not any of the
426         certificates used to verify the JAR file are contained in that
427         keystore.
428
429         The -keystore argument can be a file name and path specification
430         rather than a URL, in which case it is treated the same as a file:
431         URL, for example, the following are equivalent:
432
433         -keystore filePathAndName
434         -keystore file:filePathAndName
435
436
437
438         If the Sun PKCS #11 provider was configured in the java.security
439         security properties file (located in the JRE's
440         $JAVA_HOME/lib/security directory), then the keytool and jarsigner
441         tools can operate on the PKCS #11 token by specifying these options:
442
443         -keystore NONE
444         -storetype PKCS11
445
446
447
448         For example, the following command lists the contents of the
449         configured PKCS#11 token:
450
451         keytool -keystore NONE -storetype PKCS11 -list
452
453
454
455       -storetype storetype
456         Specifies the type of keystore to be instantiated. The default
457         keystore type is the one that is specified as the value of the
458         keystore.type property in the security properties file, which is
459         returned by the static getDefaultType method in
460         java.security.KeyStore.
461
462         The PIN for a PCKS #11 token can also be specified with the
463         -storepass option. If none is specified, then the keytool and
464         jarsigner commands prompt for the token PIN. If the token has a
465         protected authentication path (such as a dedicated PIN-pad or a
466         biometric reader), then the -protected option must be specified and
467         no password options can be specified.
468
469       -storepass[:env | :file] argument
470         Specifies the password that is required to access the keystore. This
471         is only needed when signing (not verifying) a JAR file. In that case,
472         if a -storepass option is not provided at the command line, then the
473         user is prompted for the password.
474
475         If the modifier env or file is not specified, then the password has
476         the value argument. Otherwise, the password is retrieved as follows:
477
478         · env: Retrieve the password from the environment variable named
479           argument.
480
481         · file: Retrieve the password from the file named argument.
482
483
484       Note: The password should not be specified on the command line or in a
485       script unless it is for testing purposes, or you are on a secure
486       system.
487
488       -keypass [:env | :file] argument
489         Specifies the password used to protect the private key of the
490         keystore entry addressed by the alias specified on the command line.
491         The password is required when using jarsigner to sign a JAR file. If
492         no password is provided on the command line, and the required
493         password is different from the store password, then the user is
494         prompted for it.
495
496         If the modifier env or file is not specified, then the password has
497         the value argument. Otherwise, the password is retrieved as follows:
498
499         · env: Retrieve the password from the environment variable named
500           argument.
501
502         · file: Retrieve the password from the file named argument.
503
504
505       Note: The password should not be specified on the command line or in a
506       script unless it is for testing purposes, or you are on a secure
507       system.
508
509       -sigfile file
510         Specifies the base file name to be used for the generated .SF and
511         .DSA files. For example, if file is DUKESIGN, then the generated .SF
512         and .DSA files are named DUKESIGN.SF and DUKESIGN.DSA, and placed in
513         the META-INF directory of the signed JAR file.
514
515         The characters in the file must come from the set a-zA-Z0-9_-. Only
516         letters, numbers, underscore, and hyphen characters are allowed. All
517         lowercase characters are converted to uppercase for the .SF and .DSA
518         file names.
519
520         If no -sigfile option appears on the command line, then the base file
521         name for the .SF and .DSA files is the first 8 characters of the
522         alias name specified on the command line, all converted to upper
523         case. If the alias name has fewer than 8 characters, then the full
524         alias name is used. If the alias name contains any characters that
525         are not valid in a signature file name, then each such character is
526         converted to an underscore (_) character to form the file name.
527
528       -sigalg algorithm
529         Specifies the name of the signature algorithm to use to sign the JAR
530         file.
531
532         For a list of standard signature algorithm names, see "Appendix A:
533         Standard Names" in the Java Cryptography Architecture (JCA) Reference
534         Guide at
535         http://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/CryptoSpec.html#AppA
536
537         This algorithm must be compatible with the private key used to sign
538         the JAR file. If this option is not specified, then SHA1withDSA,
539         SHA256withRSA, or SHA256withECDSA are used depending on the type of
540         private key. There must either be a statically installed provider
541         supplying an implementation of the specified algorithm or the user
542         must specify one with the -providerClass option; otherwise, the
543         command will not succeed.
544
545       -digestalg algorithm
546         Specifies the name of the message digest algorithm to use when
547         digesting the entries of a JAR file.
548
549         For a list of standard message digest algorithm names, see "Appendix
550         A: Standard Names" in the Java Cryptography Architecture (JCA)
551         Reference Guide at
552         http://docs.oracle.com/javase/7/docs/technotes/guides/security/crypto/CryptoSpec.html#AppA
553
554         If this option is not specified, then SHA256 is used. There must
555         either be a statically installed provider supplying an implementation
556         of the specified algorithm or the user must specify one with the
557         -providerClass option; otherwise, the command will not succeed.
558
559       -certs
560         If the -certs option appears on the command line with the -verify and
561         -verbose options, then the output includes certificate information
562         for each signer of the JAR file. This information includes the name
563         of the type of certificate (stored in the .DSA file) that certifies
564         the signer's public key, and if the certificate is an X.509
565         certificate (an instance of the java.security.cert.X509Certificate),
566         then the distinguished name of the signer.
567
568         The keystore is also examined. If no keystore value is specified on
569         the command line, then the default keystore file (if any) is checked.
570         If the public key certificate for a signer matches an entry in the
571         keystore, then the alias name for the keystore entry for that signer
572         is displayed in parentheses. If the signer comes from a JDK 1.1
573         identity database instead of from a keystore, then the alias name
574         displays in brackets instead of parentheses.
575
576       -certchain file
577         Specifies the certificate chain to be used when the certificate chain
578         associated with the private key of the keystore entry that is
579         addressed by the alias specified on the command line is not complete.
580         This can happen when the keystore is located on a hardware token
581         where there is not enough capacity to hold a complete certificate
582         chain. The file can be a sequence of concatenated X.509 certificates,
583         or a single PKCS#7 formatted data block, either in binary encoding
584         format or in printable encoding format (also known as Base64
585         encoding) as defined by the Internet RFC 1421 standard. See the
586         section Internet RFC 1421 Certificate Encoding Standard in keytool
587         and http://tools.ietf.org/html/rfc1421.
588
589       -verbose
590         When the -verbose option appears on the command line, it indicates
591         verbose mode, which causes jarsigner to output extra information
592         about the progress of the JAR signing or verification.
593
594       -internalsf
595         In the past, the .DSA (signature block) file generated when a JAR
596         file was signed included a complete encoded copy of the .SF file
597         (signature file) also generated. This behavior has been changed. To
598         reduce the overall size of the output JAR file, the .DSA file by
599         default does not contain a copy of the .SF file anymore. If
600         -internalsf appears on the command line, then the old behavior is
601         utilized. This option is useful for testing. In practice, do not use
602         the -internalsf option because it incurs higher overhead.
603
604       -sectionsonly
605         If the -sectionsonly option appears on the command line, then the .SF
606         file (signature file) generated when a JAR file is signed does not
607         include a header that contains a hash of the whole manifest file. It
608         contains only the information and hashes related to each individual
609         source file included in the JAR file. See Signature File.
610
611         By default, this header is added, as an optimization. When the header
612         is present, whenever the JAR file is verified, the verification can
613         first check to see whether the hash in the header matches the hash of
614         the whole manifest file. When there is a match, verification proceeds
615         to the next step. When there is no match, it is necessary to do a
616         less optimized verification that the hash in each source file
617         information section in the .SF file equals the hash of its
618         corresponding section in the manifest file. See JAR File
619         Verification.
620
621         The -sectionsonly option is primarily used for testing. It should not
622         be used other than for testing because using it incurs higher
623         overhead.
624
625       -protected
626         Values can be either true or false. Specify true when a password must
627         be specified through a protected authentication path such as a
628         dedicated PIN reader.
629
630       -providerClass provider-class-name
631         Used to specify the name of cryptographic service provider's master
632         class file when the service provider is not listed in the
633         java.security security properties file.
634
635         Used with the -providerArg ConfigFilePath option, the keytool and
636         jarsigner tools install the provider dynamically and use
637         ConfigFilePath for the path to the token configuration file. The
638         following example shows a command to list a PKCS #11 keystore when
639         the Oracle PKCS #11 provider was not configured in the security
640         properties file.
641
642         jarsigner -keystore NONE -storetype PKCS11 \
643                   -providerClass sun.security.pkcs11.SunPKCS11 \
644                   -providerArg /mydir1/mydir2/token.config \
645                   -list
646
647
648
649       -providerName providerName
650         If more than one provider was configured in the java.security
651         security properties file, then you can use the -providerName option
652         to target a specific provider instance. The argument to this option
653         is the name of the provider.
654
655         For the Oracle PKCS #11 provider, providerName is of the form
656         SunPKCS11-TokenName, where TokenName is the name suffix that the
657         provider instance has been configured with, as detailed in the
658         configuration attributes table. For example, the following command
659         lists the contents of the PKCS #11 keystore provider instance with
660         name suffix SmartCard:
661
662         jarsigner -keystore NONE -storetype PKCS11 \
663                 -providerName SunPKCS11-SmartCard \
664                 -list
665
666
667
668       -Jjavaoption
669         Passes through the specified javaoption string directly to the Java
670         interpreter. The jarsigner command is a wrapper around the
671         interpreter. This option should not contain any spaces. It is useful
672         for adjusting the execution environment or memory usage. For a list
673         of possible interpreter options, type java -h or java -X at the
674         command line.
675
676       -tsa url
677         If -tsa http://example.tsa.url appears on the command line when
678         signing a JAR file then a time stamp is generated for the signature.
679         The URL, http://example.tsa.url, identifies the location of the Time
680         Stamping Authority (TSA) and overrides any URL found with the
681         -tsacert option. The -tsa option does not require the TSA public key
682         certificate to be present in the keystore.
683
684         To generate the time stamp, jarsigner communicates with the TSA with
685         the Time-Stamp Protocol (TSP) defined in RFC 3161. When successful,
686         the time stamp token returned by the TSA is stored with the signature
687         in the signature block file.
688
689       -tsacert alias
690         When -tsacert alias appears on the command line when signing a JAR
691         file, a time stamp is generated for the signature. The alias
692         identifies the TSA public key certificate in the keystore that is in
693         effect. The entry's certificate is examined for a Subject Information
694         Access extension that contains a URL identifying the location of the
695         TSA.
696
697         The TSA public key certificate must be present in the keystore when
698         using the -tsacert option.
699
700       -tsapolicyid policyid
701         Specifies the object identifier (OID) that identifies the policy ID
702         to be sent to the TSA server. If this option is not specified, no
703         policy ID is sent and the TSA server will choose a default policy ID.
704
705         Object identifiers are defined by X.696, which is an ITU
706         Telecommunication Standardization Sector (ITU-T) standard. These
707         identifiers are typically period-separated sets of non-negative
708         digits like 1.2.3.4, for example.
709
710       -altsigner class
711         This option specifies an alternative signing mechanism. The fully
712         qualified class name identifies a class file that extends the
713         com.sun.jarsigner.ContentSigner abstract class. The path to this
714         class file is defined by the -altsignerpath option. If the -altsigner
715         option is used, then the jarsigner command uses the signing mechanism
716         provided by the specified class. Otherwise, the jarsigner command
717         uses its default signing mechanism.
718
719         For example, to use the signing mechanism provided by a class named
720         com.sun.sun.jarsigner.AuthSigner, use the jarsigner option -altsigner
721         com.sun.jarsigner.AuthSigner.
722
723       -altsignerpath classpathlist
724         Specifies the path to the class file and any JAR file it depends on.
725         The class file name is specified with the -altsigner option. If the
726         class file is in a JAR file, then this option specifies the path to
727         that JAR file.
728
729         An absolute path or a path relative to the current directory can be
730         specified. If classpathlist contains multiple paths or JAR files,
731         then they should be separated with a colon (:) on Oracle Solaris and
732         a semicolon (;) on Windows. This option is not necessary when the
733         class is already in the search path.
734
735         The following example shows how to specify the path to a JAR file
736         that contains the class file. The JAR file name is included.
737
738         -altsignerpath /home/user/lib/authsigner.jar
739
740
741
742         The following example shows how to specify the path to the JAR file
743         that contains the class file. The JAR file name is omitted.
744
745         -altsignerpath /home/user/classes/com/sun/tools/jarsigner/
746
747
748
749       -strict
750         During the signing or verifying process, the command may issue
751         warning messages. If you specify this option, the exit code of the
752         tool reflects the severe warning messages that this command found.
753         See Errors and Warnings.
754
755       -verbose suboptions
756         For the verifying process, the -verbose option takes suboptions to
757         determine how much information is shown. If the -certs option is also
758         specified, then the default mode (or suboption all) displays each
759         entry as it is being processed, and after that, the certificate
760         information for each signer of the JAR file. If the -certs and the
761         -verbose:grouped suboptions are specified, then entries with the same
762         signer info are grouped and displayed together with their certificate
763         information. If -certs and the -verbose:summary suboptions are
764         specified, then entries with the same signer information are grouped
765         and displayed together with their certificate information. Details
766         about each entry are summarized and displayed as one entry (and
767         more). See Examples.
768

ERRORS AND WARNINGS

770       During the signing or verifying process, the jarsigner command may
771       issue various errors or warnings.
772
773       If there is a failure, the jarsigner command exits with code 1. If
774       there is no failure, but there are one or more severe warnings, the
775       jarsigner command exits with code 0 when the -strict option is not
776       specified, or exits with the OR-value of the warning codes when the
777       -strict is specified. If there is only informational warnings or no
778       warning at all, the command always exits with code 0.
779
780       For example, if a certificate used to sign an entry is expired and has
781       a KeyUsage extension that does not allow it to sign a file, the
782       jarsigner command exits with code 12 (=4+8) when the -strict option is
783       specified.
784
785       Note: Exit codes are reused because only the values from 0 to 255 are
786       legal on Unix-based operating systems.
787
788       The following sections describes the names, codes, and descriptions of
789       the errors and warnings that the jarsigner command can issue.
790
791   FAILURE
792       Reasons why the jarsigner command fails include (but are not limited
793       to) a command line parsing error, the inability to find a keypair to
794       sign the JAR file, or the verification of a signed JAR fails.
795
796       failure
797              Code 1. The signing or verifying fails.
798
799   SEVERE WARNINGS
800       Note: Severe warnings are reported as errors if you specify the -strict
801       option.
802
803       Reasons why the jarsigner command issues a severe warning include the
804       certificate used to sign the JAR file has an error or the signed JAR
805       file has other problems.
806
807       hasExpiredCert
808              Code 4. This jar contains entries whose signer certificate has
809              expired.
810
811       notYetValidCert
812              Code 4. This jar contains entries whose signer certificate is
813              not yet valid.
814
815       chainNotValidated
816              Code 4. This jar contains entries whose certificate chain cannot
817              be correctly validated.
818
819       badKeyUsage
820              Code 8. This jar contains entries whose signer certificate's
821              KeyUsage extension doesn't allow code signing.
822
823       badExtendedKeyUsage
824              Code 8. This jar contains entries whose signer certificate's
825              ExtendedKeyUsage extension doesn't allow code signing.
826
827       badNetscapeCertType
828              Code 8. This jar contains entries whose signer certificate's
829              NetscapeCertType extension doesn't allow code signing.
830
831       hasUnsignedEntry
832              Code 16. This jar contains unsigned entries which have not been
833              integrity-checked.
834
835       notSignedByAlias
836              Code 32. This jar contains signed entries which are not signed
837              by the specified alias(es).
838
839       aliasNotInStore
840              Code 32. This jar contains signed entries that are not signed by
841              alias in this keystore.
842
843   INFORMATIONAL WARNINGS
844       Informational warnings include those that are not errors but regarded
845       as bad practice. They do not have a code.
846
847       hasExpiringCert
848              This jar contains entries whose signer certificate will expire
849              within six months.
850
851       noTimestamp
852              This jar contains signatures that does not include a timestamp.
853              Without a timestamp, users may not be able to validate this JAR
854              file after the signer certificate's expiration date (YYYY-MM-DD)
855              or after any future revocation date.
856

EXAMPLES

858   SIGN A JAR FILE
859       Use the following command to sign bundle.jar with the private key of a
860       user whose keystore alias is jane in a keystore named mystore in the
861       working directory and name the signed JAR file sbundle.jar:
862
863       jarsigner -keystore /working/mystore
864           -storepass <keystore password>
865           -keypass <private key password>
866           -signedjar sbundle.jar bundle.jar jane
867
868       There is no -sigfile specified in the previous command so the generated
869       .SF and .DSA files to be placed in the signed JAR file have default
870       names based on the alias name. They are named JANE.SF and JANE.DSA.
871
872       If you want to be prompted for the store password and the private key
873       password, then you could shorten the previous command to the following:
874
875       jarsigner -keystore /working/mystore
876           -signedjar sbundle.jar bundle.jar jane
877
878       If the keystore is the default keystore (.keystore in your home
879       directory), then you do not need to specify a keystore, as follows:
880
881       jarsigner -signedjar sbundle.jar bundle.jar jane
882
883       If you want the signed JAR file to overwrite the input JAR file
884       (bundle.jar), then you do not need to specify a -signedjar option, as
885       follows:
886
887       jarsigner bundle.jar jane
888
889
890   VERIFY A SIGNED JAR FILE
891       To verify a signed JAR file to ensure that the signature is valid and
892       the JAR file was not been tampered with, use a command such as the
893       following:
894
895       jarsigner -verify sbundle.jar
896
897       When the verification is successful, jar verified is displayed.
898       Otherwise, an error message is displayed. You can get more information
899       when you use the -verbose option. A sample use of jarsigner with the-
900       verbose option follows:
901
902       jarsigner -verify -verbose sbundle.jar
903                  198 Fri Sep 26 16:14:06 PDT 1997 META-INF/MANIFEST.MF
904                  199 Fri Sep 26 16:22:10 PDT 1997 META-INF/JANE.SF
905                 1013 Fri Sep 26 16:22:10 PDT 1997 META-INF/JANE.DSA
906           smk   2752 Fri Sep 26 16:12:30 PDT 1997 AclEx.class
907           smk    849 Fri Sep 26 16:12:46 PDT 1997 test.class
908             s = signature was verified
909             m = entry is listed in manifest
910             k = at least one certificate was found in keystore
911           jar verified.
912
913
914   VERIFICATION WITH CERTIFICATE INFORMATION
915       If you specify the -certs option with the -verify and -verbose options,
916       then the output includes certificate information for each signer of the
917       JAR file. The information includes the certificate type, the signer
918       distinguished name information (when it is an X.509 certificate), and
919       in parentheses, the keystore alias for the signer when the public key
920       certificate in the JAR file matches the one in a keystore entry, for
921       example:
922
923       jarsigner -keystore /working/mystore -verify -verbose -certs myTest.jar
924                  198 Fri Sep 26 16:14:06 PDT 1997 META-INF/MANIFEST.MF
925                  199 Fri Sep 26 16:22:10 PDT 1997 META-INF/JANE.SF
926                 1013 Fri Sep 26 16:22:10 PDT 1997 META-INF/JANE.DSA
927                  208 Fri Sep 26 16:23:30 PDT 1997 META-INF/JAVATEST.SF
928                 1087 Fri Sep 26 16:23:30 PDT 1997 META-INF/JAVATEST.DSA
929           smk   2752 Fri Sep 26 16:12:30 PDT 1997 Tst.class
930             X.509, CN=Test Group, OU=Java Software, O=Oracle, L=CUP, S=CA, C=US (javatest)
931             X.509, CN=Jane Smith, OU=Java Software, O=Oracle, L=cup, S=ca, C=us (jane)
932             s = signature was verified
933             m = entry is listed in manifest
934             k = at least one certificate was found in keystore
935           jar verified.
936
937       If the certificate for a signer is not an X.509 certificate, then there
938       is no distinguished name information. In that case, just the
939       certificate type and the alias are shown. For example, if the
940       certificate is a PGP certificate, and the alias is bob, then you would
941       get: PGP, (bob).
942
943   VERIFICATION THAT INCLUDES IDENTITY DATABASE SIGNERS
944       If a JAR file was signed with the JDK 1.1 javakey tool, and the signer
945       is an alias in an identity database, then the verification output
946       includes an i. If the JAR file was signed by both an alias in an
947       identity database and an alias in a keystore, then both k and i appear.
948
949       When the -certs option is used, any identity database aliases are shown
950       in brackets rather than the parentheses used for keystore aliases, for
951       example:
952
953           jarsigner -keystore /working/mystore -verify -verbose -certs writeFile.jar
954                  198 Fri Sep 26 16:14:06 PDT 1997 META-INF/MANIFEST.MF
955                  199 Fri Sep 26 16:22:10 PDT 1997 META-INF/JANE.SF
956                 1013 Fri Sep 26 16:22:10 PDT 1997 META-INF/JANE.DSA
957                  199 Fri Sep 27 12:22:30 PDT 1997 META-INF/DUKE.SF
958                 1013 Fri Sep 27 12:22:30 PDT 1997 META-INF/DUKE.DSA
959          smki   2752 Fri Sep 26 16:12:30 PDT 1997 writeFile.html
960             X.509, CN=Jane Smith, OU=Java Software, O=Oracle, L=cup, S=ca, C=us (jane)
961             X.509, CN=Duke, OU=Java Software, O=Oracle, L=cup, S=ca, C=us [duke]
962             s = signature was verified
963             m = entry is listed in manifest
964             k = at least one certificate was found in keystore
965             i = at least one certificate was found in identity scope
966           jar verified.
967
968       Note: The alias duke is in brackets to denote that it is an identity
969       database alias, and not a keystore alias.
970

JDK 1.1 COMPATIBILITY

972       The keytool and jarsigner tools replace the javakey tool in JDK 1.1.
973       These new tools provide more features than javakey, including the
974       ability to protect the keystore and private keys with passwords, and
975       the ability to verify signatures in addition to generating them.
976
977       The new keystore architecture replaces the identity database that
978       javakey created and managed. There is no backward compatibility between
979       the keystore format and the database format used by javakey in JDK 1.1.
980       However, be aware of the following:
981
982       · It is possible to import the information from an identity database
983         into a keystore through the keytool -identitydb command.
984
985       · The jarsigner command can sign JAR files that were signed with the
986         javakey command.
987
988       · The jarsigner command can verify JAR files signed with javakey. The
989         jarsigner command recognizes and can work with signer aliases that
990         are from a JDK 1.1 identity database rather than a JDK keystore.
991
992   UNSIGNED JARS
993       Unsigned JARs have the default privileges that are granted to all code.
994
995   SIGNED JARS
996       Signed JARs have the privilege configurations based on their JDK 1.1.n
997       identity and policy file status as described. Only trusted identities
998       can be imported into the JDK keystore.
999
1000       Default Privileges Granted to All Code
1001
1002       Identity in 1.1 database: No
1003       Trusted identity imported into Java keystore from 1.1. database: No
1004       Policy file grants privileges to identity/alias: No
1005
1006       Identity in 1.1 database: No
1007       Trusted identity imported into Java keystore from 1.1. database: Yes
1008       Policy file grants privileges to identity/alias: No
1009
1010       Identity in 1.1 database: Yes/Untrusted
1011       Trusted identity imported into Java keystore from 1.1. database: No
1012       Policy file grants privileges to identity/alias: No
1013       See 3 in Notes Regarding Privileges of Signed JARs.
1014
1015       Identity in 1.1 database: Yes/Untrusted
1016       Trusted identity imported into Java keystore from 1.1. database: No
1017       Policy file grants privileges to identity/alias: Yes
1018       See 1 and 3 in Notes Regarding Privileges of Signed JARs.
1019
1020       Default Privileges and Policy File Privileges Granted
1021
1022       Identity in 1.1 database: No
1023       Trusted identity imported into Java keystore from 1.1. database: Yes
1024       Policy file grants privileges to identity/alias: Yes
1025
1026       Identity in 1.1 database: Yes/Trusted
1027       Trusted identity imported into Java keystore from 1.1. database: Yes
1028       Policy file grants privileges to identity/alias: Yes
1029       See 2 in Notes Regarding Privileges of Signed JARs.
1030
1031       All Privileges Granted
1032
1033       Identity in 1.1 database: Yes/Trusted
1034       Trusted identity imported into Java keystore from 1.1. database: No
1035       Policy file grants privileges to identity/alias: No
1036
1037       Identity in 1.1 database: Yes/Trusted
1038       Trusted identity imported into Java keystore from 1.1. database: Yes
1039       Policy file grants privileges to identity/alias: No
1040       See 1 in Notes Regarding Privileges of Signed JARs.
1041
1042       Identity in 1.1 database: Yes/Trusted
1043       Trusted identity imported into Java keystore from 1.1. database: No
1044       Policy file grants privileges to identity/alias: Yes
1045       See 1 in Notes Regarding Privileges of Signed JARs.
1046
1047       Notes Regarding Privileges of Signed JARs
1048
1049       1.  If an identity or alias is mentioned in the policy file, then it
1050           must be imported into the keystore for the policy file to have any
1051           effect on privileges granted.
1052
1053       2.  The policy file/keystore combination has precedence over a trusted
1054           identity in the identity database.
1055
1056       3.  Untrusted identities are ignored in the Java platform.
1057

SEE ALSO

1059       · jar
1060
1061       · keytool
1062
1063       · Trail: Security Features in Java SE at
1064         http://docs.oracle.com/javase/tutorial/security/index.html
1065
1066
1067
1068JDK 7                            6 August 2013                    jarsigner(1)
Impressum