jdk/src/solaris/doc/sun/man/man1/jarsigner.1
changeset 9573 c02ff5a7c67b
parent 5865 47da38a8c0f0
child 21743 3d979da7bdf0
equal deleted inserted replaced
9572:6f64c69a7574 9573:c02ff5a7c67b
     1 ." Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     1 ." Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved.
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     2 ." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 ."
     3 ."
     4 ." 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
     5 ." 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
     6 ." published by the Free Software Foundation.
     6 ." published by the Free Software Foundation.
    17 ."
    17 ."
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    18 ." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    19 ." or visit www.oracle.com if you need additional information or have any
    19 ." or visit www.oracle.com if you need additional information or have any
    20 ." questions.
    20 ." questions.
    21 ."
    21 ."
    22 .TH jarsigner 1 "02 Jun 2010"
    22 .TH jarsigner 1 "10 May 2011"
    23 
    23 
    24 .LP
    24 .LP
    25 .SH "Name"
    25 .SH "Name"
    26 jarsigner \- JAR Signing and Verification Tool
    26 jarsigner \- JAR Signing and Verification Tool
    27 .LP
    27 .LP
    28 .RS 3
       
    29 
       
    30 .LP
       
    31 .LP
    28 .LP
    32 Generates signatures for Java ARchive (JAR) files, and verifies the signatures of signed JAR files.
    29 Generates signatures for Java ARchive (JAR) files, and verifies the signatures of signed JAR files.
    33 .LP
    30 .LP
    34 .RE
       
    35 .SH "SYNOPSIS"
    31 .SH "SYNOPSIS"
    36 .LP
    32 .LP
    37 
       
    38 .LP
       
    39 .nf
    33 .nf
    40 \f3
    34 \f3
    41 .fl
    35 .fl
    42 \fP\f3jarsigner\fP [ options ] jar\-file alias
    36 \fP\f3jarsigner\fP [ options ] jar\-file alias
    43 .fl
    37 .fl
    48 .LP
    42 .LP
    49 .LP
    43 .LP
    50 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.
    44 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.
    51 .LP
    45 .LP
    52 .SH "DESCRIPTION"
    46 .SH "DESCRIPTION"
    53 .LP
       
    54 
       
    55 .LP
    47 .LP
    56 .LP
    48 .LP
    57 The \f3jarsigner\fP tool is used for two purposes:
    49 The \f3jarsigner\fP tool is used for two purposes:
    58 .LP
    50 .LP
    59 .RS 3
    51 .RS 3
   107 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.
    99 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 .LP
   100 .LP
   109 .SS 
   101 .SS 
   110 Keystore Aliases
   102 Keystore Aliases
   111 .LP
   103 .LP
   112 .RS 3
       
   113 
       
   114 .LP
       
   115 .LP
   104 .LP
   116 All keystore entities are accessed via unique \f2aliases\fP.
   105 All keystore entities are accessed via unique \f2aliases\fP.
   117 .LP
   106 .LP
   118 .LP
   107 .LP
   119 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.
   108 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.
   120 .LP
   109 .LP
   121 .nf
   110 .nf
   122 \f3
   111 \f3
   123 .fl
   112 .fl
   124     jarsigner \-keystore /working/mystore \-storepass myspass
   113     jarsigner \-keystore /working/mystore \-storepass \fP\f4<keystore password>\fP\f3
   125 .fl
   114 .fl
   126       \-keypass dukekeypasswd MyJARFile.jar duke 
   115       \-keypass \fP\f4<private key password>\fP\f3 MyJARFile.jar duke
   127 .fl
   116 .fl
   128 \fP
   117 \fP
   129 .fi
   118 .fi
   130 
   119 
   131 .LP
   120 .LP
   132 .LP
   121 .LP
   133 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.
   122 Keystores are protected with a password, so the store password 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 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.
   134 .LP
   123 .LP
   135 .RE
       
   136 .SS 
   124 .SS 
   137 Keystore Location
   125 Keystore Location
   138 .LP
   126 .LP
   139 .RS 3
       
   140 
       
   141 .LP
       
   142 .LP
   127 .LP
   143 \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.
   128 \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.
   144 .LP
   129 .LP
   145 .LP
   130 .LP
   146 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.
   131 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.
   147 .LP
   132 .LP
   148 .RE
       
   149 .SS 
   133 .SS 
   150 Keystore Implementation
   134 Keystore Implementation
   151 .LP
       
   152 .RS 3
       
   153 
       
   154 .LP
   135 .LP
   155 .LP
   136 .LP
   156 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.
   137 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.
   157 .LP
   138 .LP
   158 .LP
   139 .LP
   164 .LP
   145 .LP
   165 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 
   146 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 
   166 .na
   147 .na
   167 \f2How to Implement a Provider for the Java Cryptography Architecture\fP @
   148 \f2How to Implement a Provider for the Java Cryptography Architecture\fP @
   168 .fi
   149 .fi
   169 http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/HowToImplAProvider.html.
   150 http://download.oracle.com/javase/7/docs/technotes/guides/security/crypto/HowToImplAProvider.html.
   170 .LP
   151 .LP
   171 .LP
   152 .LP
   172 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.
   153 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.
   173 .LP
   154 .LP
   174 .LP
   155 .LP
   175 \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.
   156 \f3keytool\fP works on any file\-based keystore implementation. (It treats the keystore 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.
   176 .LP
   157 .LP
   177 .LP
   158 .LP
   178 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.
   159 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.
   179 .LP
   160 .LP
   180 .LP
   161 .LP
   225 .LP
   206 .LP
   226 Note that if you us the PKCS#11 provider package, you should refer to the 
   207 Note that if you us the PKCS#11 provider package, you should refer to the 
   227 .na
   208 .na
   228 \f2KeyTool and JarSigner\fP @
   209 \f2KeyTool and JarSigner\fP @
   229 .fi
   210 .fi
   230 http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#KeyToolJarSigner section of the Java PKCS#11 Reference Guide for details.
   211 http://download.oracle.com/javase/7/docs/technotes/guides/security/p11guide.html#KeyToolJarSigner section of the Java PKCS#11 Reference Guide for details.
   231 .LP
   212 .LP
   232 .RE
       
   233 .SS 
   213 .SS 
   234 Supported Algorithms
   214 Supported Algorithms
   235 .LP
   215 .LP
   236 .RS 3
   216 .LP
   237 
   217 By default, \f3jarsigner\fP signs a JAR file using one of the following:
   238 .LP
   218 .LP
   239 .LP
   219 .RS 3
   240 By default, \f3jarsigner\fP signs a JAR file using either
   220 .TP 2
   241 .LP
   221 o
   242 .RS 3
   222 DSA (Digital Signature Algorithm) with the SHA1 digest algorithm 
   243 .TP 2
   223 .TP 2
   244 o
   224 o
   245 DSA (Digital Signature Algorithm) with the SHA\-1 digest algorithm, or 
   225 RSA algorithm with the SHA256 digest algorithm. 
   246 .TP 2
   226 .TP 2
   247 o
   227 o
   248 the RSA algorithm with the SHA\-256 digest algorithm. 
   228 EC (Elliptic Curve) cryptography algorithm with the SHA256 with ECDSA (Elliptic Curve Digital Signature Algorithm). 
   249 .RE
   229 .RE
   250 
   230 
   251 .LP
   231 .LP
   252 .LP
   232 .LP
   253 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 "SHA256withRSA" algorithm.
   233 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 "SHA256withRSA" algorithm. If the signer's keys are EC keys, \f3jarsigner\fP will sign the JAR file using the "SHA256withECDSA" algorithm.
   254 .LP
   234 .LP
   255 .LP
   235 .LP
   256 These default signature algorithms can be overridden using the \f2\-sigalg\fP option.
   236 These default signature algorithms can be overridden using the \f2\-sigalg\fP option.
   257 .LP
   237 .LP
   258 .RE
       
   259 .SS 
   238 .SS 
   260 The Signed JAR File
   239 The Signed JAR File
   261 .LP
   240 .LP
   262 .RS 3
       
   263 
       
   264 .LP
       
   265 .LP
   241 .LP
   266 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:
   242 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:
   267 .LP
   243 .LP
   268 .RS 3
   244 .RS 3
   269 .TP 2
   245 .TP 2
   270 o
   246 o
   271 a signature file, with a .SF extension, and 
   247 a signature file, with a .SF extension, and 
   272 .TP 2
   248 .TP 2
   273 o
   249 o
   274 a signature block file, with a .DSA extension. 
   250 a signature block file, with a .DSA, .RSA, or .EC extension. 
   275 .RE
   251 .RE
   276 
   252 
   277 .LP
   253 .LP
   278 .LP
   254 .LP
   279 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
   255 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
   280 .LP
   256 .LP
   281 .nf
   257 .nf
   282 \f3
   258 \f3
   283 .fl
   259 .fl
   284   \-sigFile MKSIGN
   260 \-sigFile MKSIGN
   285 .fl
   261 .fl
   286 \fP
   262 \fP
   287 .fi
   263 .fi
   288 
   264 
   289 .LP
   265 .LP
   290 .LP
   266 .LP
   291 the files are named "MKSIGN.SF" and "MKSIGN.DSA".
   267 The files are named "MKSIGN.SF" and "MKSIGN.DSA".
   292 .LP
   268 .LP
   293 .LP
   269 .LP
   294 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.
   270 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.
   295 .LP
   271 .LP
   296 \f3The Signature (.SF) File\fP
   272 \f3The Signature (.SF) File\fP
   297 .LP
   273 .LP
   298 .RS 3
       
   299 
       
   300 .LP
       
   301 .LP
   274 .LP
   302 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:
   275 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:
   303 .LP
   276 .LP
   304 .RS 3
   277 .RS 3
   305 .TP 2
   278 .TP 2
   318 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.
   291 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.
   319 .LP
   292 .LP
   320 .LP
   293 .LP
   321 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.
   294 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.
   322 .LP
   295 .LP
   323 .RE
   296 \f3The Signature Block File\fP
   324 \f3The Signature Block (.DSA) File\fP
   297 .LP
   325 .LP
   298 The .SF file is signed and the signature is placed in the signature block file. This 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. The file has the extension .DSA, .RSA, or .EC depending on the digest algorithm used. 
   326 .RS 3
       
   327 
       
   328 .LP
       
   329 .LP
       
   330 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.
       
   331 .LP
       
   332 .RE
       
   333 .RE
       
   334 .SS 
   299 .SS 
   335 Signature Timestamp
   300 Signature Timestamp
   336 .LP
   301 .LP
   337 .RS 3
   302 .LP
   338 
   303 \f2jarsigner\fP tool can 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:
   339 .LP
       
   340 .LP
       
   341 \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:
       
   342 .LP
   304 .LP
   343 .RS 3
   305 .RS 3
   344 .TP 2
   306 .TP 2
   345 o
   307 o
   346 \f2\-tsa url\fP 
   308 \f2\-tsa url\fP 
   357 
   319 
   358 .LP
   320 .LP
   359 .LP
   321 .LP
   360 Each of these options is detailed in the Options section below.
   322 Each of these options is detailed in the Options section below.
   361 .LP
   323 .LP
   362 .RE
       
   363 .SS 
   324 .SS 
   364 JAR File Verification
   325 JAR File Verification
   365 .LP
   326 .LP
   366 .RS 3
       
   367 
       
   368 .LP
       
   369 .LP
   327 .LP
   370 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:
   328 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:
   371 .LP
   329 .LP
   372 .RS 3
   330 .RS 3
   373 .TP 3
   331 .TP 3
   374 1.
   332 1.
   375 Verify the signature of the .SF file itself. 
   333 Verify the signature of the .SF file itself.
   376 .LP
   334 .br
   377 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.  
   335 .br
       
   336 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. 
   378 .TP 3
   337 .TP 3
   379 2.
   338 2.
   380 Verify the digest listed in each entry in the .SF file with each corresponding section in the manifest. 
   339 Verify the digest listed in each entry in the .SF file with each corresponding section in the manifest.
   381 .LP
   340 .br
   382 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. 
   341 .br
   383 .LP
   342 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 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). 
   343 .br
   385 .LP
   344 .br
   386 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.  
   345 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).
       
   346 .br
       
   347 .br
       
   348 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. 
   387 .TP 3
   349 .TP 3
   388 3.
   350 3.
   389 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. 
   351 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. 
   390 .RE
   352 .RE
   391 
   353 
   392 .LP
   354 .LP
   393 .LP
   355 .LP
   394 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.
   356 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.
   395 .LP
   357 .LP
   396 .RE
       
   397 .SS 
   358 .SS 
   398 Multiple Signatures for a JAR File
   359 Multiple Signatures for a JAR File
   399 .LP
   360 .LP
   400 .RS 3
       
   401 
       
   402 .LP
       
   403 .LP
   361 .LP
   404 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:
   362 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:
   405 .LP
   363 .LP
   406 .nf
   364 .nf
   407 \f3
   365 \f3
   433 
   391 
   434 .LP
   392 .LP
   435 .LP
   393 .LP
   436 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.
   394 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.
   437 .LP
   395 .LP
   438 .RE
       
   439 .SH "OPTIONS"
   396 .SH "OPTIONS"
   440 .LP
   397 .LP
   441 
       
   442 .LP
       
   443 .LP
   398 .LP
   444 The various \f3jarsigner\fP options are listed and described below. Note:
   399 The various \f3jarsigner\fP options are listed and described below. Note:
   445 .LP
   400 .LP
   446 .RS 3
   401 .RS 3
   447 .TP 2
   402 .TP 2
   460 
   415 
   461 .LP
   416 .LP
   462 .RS 3
   417 .RS 3
   463 .TP 3
   418 .TP 3
   464 \-keystore url 
   419 \-keystore url 
   465 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. 
   420 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.
   466 .LP
   421 .br
   467 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). 
   422 .br
   468 .LP
   423 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 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. 
   424 .br
   470 .LP
   425 .br
       
   426 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.
       
   427 .br
       
   428 .br
   471 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, 
   429 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, 
   472 .nf
   430 .nf
   473 \f3
   431 \f3
   474 .fl
   432 .fl
   475   \-keystore \fP\f4filePathAndName\fP\f3
   433   \-keystore \fP\f4filePathAndName\fP\f3
   492 .TP 2
   450 .TP 2
   493 o
   451 o
   494 \f2\-storetype PKCS11\fP 
   452 \f2\-storetype PKCS11\fP 
   495 .RE
   453 .RE
   496 For example, this command lists the contents of the configured PKCS#11 token: 
   454 For example, this command lists the contents of the configured PKCS#11 token: 
   497 .RS 3
       
   498 
       
   499 .LP
       
   500 .nf
   455 .nf
   501 \f3
   456 \f3
   502 .fl
   457 .fl
   503    jarsigner \-keystore NONE \-storetype PKCS11 \-list
   458    jarsigner \-keystore NONE \-storetype PKCS11 \-list
   504 .fl
   459 .fl
   505   
   460 \fP
   506 .fl
   461 .fi
   507 \fP
       
   508 .fi
       
   509 .RE
       
   510 .TP 3
   462 .TP 3
   511 \-storetype storetype 
   463 \-storetype storetype 
   512 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. 
   464 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.
   513 .LP
   465 .br
   514 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.  
   466 .br
   515 .TP 3
   467 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 \-storepass password 
   468 .TP 3
   517 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. 
   469 \-storepass[:env | :file] argument 
   518 .LP
   470 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 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.  
   471 .br
   520 .TP 3
   472 .br
   521 \-keypass password 
   473 If the modifier \f2env\fP or \f2file\fP is not specified, then the password has the value \f2argument\fP. Otherwise, the password is retrieved as follows: 
   522 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. 
   474 .RS 3
   523 .LP
   475 .TP 2
   524 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.  
   476 o
       
   477 \f2env\fP: Retrieve the password from the environment variable named \f2argument\fP 
       
   478 .TP 2
       
   479 o
       
   480 \f2file\fP: Retrieve the password from the file named \f2argument\fP 
       
   481 .RE
       
   482 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. 
       
   483 .TP 3
       
   484 \-keypass[:env | :file] argument 
       
   485 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.
       
   486 .br
       
   487 .br
       
   488 If the modifier \f2env\fP or \f2file\fP is not specified, then the password has the value \f2argument\fP. Otherwise, the password is retrieved as follows: 
       
   489 .RS 3
       
   490 .TP 2
       
   491 o
       
   492 \f2env\fP: Retrieve the password from the environment variable named \f2argument\fP 
       
   493 .TP 2
       
   494 o
       
   495 \f2file\fP: Retrieve the password from the file named \f2argument\fP 
       
   496 .RE
       
   497 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. 
   525 .TP 3
   498 .TP 3
   526 \-sigfile file 
   499 \-sigfile file 
   527 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. 
   500 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.
   528 .LP
   501 .br
   529 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. 
   502 .br
   530 .LP
   503 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 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.  
   504 .br
       
   505 .br
       
   506 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. 
   532 .TP 3
   507 .TP 3
   533 \-sigalg algorithm 
   508 \-sigalg algorithm 
   534 .RS 3
   509 Specifies the name of the signature algorithm to use to sign the JAR file.
   535 
   510 .br
   536 .LP
   511 .br
   537 Specifies the name of the signature algorithm to use to sign the JAR file. 
       
   538 .LP
       
   539 See 
   512 See 
   540 .na
   513 .na
   541 \f2Appendix A\fP @
   514 \f2Appendix A\fP @
   542 .fi
   515 .fi
   543 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 SHA256withRSA 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.
   516 http://download.oracle.com/javase/7/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, SHA256withRSA, or SHA256withECDSA 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. 
   544 .LP
       
   545 .RE
       
   546 .TP 3
   517 .TP 3
   547 \-digestalg algorithm 
   518 \-digestalg algorithm 
   548 .RS 3
   519 Specifies the name of the message digest algorithm to use when digesting the entries of a jar file.
   549 Specifies the name of the message digest algorithm to use when digesting the entries of a jar file. 
   520 .br
   550 .LP
   521 .br
   551 See 
   522 See 
   552 .na
   523 .na
   553 \f2Appendix A\fP @
   524 \f2Appendix A\fP @
   554 .fi
   525 .fi
   555 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\-256 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.
   526 http://download.oracle.com/javase/7/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, SHA256 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. 
   556 .LP
       
   557 .RE
       
   558 .TP 3
   527 .TP 3
   559 \-signedjar file 
   528 \-signedjar file 
   560 Specifies the name to be used for the signed JAR file. 
   529 Specifies the name to be used for the signed JAR file.
   561 .LP
   530 .br
   562 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.  
   531 .br
       
   532 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. 
   563 .TP 3
   533 .TP 3
   564 \-verify 
   534 \-verify 
   565 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)" 
   535 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)"
   566 .LP
   536 .br
   567 It is possible to verify JAR files signed using either \f3jarsigner\fP or the JDK 1.1 \f3javakey\fP tool, or both. 
   537 .br
   568 .LP
   538 It is possible to verify JAR files signed using either \f3jarsigner\fP or the JDK 1.1 \f3javakey\fP tool, or both.
   569 For further information on verification, see JAR File Verification.  
   539 .br
       
   540 .br
       
   541 For further information on verification, see JAR File Verification. 
   570 .TP 3
   542 .TP 3
   571 \-certs 
   543 \-certs 
   572 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 
   544 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 
   573 .RS 3
   545 .RS 3
   574 .TP 2
   546 .TP 2
   576 the name of the type of certificate (stored in the .DSA file) that certifies the signer's public key 
   548 the name of the type of certificate (stored in the .DSA file) that certifies the signer's public key 
   577 .TP 2
   549 .TP 2
   578 o
   550 o
   579 if the certificate is an X.509 certificate (more specifically, an instance of \f2java.security.cert.X509Certificate\fP): the distinguished name of the signer 
   551 if the certificate is an X.509 certificate (more specifically, an instance of \f2java.security.cert.X509Certificate\fP): the distinguished name of the signer 
   580 .RE
   552 .RE
   581 .LP
       
   582 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: 
   553 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: 
   583 .RS 3
   554 .RS 3
   584 .TP 2
   555 .TP 2
   585 o
   556 o
   586 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. 
   557 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. 
   594 .TP 3
   565 .TP 3
   595 \-internalsf 
   566 \-internalsf 
   596 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 
   567 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 
   597 .TP 3
   568 .TP 3
   598 \-sectionsonly 
   569 \-sectionsonly 
   599 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 . 
   570 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 .
   600 .LP
   571 .br
   601 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. 
   572 .br
   602 .LP
   573 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 For further information, see JAR File Verification. 
   574 .br
   604 .LP
   575 .br
   605 \f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP  
   576 For further information, see JAR File Verification.
       
   577 .br
       
   578 .br
       
   579 \f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP 
   606 .TP 3
   580 .TP 3
   607 \-protected 
   581 \-protected 
   608 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. 
   582 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. 
   609 .RE
   583 .TP 3
   610 .RS 3
   584 \-providerClass provider\-class\-name 
   611 .TP 3
   585 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.
   612 \-provider provider\-class\-name 
   586 .br
   613 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. 
   587 .br
   614 .LP
       
   615 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. 
   588 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. 
   616 .RS 3
       
   617 
       
   618 .LP
       
   619 .nf
   589 .nf
   620 \f3
   590 \f3
   621 .fl
   591 .fl
   622 jarsigner \-keystore NONE \-storetype PKCS11 \\ 
   592 jarsigner \-keystore NONE \-storetype PKCS11 \\ 
   623 .fl
   593 .fl
   627 .fl
   597 .fl
   628           \-list
   598           \-list
   629 .fl
   599 .fl
   630 \fP
   600 \fP
   631 .fi
   601 .fi
   632 .RE
       
   633 .TP 3
   602 .TP 3
   634 \-providerName providerName 
   603 \-providerName providerName 
   635 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. 
   604 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.
   636 .LP
   605 .br
       
   606 .br
   637 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 
   607 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 
   638 .na
   608 .na
   639 \f2configuration attributes table\fP @
   609 \f2configuration attributes table\fP @
   640 .fi
   610 .fi
   641 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: 
   611 http://download.oracle.com/javase/7/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: 
   642 .RS 3
       
   643 
       
   644 .LP
       
   645 .nf
   612 .nf
   646 \f3
   613 \f3
   647 .fl
   614 .fl
   648 jarsigner \-keystore NONE \-storetype PKCS11 \\ 
   615 jarsigner \-keystore NONE \-storetype PKCS11 \\ 
   649 .fl
   616 .fl
   651 .fl
   618 .fl
   652         \-list
   619         \-list
   653 .fl
   620 .fl
   654 \fP
   621 \fP
   655 .fi
   622 .fi
   656 .RE
       
   657 .TP 3
   623 .TP 3
   658 \-Jjavaoption 
   624 \-Jjavaoption 
   659 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. 
   625 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.  
   660 .LP
       
   661 .TP 3
   626 .TP 3
   662 \-tsa url 
   627 \-tsa url 
   663 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. 
   628 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.
   664 .LP
   629 .br
       
   630 .br
   665 To generate the timestamp, \f2jarsigner\fP communicates with the TSA using the Time\-Stamp Protocol (TSP) defined in 
   631 To generate the timestamp, \f2jarsigner\fP communicates with the TSA using the Time\-Stamp Protocol (TSP) defined in 
   666 .na
   632 .na
   667 \f2RFC 3161\fP @
   633 \f2RFC 3161\fP @
   668 .fi
   634 .fi
   669 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. 
   635 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.  
   670 .LP
       
   671 .TP 3
   636 .TP 3
   672 \-tsacert alias 
   637 \-tsacert alias 
   673 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. 
   638 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.
   674 .LP
   639 .br
   675 The TSA's public key certificate must be present in the keystore when using \f2\-tsacert\fP. 
   640 .br
   676 .LP
   641 The TSA's public key certificate must be present in the keystore when using \f2\-tsacert\fP.  
   677 .TP 3
   642 .TP 3
   678 \-altsigner class 
   643 \-altsigner class 
   679 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. 
   644 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.
   680 .LP
   645 .br
   681 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 
   646 .br
   682 .LP
   647 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 .TP 3
   648 .TP 3
   684 \-altsignerpath classpathlist 
   649 \-altsignerpath classpathlist 
   685 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. 
   650 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.
   686 .LP
   651 .br
   687 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. 
   652 .br
   688 .LP
   653 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.
       
   654 .br
       
   655 .br
   689 Example of specifying the path to a jar file that contains the class file: 
   656 Example of specifying the path to a jar file that contains the class file: 
   690 .RS 3
   657 .nf
   691 
   658 \f3
   692 .LP
   659 .fl
   693 .LP
   660 \-altsignerpath /home/user/lib/authsigner.jar
   694 \f2\-altsignerpath /home/user/lib/authsigner.jar\fP
   661 .fl
   695 .LP
   662 \fP
   696 .RE
   663 .fi
   697 .LP
   664 Note that the JAR file name is included.
   698 Note that the JAR file name is included. 
   665 .br
   699 .LP
   666 .br
   700 Example of specifying the path to the jar file that contains the class file: 
   667 Example of specifying the path to the jar file that contains the class file: 
   701 .RS 3
   668 .nf
   702 .LP
   669 \f3
   703 \f2\-altsignerpath /home/user/classes/com/sun/tools/jarsigner/\fP
   670 .fl
   704 .LP
   671 \-altsignerpath /home/user/classes/com/sun/tools/jarsigner/
   705 .RE
   672 .fl
   706 .LP
   673 \fP
   707 Note that the JAR file name is omitted.  
   674 .fi
       
   675 Note that the JAR file name is omitted. 
   708 .TP 3
   676 .TP 3
   709 \-strict 
   677 \-strict 
   710 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. 
   678 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. 
   711 .TP 3
   679 .TP 3
   712 \-verbose:sub\-options 
   680 \-verbose:sub\-options 
   713 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. 
   681 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. 
   714 .RE
   682 .RE
       
   683 
       
   684 .LP
   715 .SH "EXAMPLES"
   685 .SH "EXAMPLES"
   716 .LP
       
   717 
       
   718 .LP
   686 .LP
   719 .SS 
   687 .SS 
   720 Signing a JAR File
   688 Signing a JAR File
   721 .LP
   689 .LP
   722 .RS 3
   690 .LP
   723 
   691 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. You can use the following to sign the JAR file and name the signed JAR file "sbundle.jar":
   724 .LP
   692 .LP
   725 .LP
   693 .nf
   726 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":
   694 \f3
   727 .LP
   695 .fl
   728 .nf
   696     jarsigner \-keystore /working/mystore \-storepass \fP\f4<keystore password>\fP\f3
   729 \f3
   697 .fl
   730 .fl
   698       \-keypass \fP\f4<private key password>\fP\f3 \-signedjar sbundle.jar bundle.jar jane
   731     jarsigner \-keystore /working/mystore \-storepass myspass
       
   732 .fl
       
   733       \-keypass j638klm \-signedjar sbundle.jar bundle.jar jane 
       
   734 .fl
   699 .fl
   735 \fP
   700 \fP
   736 .fi
   701 .fi
   737 
   702 
   738 .LP
   703 .LP
   745 .nf
   710 .nf
   746 \f3
   711 \f3
   747 .fl
   712 .fl
   748     jarsigner \-keystore /working/mystore
   713     jarsigner \-keystore /working/mystore
   749 .fl
   714 .fl
   750       \-signedjar sbundle.jar bundle.jar jane 
   715       \-signedjar sbundle.jar bundle.jar jane
   751 .fl
   716 .fl
   752 \fP
   717 \fP
   753 .fi
   718 .fi
   754 
   719 
   755 .LP
   720 .LP
   757 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:
   722 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:
   758 .LP
   723 .LP
   759 .nf
   724 .nf
   760 \f3
   725 \f3
   761 .fl
   726 .fl
   762     jarsigner \-signedjar sbundle.jar bundle.jar jane 
   727     jarsigner \-signedjar sbundle.jar bundle.jar jane
   763 .fl
   728 .fl
   764 \fP
   729 \fP
   765 .fi
   730 .fi
   766 
   731 
   767 .LP
   732 .LP
   769 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:
   734 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:
   770 .LP
   735 .LP
   771 .nf
   736 .nf
   772 \f3
   737 \f3
   773 .fl
   738 .fl
   774     jarsigner bundle.jar jane 
   739     jarsigner bundle.jar jane
   775 .fl
   740 .fl
   776 \fP
   741 \fP
   777 .fi
   742 .fi
   778 .RE
       
   779 
   743 
   780 .LP
   744 .LP
   781 .SS 
   745 .SS 
   782 Verifying a Signed JAR File
   746 Verifying a Signed JAR File
   783 .LP
   747 .LP
   784 .RS 3
       
   785 
       
   786 .LP
       
   787 .LP
   748 .LP
   788 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:
   749 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:
   789 .LP
   750 .LP
   790 .nf
   751 .nf
   791 \f3
   752 \f3
   792 .fl
   753 .fl
   793     jarsigner \-verify sbundle.jar 
   754     jarsigner \-verify sbundle.jar
   794 .fl
   755 .fl
   795 \fP
   756 \fP
   796 .fi
   757 .fi
   797 
   758 
   798 .LP
   759 .LP
   849 .LP
   810 .LP
   850 .SS 
   811 .SS 
   851 Verification with Certificate Information
   812 Verification with Certificate Information
   852 .LP
   813 .LP
   853 .LP
   814 .LP
   854 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,
   815 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 (if and only if 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,
   855 .LP
   816 .LP
   856 .nf
   817 .nf
   857 \f3
   818 \f3
   858 .fl
   819 .fl
   859     jarsigner \-keystore /working/mystore \-verify \-verbose \-certs myTest.jar
   820     jarsigner \-keystore /working/mystore \-verify \-verbose \-certs myTest.jar
   959 
   920 
   960 .LP
   921 .LP
   961 .LP
   922 .LP
   962 Note that the alias "duke" is in brackets to denote that it is an identity database alias, not a keystore alias.
   923 Note that the alias "duke" is in brackets to denote that it is an identity database alias, not a keystore alias.
   963 .LP
   924 .LP
   964 .RE
       
   965 .SH "WARNINGS"
   925 .SH "WARNINGS"
   966 .LP
   926 .LP
   967 
       
   968 .LP
       
   969 During the signing/verifying process, jarsigner may display various warnings. These warning codes are defined as follows: 
   927 During the signing/verifying process, jarsigner may display various warnings. These warning codes are defined as follows: 
   970 .nf
   928 .nf
   971 \f3
   929 \f3
   972 .fl
   930 .fl
   973          hasExpiringCert         2
   931          hasExpiringCert         2
   978 .fl
   936 .fl
   979          hasExpiredCert          4
   937          hasExpiredCert          4
   980 .fl
   938 .fl
   981              This jar contains entries whose signer certificate has expired.
   939              This jar contains entries whose signer certificate has expired.
   982 .fl
   940 .fl
   983          
   941 
   984 .fl
   942 .fl
   985          notYetValidCert         4
   943          notYetValidCert         4
   986 .fl
   944 .fl
   987              This jar contains entries whose signer certificate is not yet valid.
   945              This jar contains entries whose signer certificate is not yet valid.
   988 .fl
   946 .fl
   989          
   947 
   990 .fl
   948 .fl
   991          chainNotValidated       4
   949          chainNotValidated       4
   992 .fl
   950 .fl
   993              This jar contains entries whose certificate chain cannot be correctly validated.
   951              This jar contains entries whose certificate chain cannot be correctly validated.
   994 .fl
   952 .fl
   995          
   953 
   996 .fl
   954 .fl
   997          badKeyUsage             8
   955          badKeyUsage             8
   998 .fl
   956 .fl
   999              This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing.
   957              This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing.
  1000 .fl
   958 .fl
  1001          
   959 
  1002 .fl
   960 .fl
  1003          badExtendedKeyUsage     8
   961          badExtendedKeyUsage     8
  1004 .fl
   962 .fl
  1005              This jar contains entries whose signer certificate's ExtendedKeyUsage extension
   963              This jar contains entries whose signer certificate's ExtendedKeyUsage extension
  1006 .fl
   964 .fl
  1007              doesn't allow code signing.
   965              doesn't allow code signing.
  1008 .fl
   966 .fl
  1009          
   967 
  1010 .fl
   968 .fl
  1011          badNetscapeCertType     8
   969          badNetscapeCertType     8
  1012 .fl
   970 .fl
  1013              This jar contains entries whose signer certificate's NetscapeCertType extension 
   971              This jar contains entries whose signer certificate's NetscapeCertType extension
  1014 .fl
   972 .fl
  1015              doesn't allow code signing.
   973              doesn't allow code signing.
  1016 .fl
   974 .fl
  1017          
   975 
  1018 .fl
   976 .fl
  1019          hasUnsignedEntry        16
   977          hasUnsignedEntry        16
  1020 .fl
   978 .fl
  1021              This jar contains unsigned entries which have not been integrity\-checked.
   979              This jar contains unsigned entries which have not been integrity\-checked.
  1022 .fl
   980 .fl
  1023          
   981 
  1024 .fl
   982 .fl
  1025          notSignedByAlias        32
   983          notSignedByAlias        32
  1026 .fl
   984 .fl
  1027              This jar contains signed entries which are not signed by the specified alias(es)
   985              This jar contains signed entries which are not signed by the specified alias(es)
  1028 .fl
   986 .fl
  1029          
   987 
  1030 .fl
   988 .fl
  1031          aliasNotInStore         32
   989          aliasNotInStore         32
  1032 .fl
   990 .fl
  1033              This jar contains signed entries that are not signed by alias in this keystore
   991              This jar contains signed entries that are not signed by alias in this keystore
  1034 .fl
   992 .fl
  1035    
   993 
  1036 .fl
   994 .fl
  1037 \fP
   995 \fP
  1038 .fi
   996 .fi
  1039 
   997 
  1040 .LP
   998 .LP
  1041 .LP
   999 .LP
  1042 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.
  1000 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.
  1043 .LP
  1001 .LP
  1044 .LP
  1002 .LP
  1045 \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
  1003 \f3Note\fP: Exit codes are reused because only 0\-255 is legal for Unix. In any case, if the signing/verifying process fails, the following exit code will be returned:
  1046 .LP
  1004 .LP
  1047 .nf
  1005 .nf
  1048 \f3
  1006 \f3
  1049 .fl
  1007 .fl
  1050 failure                 1 
  1008 failure                 1
  1051 .fl
  1009 .fl
  1052 \fP
  1010 \fP
  1053 .fi
  1011 .fi
  1054 
  1012 
  1055 .LP
  1013 .LP
  1056 will be returned. 
       
  1057 .SS 
  1014 .SS 
  1058 Compatibility with JDK 1.1
  1015 Compatibility with JDK 1.1
  1059 .LP
       
  1060 .RS 3
       
  1061 
       
  1062 .LP
  1016 .LP
  1063 .LP
  1017 .LP
  1064 The \f3keytool\fP and \f3jarsigner\fP tools completely replace the \f3javakey\fP tool provided in JDK 1.1. These new tools provide more features than \f3javakey\fP, including the ability to protect the keystore and private keys with passwords, and the ability to verify signatures in addition to generating them.
  1018 The \f3keytool\fP and \f3jarsigner\fP tools completely replace the \f3javakey\fP tool provided in JDK 1.1. These new tools provide more features than \f3javakey\fP, including the ability to protect the keystore and private keys with passwords, and the ability to verify signatures in addition to generating them.
  1065 .LP
  1019 .LP
  1066 .LP
  1020 .LP
  1388 .nr 43 \n(82+(3*\n(38)
  1342 .nr 43 \n(82+(3*\n(38)
  1389 .nr 83 +\n(43
  1343 .nr 83 +\n(43
  1390 .nr 44 \n(83+(3*\n(38)
  1344 .nr 44 \n(83+(3*\n(38)
  1391 .nr 84 +\n(44
  1345 .nr 84 +\n(44
  1392 .nr TW \n(84
  1346 .nr TW \n(84
  1393 .if t .if \n(TW>\n(.li .tm Table at line 1128 file Input is too wide - \n(TW units
  1347 .if t .if \n(TW>\n(.li .tm Table at line 1082 file Input is too wide - \n(TW units
  1394 .fc  
  1348 .fc  
  1395 .nr #T 0-1
  1349 .nr #T 0-1
  1396 .nr #a 0-1
  1350 .nr #a 0-1
  1397 .eo
  1351 .eo
  1398 .de T#
  1352 .de T#
  1589 .RE
  1543 .RE
  1590 
  1544 
  1591 .LP
  1545 .LP
  1592 .SH "SEE ALSO"
  1546 .SH "SEE ALSO"
  1593 .LP
  1547 .LP
  1594 
       
  1595 .LP
       
  1596 .RS 3
  1548 .RS 3
  1597 .TP 2
  1549 .TP 2
  1598 o
  1550 o
  1599 jar(1) tool documentation 
  1551 jar(1) tool documentation 
  1600 .TP 2
  1552 .TP 2
  1604 o
  1556 o
  1605 the 
  1557 the 
  1606 .na
  1558 .na
  1607 \f4Security\fP @
  1559 \f4Security\fP @
  1608 .fi
  1560 .fi
  1609 http://java.sun.com/docs/books/tutorial/security/index.html trail of the 
  1561 http://download.oracle.com/javase/tutorial/security/index.html trail of the 
  1610 .na
  1562 .na
  1611 \f4Java Tutorial\fP @
  1563 \f4Java Tutorial\fP @
  1612 .fi
  1564 .fi
  1613 http://java.sun.com/docs/books/tutorial/index.html for examples of the use of the \f3jarsigner\fP tool 
  1565 http://download.oracle.com/javase/tutorial/index.html for examples of the use of the \f3jarsigner\fP tool 
  1614 .RE
  1566 .RE
  1615 
  1567 
  1616 .LP
  1568 .LP
  1617 .RE
       
  1618  
  1569