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