1 '\" t 2 .\" Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 3 .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 .\" 5 .\" This code is free software; you can redistribute it and/or modify it 6 .\" under the terms of the GNU General Public License version 2 only, as 7 .\" published by the Free Software Foundation. 8 .\" 9 .\" This code is distributed in the hope that it will be useful, but WITHOUT 10 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 .\" version 2 for more details (a copy is included in the LICENSE file that 13 .\" accompanied this code). 14 .\" 15 .\" You should have received a copy of the GNU General Public License version 16 .\" 2 along with this work; if not, write to the Free Software Foundation, 17 .\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 .\" 19 .\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 .\" or visit www.oracle.com if you need additional information or have any 21 .\" questions. 22 .\" 23 .\" Arch: generic 24 .\" Software: JDK 8 25 .\" Date: 21 November 2013 26 .\" SectDesc: Security Tools 27 .\" Title: jarsigner.1 28 .\" 29 .if n .pl 99999 30 .TH jarsigner 1 "21 November 2013" "JDK 8" "Security Tools" 31 .\" ----------------------------------------------------------------- 32 .\" * Define some portability stuff 33 .\" ----------------------------------------------------------------- 34 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 35 .\" http://bugs.debian.org/507673 36 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html 37 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38 .ie \n(.g .ds Aq \(aq 39 .el .ds Aq ' 40 .\" ----------------------------------------------------------------- 41 .\" * set default formatting 42 .\" ----------------------------------------------------------------- 43 .\" disable hyphenation 44 .nh 45 .\" disable justification (adjust text to left margin only) 46 .ad l 47 .\" ----------------------------------------------------------------- 48 .\" * MAIN CONTENT STARTS HERE * 49 .\" ----------------------------------------------------------------- 50 51 .SH NAME 52 jarsigner \- Signs and verifies Java Archive (JAR) files\&. 53 .SH SYNOPSIS 54 .sp 55 .nf 56 57 \fBjarsigner\fR [ \fIoptions\fR ] \fIjar\-file\fR \fIalias\fR 58 .fi 59 .nf 60 61 \fBjarsigner\fR \fB\-verify\fR [ \fIoptions\fR ] \fIjar\-file\fR [\fIalias \&.\&.\&.\fR] 62 .fi 63 .sp 64 .TP 65 \fIoptions\fR 66 The command-line options\&. See Options\&. 67 .TP 68 -verify 69 .br 70 The \f3-verify\fR option can take zero or more keystore alias names after the JAR file name\&. When the \f3-verify\fR option is specified, the \f3jarsigner\fR command checks 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 \f3-keystore\fR or the default keystore\&. 71 72 If you also specified the \f3-strict\fR option, and the \f3jarsigner\fR command detected severe warnings, the message, "jar verified, with signer errors" is displayed\&. 73 .TP 74 \fIjar-file\fR 75 The JAR file to be signed\&. 76 77 If you also specified the \f3-strict\fR option, and the \f3jarsigner\fR command detected severe warnings, the message, "jar signed, with signer errors" is displayed\&. 78 .TP 79 \fIalias\fR 80 The aliases are defined in the keystore specified by \f3-keystore\fR or the default keystore\&. 81 .SH DESCRIPTION 82 The \f3jarsigner\fR tool has two purposes: 83 .TP 0.2i 84 \(bu 85 To sign Java Archive (JAR) files\&. 86 .TP 0.2i 87 \(bu 88 To verify the signatures and integrity of signed JAR files\&. 89 .PP 90 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\fR enables developers to produce JAR files\&. (Technically, any zip file can also be considered a JAR file, although when created by the \f3jar\fR command or processed by the \f3jarsigner\fR command, JAR files also contain a \f3META-INF/MANIFEST\&.MF\fR file\&.) 91 .PP 92 A digital signature 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, and so on)\&. Similar to a handwritten signature, a digital signature has many useful characteristics: 93 .TP 0.2i 94 \(bu 95 Its authenticity can be verified by a computation that uses the public key corresponding to the private key used to generate the signature\&. 96 .TP 0.2i 97 \(bu 98 It cannot be forged, assuming the private key is kept secret\&. 99 .TP 0.2i 100 \(bu 101 It is a function of the data signed and thus cannot be claimed to be the signature for other data as well\&. 102 .TP 0.2i 103 \(bu 104 The signed data cannot be changed\&. If the data is changed, then the signature cannot be verified as authentic\&. 105 .PP 106 To generate an entity\&'s signature for a file, the entity must first have a public/private key pair associated with it and one or more certificates that authenticate its public key\&. A certificate is a digitally signed statement from one entity that says that the public key of another entity has a particular value\&. 107 .PP 108 The \f3jarsigner\fR command uses key and certificate information from a keystore to generate digital signatures for JAR files\&. A keystore is a database of private keys and their associated X\&.509 certificate chains that authenticate the corresponding public keys\&. The \f3keytool\fR command is used to create and administer keystores\&. 109 .PP 110 The \f3jarsigner\fR command 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\&. The \f3jarsigner\fR command can verify the digital signature of the signed JAR file using the certificate inside it (in its signature block file)\&. 111 .PP 112 The \f3jarsigner\fR command can generate signatures that include a time stamp that lets a systems or deployer (including Java Plug-in) to check whether the JAR file was signed while the signing certificate was still valid\&. In addition, APIs allow applications to obtain the timestamp information\&. 113 .PP 114 At this time, the \f3jarsigner\fR command can only sign JAR files created by the \f3jar\fR command or zip files\&. JAR files are the same as zip files, except they also have a \f3META-INF/MANIFEST\&.MF\fR file\&. A \f3META-INF/MANIFEST\&.MF\fR file is created when the \f3jarsigner\fR command signs a zip file\&. 115 .PP 116 The default \f3jarsigner\fR command behavior is to sign a JAR or zip file\&. Use the \f3-verify\fR option to verify a signed JAR file\&. 117 .PP 118 The \f3jarsigner\fR command also attempts to validate the signer\&'s certificate after signing or verifying\&. If there is a validation error or any other problem, the command generates warning messages\&. If you specify the \f3-strict\fR option, then the command treats severe warnings as errors\&. See Errors and Warnings\&. 119 .SS KEYSTORE\ ALIASES 120 All keystore entities are accessed with unique aliases\&. 121 .PP 122 When you use the \f3jarsigner\fR command to sign a JAR file, you must specify the alias for the keystore entry that contains the private key needed to generate the signature\&. For example, the following command signs the JAR file named \f3MyJARFile\&.jar\fR with the private key associated with the alias \f3duke\fR in the keystore named \f3mystore\fR in the \f3working\fR directory\&. Because no output file is specified, it overwrites \f3MyJARFile\&.jar\fR with the signed JAR file\&. 123 .sp 124 .nf 125 \f3jarsigner \-keystore /working/mystore \-storepass <keystore password>\fP 126 .fi 127 .nf 128 \f3 \-keypass <private key password> MyJARFile\&.jar duke\fP 129 .fi 130 .nf 131 \f3\fR 132 .fi 133 .sp 134 Keystores are protected with a password, so the store password must be specified\&. You are prompted for it when you do not 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 are prompted for the password when you do not specify it on the command line and it is not the same as the store password\&. 135 .SS KEYSTORE\ LOCATION 136 The \f3jarsigner\fR command has a \f3-keystore\fR option for specifying the URL of the keystore to be used\&. The keystore is by default stored in a file named \f3\&.keystore\fR in the user\&'s home directory, as determined by the \f3user\&.home\fR system property\&. 137 .PP 138 On Oracle Solaris systems, \f3user\&.home\fR defaults to the user\&'s home directory\&. 139 .PP 140 The input stream from the \f3-keystore\fR option is passed to the \f3KeyStore\&.load\fR method\&. If \f3NONE\fR is specified as the URL, then a null stream is passed to the \f3KeyStore\&.load\fR method\&. \f3NONE\fR should be specified when the \f3KeyStore\fR class is not file based, for example, when it resides on a hardware token device\&. 141 .SS KEYSTORE\ IMPLEMENTATION 142 The \f3KeyStore\fR class provided in the \f3java\&.security\fR package supplies a number of well-defined interfaces to access and modify the information in a keystore\&. You can have multiple different concrete implementations, where each implementation is for a particular type of keystore\&. 143 .PP 144 Currently, there are two command-line tools that use keystore implementations (\f3keytool\fR and \f3jarsigner\fR), and a GUI-based tool named Policy Tool\&. Because the \f3KeyStore\fR class is publicly available, JDK users can write additional security applications that use it\&. 145 .PP 146 There is a built-in default implementation provided by Oracle that implements the keystore as a file, that uses a proprietary keystore type (format) named JKS\&. The built-in implementation protects each private key with its individual password and protects the integrity of the entire keystore with a (possibly different) password\&. 147 .PP 148 Keystore implementations are provider-based, which means the application interfaces supplied by the \f3KeyStore\fR class are implemented in terms of a Service Provider Interface (SPI)\&. There is a corresponding abstract \f3KeystoreSpi\fR class, also in the \f3java\&.security package\fR, that 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\&. To provide a keystore implementation, clients must implement a provider and supply a \f3KeystoreSpi\fR subclass implementation, as described in How to Implement a Provider in the Java Cryptography Architecture at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/security/crypto/HowToImplAProvider\&.html 149 .PP 150 Applications can choose different types of keystore implementations from different providers, with the \f3getInstance\fR factory method in the \f3KeyStore\fR 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\&. 151 .PP 152 The \f3jarsigner\fR command can read file-based keystores from any location that can be specified using a URL\&. In addition, the command can read non-file-based keystores such as those provided by MSCAPI on Windows and PKCS11 on all platforms\&. 153 .PP 154 For the \f3jarsigner\fR and \f3keytool\fR commands, you can specify a keystore type at the command line with the \f3-storetype\fR option\&. For Policy Tool, you can specify a keystore type with the \fIEdit\fR command in the \fIKeyStore\fR menu\&. 155 .PP 156 If you do not explicitly specify a keystore type, then the tools choose a keystore implementation based on the value of the \f3keystore\&.type\fR property specified in the security properties file\&. The security properties file is called \f3java\&.security\fR, and it resides in the JDK security properties directory, \f3java\&.home/lib/security\fR, where \f3java\&.home\fR is the runtime environment\&'s directory\&. The \f3jre\fR directory in the JDK or the top-level directory of the Java Runtime Environment (JRE)\&. 157 .PP 158 Each tool gets the \f3keystore\&.type\fR value and then examines all the installed providers until it finds one that implements keystores of that type\&. It then uses the keystore implementation from that provider\&. 159 .PP 160 The \f3KeyStore\fR class defines a static method named \f3getDefaultType\fR that lets applications and applets retrieve the value of the \f3keystore\&.type\fR property\&. The following line of code creates an instance of the default keystore type as specified in the \f3keystore\&.type property\fR: 161 .sp 162 .nf 163 \f3KeyStore keyStore = KeyStore\&.getInstance(KeyStore\&.getDefaultType());\fP 164 .fi 165 .nf 166 \f3\fR 167 .fi 168 .sp 169 The default keystore type is \f3jks\fR (the proprietary type of the keystore implementation provided by Oracle)\&. This is specified by the following line in the security properties file: 170 .sp 171 .nf 172 \f3keystore\&.type=jks\fP 173 .fi 174 .nf 175 \f3\fR 176 .fi 177 .sp 178 Case does not matter in keystore type designations\&. For example, \f3JKS\fR is the same as \f3jks\fR\&. 179 .PP 180 To have the tools use 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 \f3pkcs12\fR, then change the line to the following: 181 .sp 182 .nf 183 \f3keystore\&.type=pkcs12\fP 184 .fi 185 .nf 186 \f3\fR 187 .fi 188 .sp 189 \fINote:\fR If you use the PKCS 11 provider package, then see "KeyTool" and "JarSigner" in Java PKCS #11 Reference Guide at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/security/p11guide\&.html 190 .SS SUPPORTED\ ALGORITHMS 191 By default, the \f3jarsigner\fR command signs a JAR file using one of the following algorithms: 192 .TP 0.2i 193 \(bu 194 Digital Signature Algorithm (DSA) with the SHA1 digest algorithm 195 .TP 0.2i 196 \(bu 197 RSA algorithm with the SHA256 digest algorithm 198 .TP 0.2i 199 \(bu 200 Elliptic Curve (EC) cryptography algorithm with the SHA256 with Elliptic Curve Digital Signature Algorithm (ECDSA)\&. 201 .PP 202 If the signer\&'s public and private keys are DSA keys, then \f3jarsigner\fR signs the JAR file with the \f3SHA1withDSA\fR algorithm\&. If the signer\&'s keys are RSA keys, then \f3jarsigner\fR attempts to sign the JAR file with the \f3SHA256withRSA\fR algorithm\&. If the signer\&'s keys are EC keys, then \f3jarsigner\fR signs the JAR file with the \f3SHA256withECDSA\fR algorithm\&. 203 .PP 204 These default signature algorithms can be overridden using the \f3-sigalg\fR option\&. 205 .SS THE\ SIGNED\ JAR\ FILE 206 When the \f3jarsigner\fR command 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: 207 .TP 0.2i 208 \(bu 209 A signature file with an \f3\&.SF\fR extension 210 .TP 0.2i 211 \(bu 212 A signature block file with a \f3\&.DSA\fR, \f3\&.RSA\fR, or \f3\&.EC\fR extension 213 .PP 214 The base file names for these two files come from the value of the \f3-sigFile\fR option\&. For example, when the option is \f3-sigFile MKSIGN\fR, the files are named \f3MKSIGN\&.SF\fR and \f3MKSIGN\&.DSA\fR 215 .PP 216 If no \f3-sigfile\fR option appears on the command line, then the base file name for the \f3\&.SF\fR and \f3\&.DSA\fR files is the first 8 characters of the alias name specified on the command line, all converted to uppercase\&. If the alias name has fewer than 8 characters, then the full alias name is used\&. If the alias name contains any characters that are not allowed in a signature file name, then each such character is converted to an underscore (_) character in forming the file name\&. Valid characters include letters, digits, underscores, and hyphens\&. 217 .PP 218 Signature File 219 220 A signature file (\f3\&.SF\fR file) looks similar to the manifest file that is always included in a JAR file when the \f3jarsigner\fR command is used to sign the file\&. For each source file included in the JAR file, the \f3\&.SF\fR file has three lines, such as in the manifest file, that list the following: 221 .TP 0.2i 222 \(bu 223 File name 224 .TP 0.2i 225 \(bu 226 Name of the digest algorithm (SHA) 227 .TP 0.2i 228 \(bu 229 SHA digest value 230 .PP 231 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 \f3\&.SF\fR file, the digest value for a specified source file is the hash of the three lines in the manifest file for the source file\&. 232 .PP 233 The signature file, by default, includes a header with a hash of the whole manifest file\&. The header also contains a hash of the manifest header\&. The presence of the header enables verification optimization\&. See JAR File Verification\&. 234 .PP 235 Signature Block File 236 237 The \f3\&.SF\fR 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 that authenticates the public key corresponding to the private key used for signing\&. The file has the extension \f3\&.DSA\fR, \f3\&.RSA\fR, or \f3\&.EC\fR, depending on the digest algorithm used\&. 238 .SS SIGNATURE\ TIME\ STAMP 239 The \f3jarsigner\fR command can generate and store a signature time stamp when signing a JAR file\&. In addition, \f3jarsigner\fR supports alternative signing mechanisms\&. This behavior is optional and is controlled by the user at the time of signing through these options\&. See Options\&. 240 .sp 241 .nf 242 \f3\-tsa \fIurl\fR\fP 243 .fi 244 .nf 245 \f3\-tsacert \fIalias\fR\fP 246 .fi 247 .nf 248 \f3\-altsigner \fIclass\fR\fP 249 .fi 250 .nf 251 \f3\-altsignerpath \fIclasspathlist\fR\fP 252 .fi 253 .nf 254 \f3\-tsapolicyid \fIpolicyid\fR\fP 255 .fi 256 .nf 257 \f3\fR 258 .fi 259 .sp 260 .SS JAR\ FILE\ VERIFICATION 261 A successful JAR file verification occurs when the signatures are valid, and none of the files that were in the JAR file when the signatures were generated have changed since then\&. JAR file verification involves the following steps: 262 .TP 0.4i 263 1\&. 264 Verify the signature of the \f3\&.SF\fR file\&. 265 266 The verification ensures that the signature stored in each signature block (\f3\&.DSA\fR) file was generated using the private key corresponding to the public key whose certificate (or certificate chain) also appears in the \f3\&.DSA\fR file\&. It also ensures that the signature is a valid signature of the corresponding signature (\f3\&.SF\fR) file, and thus the \f3\&.SF\fR file was not tampered with\&. 267 .TP 0.4i 268 2\&. 269 Verify the digest listed in each entry in the \f3\&.SF\fR file with each corresponding section in the manifest\&. 270 271 The \f3\&.SF\fR file by default includes a header that contains a hash of the entire manifest file\&. When the header is present, the verification can check to see whether or not the hash in the header matches the hash of the manifest file\&. If there is a match, then verification proceeds to the next step\&. 272 273 If there is no match, then a less optimized verification is required to ensure that the hash in each source file information section in the \f3\&.SF\fR file equals the hash of its corresponding section in the manifest file\&. See Signature File\&. 274 275 One reason the hash of the manifest file that is stored in the \f3\&.SF\fR file header might not equal the hash of the current manifest file is that one or more files were added to the JAR file (with the \f3jar\fR tool) after the signature and \f3\&.SF\fR file were generated\&. When the \f3jar\fR tool is used to add files, the manifest file is changed by adding sections to it for the new files, but the \f3\&.SF\fR file is not changed\&. A verification is still considered successful when none of the files that were in the JAR file when the signature was generated have been changed since then\&. This happens when the hashes in the non-header sections of the \f3\&.SF\fR file equal the hashes of the corresponding sections in the manifest file\&. 276 .TP 0.4i 277 3\&. 278 Read each file in the JAR file that has an entry in the \f3\&.SF\fR file\&. While reading, compute the file\&'s digest and compare the result with the digest for this file in the manifest section\&. The digests should be the same or verification fails\&. 279 280 If any serious verification failures occur during the verification process, then the process is stopped and a security exception is thrown\&. The \f3jarsigner\fR command catches and displays the exception\&. 281 .PP 282 \fINote:\fR You should read any addition warnings (or errors if you specified the \f3-strict\fR option), as well as the content of the certificate (by specifying the \f3-verbose\fR and \f3-certs\fR options) to determine if the signature can be trusted\&. 283 .SS MULTIPLE\ SIGNATURES\ FOR\ A\ JAR\ FILE 284 A JAR file can be signed by multiple people by running the \f3jarsigner\fR command on the file multiple times and specifying the alias for a different person each time, as follows: 285 .sp 286 .nf 287 \f3jarsigner myBundle\&.jar susan\fP 288 .fi 289 .nf 290 \f3jarsigner myBundle\&.jar kevin\fP 291 .fi 292 .nf 293 \f3\fR 294 .fi 295 .sp 296 When a JAR file is signed multiple times, there are multiple \f3\&.SF\fR and \f3\&.DSA\fR files in the resulting JAR file, one pair for each signature\&. In the previous example, the output JAR file includes files with the following names: 297 .sp 298 .nf 299 \f3SUSAN\&.SF\fP 300 .fi 301 .nf 302 \f3SUSAN\&.DSA\fP 303 .fi 304 .nf 305 \f3KEVIN\&.SF\fP 306 .fi 307 .nf 308 \f3KEVIN\&.DSA\fP 309 .fi 310 .sp 311 .SH OPTIONS 312 The following sections describe the various \f3jarsigner\fR options\&. Be aware of the following standards: 313 .TP 0.2i 314 \(bu 315 All option names are preceded by a minus sign (-)\&. 316 .TP 0.2i 317 \(bu 318 The options can be provided in any order\&. 319 .TP 0.2i 320 \(bu 321 Items that are in italics or underlined (option values) represent the actual values that must be supplied\&. 322 .TP 0.2i 323 \(bu 324 The \f3-storepass\fR, \f3-keypass\fR, \f3-sigfile\fR, \f3-sigalg\fR, \f3-digestalg\fR, \f3-signedjar\fR, and TSA-related options are only relevant when signing a JAR file; they are not relevant when verifying a signed JAR file\&. The \f3-keystore\fR option is relevant for signing and verifying a JAR file\&. In addition, aliases are specified when signing and verifying a JAR file\&. 325 .TP 326 -keystore \fIurl\fR 327 .br 328 Specifies the URL that tells the keystore location\&. This defaults to the file \f3\&.keystore\fR in the user\&'s home directory, as determined by the \f3user\&.home\fR system property\&. 329 330 A keystore is required when signing\&. You must explicitly specify a keystore when the default keystore does not exist or if you want to use one other than the default\&. 331 332 A keystore is not required when verifying, but if one is specified or the default exists and the \f3-verbose\fR option was also specified, then additional information is output regarding whether or not any of the certificates used to verify the JAR file are contained in that keystore\&. 333 334 The \f3-keystore\fR argument can be a file name and path specification rather than a URL, in which case it is treated the same as a file: URL, for example, the following are equivalent: 335 .sp 336 .nf 337 \f3\-keystore \fIfilePathAndName\fR\fP 338 .fi 339 .nf 340 \f3\-keystore file:\fIfilePathAndName\fR\fP 341 .fi 342 .nf 343 \f3\fR 344 .fi 345 .sp 346 347 348 If the Sun PKCS #11 provider was configured in the \f3java\&.security\fR security properties file (located in the JRE\&'s \f3$JAVA_HOME/lib/security directory\fR), then the \f3keytool\fR and \f3jarsigner\fR tools can operate on the PKCS #11 token by specifying these options: 349 .sp 350 .nf 351 \f3\-keystore NONE\fP 352 .fi 353 .nf 354 \f3\-storetype PKCS11\fP 355 .fi 356 .nf 357 \f3\fR 358 .fi 359 .sp 360 361 362 For example, the following command lists the contents of the configured PKCS#11 token: 363 .sp 364 .nf 365 \f3keytool \-keystore NONE \-storetype PKCS11 \-list\fP 366 .fi 367 .nf 368 \f3\fR 369 .fi 370 .sp 371 372 .TP 373 -storetype \fIstoretype\fR 374 .br 375 Specifies the type of keystore to be instantiated\&. The default keystore type is the one that is specified as the value of the \f3keystore\&.type\fR property in the security properties file, which is returned by the static \f3getDefaultType\fR method in \f3java\&.security\&.KeyStore\fR\&. 376 377 The PIN for a PCKS #11 token can also be specified with the \f3-storepass\fR option\&. If none is specified, then the \f3keytool\fR and \f3jarsigner\fR commands 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 \f3-protected\fR option must be specified and no password options can be specified\&. 378 .TP 379 -storepass[:env | :file] \fIargument\fR 380 .br 381 Specifies the password that is required to access the keystore\&. This is only needed when signing (not verifying) a JAR file\&. In that case, if a \f3-storepass\fR option is not provided at the command line, then the user is prompted for the password\&. 382 383 If the modifier \f3env\fR or \f3file\fR is not specified, then the password has the value \fIargument\fR\&. Otherwise, the password is retrieved as follows: 384 .RS 385 .TP 0.2i 386 \(bu 387 \f3env\fR: Retrieve the password from the environment variable named \f3argument\fR\&. 388 .TP 0.2i 389 \(bu 390 \f3file\fR: Retrieve the password from the file named \f3argument\fR\&. 391 .RE 392 393 394 \fINote:\fR The password should not be specified on the command line or in a script unless it is for testing purposes, or you are on a secure system\&. 395 .TP 396 -keypass [:env | :file] \fIargument\fR 397 .br 398 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\fR to sign a JAR file\&. If no password is provided on the command line, and the required password is different from the store password, then the user is prompted for it\&. 399 400 If the modifier \f3env\fR or \f3file\fR is not specified, then the password has the value \f3argument\fR\&. Otherwise, the password is retrieved as follows: 401 .RS 402 .TP 0.2i 403 \(bu 404 \f3env\fR: Retrieve the password from the environment variable named \f3argument\fR\&. 405 .TP 0.2i 406 \(bu 407 \f3file\fR: Retrieve the password from the file named \f3argument\fR\&. 408 .RE 409 410 411 \fINote:\fR The password should not be specified on the command line or in a script unless it is for testing purposes, or you are on a secure system\&. 412 .TP 413 -sigfile \fIfile\fR 414 .br 415 Specifies the base file name to be used for the generated \f3\&.SF\fR and \f3\&.DSA\fR files\&. For example, if file is \f3DUKESIGN\fR, then the generated \f3\&.SF\fR and \f3\&.DSA\fR files are named \f3DUKESIGN\&.SF\fR and \f3DUKESIGN\&.DSA\fR, and placed in the \f3META-INF\fR directory of the signed JAR file\&. 416 417 The characters in the file must come from the set \f3a-zA-Z0-9_-\fR\&. Only letters, numbers, underscore, and hyphen characters are allowed\&. All lowercase characters are converted to uppercase for the \f3\&.SF\fR and \f3\&.DSA\fR file names\&. 418 419 If no \f3-sigfile\fR option appears on the command line, then the base file name for the \f3\&.SF\fR and \f3\&.DSA\fR files is 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, then the full alias name is used\&. If the alias name contains any characters that are not valid in a signature file name, then each such character is converted to an underscore (_) character to form the file name\&. 420 .TP 421 -sigalg \fIalgorithm\fR 422 .br 423 Specifies the name of the signature algorithm to use to sign the JAR file\&. 424 425 For a list of standard signature algorithm names, see "Appendix A: Standard Names" in the Java Cryptography Architecture (JCA) Reference Guide at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec\&.html#AppA 426 427 This algorithm must be compatible with the private key used to sign the JAR file\&. If this option is not specified, then \f3SHA1withDSA\fR, \f3SHA256withRSA\fR, or \f3SHA256withECDSA\fR are 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 \f3-providerClass\fR option; otherwise, the command will not succeed\&. 428 .TP 429 -digestalg \fIalgorithm\fR 430 .br 431 Specifies the name of the message digest algorithm to use when digesting the entries of a JAR file\&. 432 433 For a list of standard message digest algorithm names, see "Appendix A: Standard Names" in the Java Cryptography Architecture (JCA) Reference Guide at http://docs\&.oracle\&.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec\&.html#AppA 434 435 If this option is not specified, then \f3SHA256\fR is used\&. There must either be a statically installed provider supplying an implementation of the specified algorithm or the user must specify one with the \f3-providerClass\fR option; otherwise, the command will not succeed\&. 436 .TP 437 -certs 438 .br 439 If the \f3-certs\fR option appears on the command line with the \f3-verify\fR and \f3-verbose\fR options, then the output includes certificate information for each signer of the JAR file\&. This information includes the name of the type of certificate (stored in the \f3\&.DSA\fR file) that certifies the signer\&'s public key, and if the certificate is an X\&.509 certificate (an instance of the \f3java\&.security\&.cert\&.X509Certificate\fR), then the distinguished name of the signer\&. 440 441 The keystore is also examined\&. If no keystore value is specified on the command line, then the default keystore file (if any) is checked\&. If the public key certificate for a signer matches an entry in the keystore, then the alias name for the keystore entry for that signer is displayed in parentheses\&. 442 .TP 443 -certchain \fIfile\fR 444 .br 445 Specifies the certificate chain to be used when the certificate chain associated with the private key of the keystore entry that is addressed by the alias specified on the command line is not complete\&. This can happen when 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 concatenated X\&.509 certificates, 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\&. See Internet RFC 1421 Certificate Encoding Standard and http://tools\&.ietf\&.org/html/rfc1421\&. 446 .TP 447 -verbose 448 .br 449 When the \f3-verbose\fR option appears on the command line, it indicates verbose mode, which causes \f3jarsigner\fR to output extra information about the progress of the JAR signing or verification\&. 450 .TP 451 -internalsf 452 .br 453 In the past, the \f3\&.DSA\fR (signature block) file generated when a JAR file was signed included a complete encoded copy of the \f3\&.SF\fR file (signature file) also generated\&. This behavior has been changed\&. To reduce the overall size of the output JAR file, the \f3\&.DSA\fR file by default does not contain a copy of the \f3\&.SF\fR file anymore\&. If \f3-internalsf\fR appears on the command line, then the old behavior is utilized\&. This option is useful for testing\&. In practice, do not use the \f3-internalsf\fR option because it incurs higher overhead\&. 454 .TP 455 -sectionsonly 456 .br 457 If the \f3-sectionsonly\fR option appears on the command line, then the \f3\&.SF\fR file (signature file) generated when a JAR file is signed does not include a header that contains a hash of the whole manifest file\&. It contains only the information and hashes related to each individual source file included in the JAR file\&. See Signature File\&. 458 459 By default, this header is added, as an optimization\&. When the header is present, whenever the JAR file is verified, the verification can first check to see whether the hash in the header matches the hash of the whole manifest file\&. When there is a match, verification proceeds to the next step\&. When there is no match, it is necessary to do a less optimized verification that the hash in each source file information section in the \f3\&.SF\fR file equals the hash of its corresponding section in the manifest file\&. See JAR File Verification\&. 460 461 The \f3-sectionsonly\fR option is primarily used for testing\&. It should not be used other than for testing because using it incurs higher overhead\&. 462 .TP 463 -protected 464 .br 465 Values can be either \f3true\fR or \f3false\fR\&. Specify \f3true\fR when a password must be specified through a protected authentication path such as a dedicated PIN reader\&. 466 .TP 467 -providerClass \fIprovider-class-name\fR 468 .br 469 Used to specify the name of cryptographic service provider\&'s master class file when the service provider is not listed in the \f3java\&.security\fR security properties file\&. 470 471 Used with the \f3-providerArg ConfigFilePath\fR option, the \f3keytool\fR and \f3jarsigner\fR tools install the provider dynamically and use \fIConfigFilePath\fR for the path to the token configuration file\&. The following example shows a command to list a \f3PKCS #11\fR keystore when the Oracle PKCS #11 provider was not configured in the security properties file\&. 472 .sp 473 .nf 474 \f3jarsigner \-keystore NONE \-storetype PKCS11 \e\fP 475 .fi 476 .nf 477 \f3 \-providerClass sun\&.security\&.pkcs11\&.SunPKCS11 \e\fP 478 .fi 479 .nf 480 \f3 \-providerArg /mydir1/mydir2/token\&.config \e\fP 481 .fi 482 .nf 483 \f3 \-list\fP 484 .fi 485 .nf 486 \f3\fR 487 .fi 488 .sp 489 490 .TP 491 -providerName \fIproviderName\fR 492 .br 493 If more than one provider was configured in the \f3java\&.security\fR security properties file, then you can use the \f3-providerName\fR option to target a specific provider instance\&. The argument to this option is the name of the provider\&. 494 495 For the Oracle PKCS #11 provider, \fIproviderName\fR is of the form \f3SunPKCS11-\fR\fITokenName\fR, where \fITokenName\fR is the name suffix that the provider instance has been configured with, as detailed in the configuration attributes table\&. For example, the following command lists the contents of the \f3PKCS #11\fR keystore provider instance with name suffix \f3SmartCard\fR: 496 .sp 497 .nf 498 \f3jarsigner \-keystore NONE \-storetype PKCS11 \e\fP 499 .fi 500 .nf 501 \f3 \-providerName SunPKCS11\-SmartCard \e\fP 502 .fi 503 .nf 504 \f3 \-list\fP 505 .fi 506 .nf 507 \f3\fR 508 .fi 509 .sp 510 511 .TP 512 -J\fIjavaoption\fR 513 .br 514 Passes through the specified \fIjavaoption\fR string directly to the Java interpreter\&. The \f3jarsigner\fR command is 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 \f3java -h\fR or \f3java -X\fR at the command line\&. 515 .TP 516 -tsa \fIurl\fR 517 .br 518 If \f3-tsa http://example\&.tsa\&.url\fR appears on the command line when signing a JAR file then a time stamp is generated for the signature\&. The URL, \f3http://example\&.tsa\&.url\fR, identifies the location of the Time Stamping Authority (TSA) and overrides any URL found with the \f3-tsacert\fR option\&. The \f3-tsa\fR option does not require the TSA public key certificate to be present in the keystore\&. 519 520 To generate the time stamp, \f3jarsigner\fR communicates with the TSA with the Time-Stamp Protocol (TSP) defined in RFC 3161\&. When successful, the time stamp token returned by the TSA is stored with the signature in the signature block file\&. 521 .TP 522 -tsacert \fIalias\fR 523 .br 524 When \f3-tsacert alias\fR appears on the command line when signing a JAR file, a time stamp is generated for the signature\&. The alias identifies the TSA public key certificate in the keystore that is in effect\&. The entry\&'s certificate is examined for a Subject Information Access extension that contains a URL identifying the location of the TSA\&. 525 526 The TSA public key certificate must be present in the keystore when using the \f3-tsacert\fR option\&. 527 .TP 528 -tsapolicyid \fIpolicyid\fR 529 .br 530 Specifies the object identifier (OID) that identifies the policy ID to be sent to the TSA server\&. If this option is not specified, no policy ID is sent and the TSA server will choose a default policy ID\&. 531 532 Object identifiers are defined by X\&.696, which is an ITU Telecommunication Standardization Sector (ITU-T) standard\&. These identifiers are typically period-separated sets of non-negative digits like \f31\&.2\&.3\&.4\fR, for example\&. 533 .TP 534 -altsigner \fIclass\fR 535 .br 536 This option specifies an alternative signing mechanism\&. The fully qualified class name identifies a class file that extends the \f3com\&.sun\&.jarsigner\&.ContentSigner\fR abstract class\&. The path to this class file is defined by the \f3-altsignerpath\fR option\&. If the \f3-altsigner\fR option is used, then the \f3jarsigner\fR command uses the signing mechanism provided by the specified class\&. Otherwise, the \f3jarsigner\fR command uses its default signing mechanism\&. 537 538 For example, to use the signing mechanism provided by a class named \f3com\&.sun\&.sun\&.jarsigner\&.AuthSigner\fR, use the jarsigner option \f3-altsigner com\&.sun\&.jarsigner\&.AuthSigner\fR\&. 539 .TP 540 -altsignerpath \fIclasspathlist\fR 541 .br 542 Specifies the path to the class file and any JAR file it depends on\&. The class file name is specified with the \f3-altsigner\fR option\&. If the class file is in a JAR file, then this option specifies the path to that JAR file\&. 543 544 An absolute path or a path relative to the current directory can be specified\&. If \fIclasspathlist\fR contains multiple paths or JAR files, then they should be separated with a colon (:) on Oracle Solaris and a semicolon (;) on Windows\&. This option is not necessary when the class is already in the search path\&. 545 546 The following example shows how to specify the path to a JAR file that contains the class file\&. The JAR file name is included\&. 547 .sp 548 .nf 549 \f3\-altsignerpath /home/user/lib/authsigner\&.jar\fP 550 .fi 551 .nf 552 \f3\fR 553 .fi 554 .sp 555 556 557 The following example shows how to specify the path to the JAR file that contains the class file\&. The JAR file name is omitted\&. 558 .sp 559 .nf 560 \f3\-altsignerpath /home/user/classes/com/sun/tools/jarsigner/\fP 561 .fi 562 .nf 563 \f3\fR 564 .fi 565 .sp 566 567 .TP 568 -strict 569 .br 570 During the signing or verifying process, the command may issue warning messages\&. If you specify this option, the exit code of the tool reflects the severe warning messages that this command found\&. See Errors and Warnings\&. 571 .TP 572 -verbose \fIsuboptions\fR 573 .br 574 For the verifying process, the \f3-verbose\fR option takes suboptions to determine how much information is shown\&. If the \f3-certs\fR option is also specified, then the default mode (or suboption \f3all\fR) displays each entry as it is being processed, and after that, the certificate information for each signer of the JAR file\&. If the \f3-certs\fR and the \f3-verbose:grouped\fR suboptions are specified, then entries with the same signer info are grouped and displayed together with their certificate information\&. If \f3-certs\fR and the \f3-verbose:summary\fR suboptions are specified, then entries with the same signer information are grouped and displayed together with their certificate information\&. Details about each entry are summarized and displayed as \fIone entry (and more)\fR\&. See Examples\&. 575 .SH ERRORS\ AND\ WARNINGS 576 During the signing or verifying process, the \f3jarsigner\fR command may issue various errors or warnings\&. 577 .PP 578 If there is a failure, the \f3jarsigner\fR command exits with code 1\&. If there is no failure, but there are one or more severe warnings, the \f3jarsigner\fR command exits with code 0 when the \f3-strict\fR option is \fInot\fR specified, or exits with the OR-value of the warning codes when the \f3-strict\fR is specified\&. If there is only informational warnings or no warning at all, the command always exits with code 0\&. 579 .PP 580 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, the \f3jarsigner\fR command exits with code 12 (=4+8) when the \f3-strict\fR option is specified\&. 581 .PP 582 \fINote:\fR Exit codes are reused because only the values from 0 to 255 are legal on Unix-based operating systems\&. 583 .PP 584 The following sections describes the names, codes, and descriptions of the errors and warnings that the \f3jarsigner\fR command can issue\&. 585 .SS FAILURE 586 Reasons why the \f3jarsigner\fR command fails include (but are not limited to) a command line parsing error, the inability to find a keypair to sign the JAR file, or the verification of a signed JAR fails\&. 587 .TP 588 failure 589 Code 1\&. The signing or verifying fails\&. 590 .SS SEVERE\ WARNINGS 591 \fINote:\fR Severe warnings are reported as errors if you specify the \f3-strict\fR option\&. 592 .PP 593 Reasons why the \f3jarsigner\fR command issues a severe warning include the certificate used to sign the JAR file has an error or the signed JAR file has other problems\&. 594 .TP 595 hasExpiredCert 596 Code 4\&. This jar contains entries whose signer certificate has expired\&. 597 .TP 598 notYetValidCert 599 Code 4\&. This jar contains entries whose signer certificate is not yet valid\&. 600 .TP 601 chainNotValidated 602 Code 4\&. This jar contains entries whose certificate chain cannot be correctly validated\&. 603 .TP 604 badKeyUsage 605 Code 8\&. This jar contains entries whose signer certificate\&'s KeyUsage extension doesn\&'t allow code signing\&. 606 .TP 607 badExtendedKeyUsage 608 Code 8\&. This jar contains entries whose signer certificate\&'s ExtendedKeyUsage extension doesn\&'t allow code signing\&. 609 .TP 610 badNetscapeCertType 611 Code 8\&. This jar contains entries whose signer certificate\&'s NetscapeCertType extension doesn\&'t allow code signing\&. 612 .TP 613 hasUnsignedEntry 614 Code 16\&. This jar contains unsigned entries which have not been integrity-checked\&. 615 .TP 616 notSignedByAlias 617 Code 32\&. This jar contains signed entries which are not signed by the specified alias(es)\&. 618 .TP 619 aliasNotInStore 620 Code 32\&. This jar contains signed entries that are not signed by alias in this keystore\&. 621 .SS INFORMATIONAL\ WARNINGS 622 Informational warnings include those that are not errors but regarded as bad practice\&. They do not have a code\&. 623 .TP 624 hasExpiringCert 625 This jar contains entries whose signer certificate will expire within six months\&. 626 .TP 627 noTimestamp 628 This jar contains signatures that does not include a timestamp\&. Without a timestamp, users may not be able to validate this JAR file after the signer certificate\&'s expiration date (\f3YYYY-MM-DD\fR) or after any future revocation date\&. 629 .SH EXAMPLES 630 .SS SIGN\ A\ JAR\ FILE 631 Use the following command to sign bundle\&.jar with the private key of a user whose keystore alias is \f3jane\fR in a keystore named \f3mystore\fR in the \f3working\fR directory and name the signed JAR file \f3sbundle\&.jar\fR: 632 .sp 633 .nf 634 \f3jarsigner \-keystore /working/mystore\fP 635 .fi 636 .nf 637 \f3 \-storepass <keystore password>\fP 638 .fi 639 .nf 640 \f3 \-keypass <private key password>\fP 641 .fi 642 .nf 643 \f3 \-signedjar sbundle\&.jar bundle\&.jar jane\fP 644 .fi 645 .nf 646 \f3\fR 647 .fi 648 .sp 649 There is no \f3-sigfile\fR specified in the previous command so the generated \f3\&.SF\fR and \f3\&.DSA\fR files to be placed in the signed JAR file have default names based on the alias name\&. They are named \f3JANE\&.SF\fR and \f3JANE\&.DSA\fR\&. 650 .PP 651 If you want to be prompted for the store password and the private key password, then you could shorten the previous command to the following: 652 .sp 653 .nf 654 \f3jarsigner \-keystore /working/mystore\fP 655 .fi 656 .nf 657 \f3 \-signedjar sbundle\&.jar bundle\&.jar jane\fP 658 .fi 659 .nf 660 \f3\fR 661 .fi 662 .sp 663 If the keystore is the default keystore (\&.keystore in your home directory), then you do not need to specify a keystore, as follows: 664 .sp 665 .nf 666 \f3jarsigner \-signedjar sbundle\&.jar bundle\&.jar jane\fP 667 .fi 668 .nf 669 \f3\fR 670 .fi 671 .sp 672 If you want the signed JAR file to overwrite the input JAR file (bundle\&.jar), then you do not need to specify a \f3-signedjar\fR option, as follows: 673 .sp 674 .nf 675 \f3jarsigner bundle\&.jar jane\fP 676 .fi 677 .nf 678 \f3\fR 679 .fi 680 .sp 681 .SS VERIFY\ A\ SIGNED\ JAR\ FILE 682 To verify a signed JAR file to ensure that the signature is valid and the JAR file was not been tampered with, use a command such as the following: 683 .sp 684 .nf 685 \f3jarsigner \-verify sbundle\&.jar\fP 686 .fi 687 .nf 688 \f3\fR 689 .fi 690 .sp 691 When the verification is successful, \f3jar verified\fR is displayed\&. Otherwise, an error message is displayed\&. You can get more information when you use the \f3-verbose\fR option\&. A sample use of \f3jarsigner\fR with the\f3-verbose\fR option follows: 692 .sp 693 .nf 694 \f3jarsigner \-verify \-verbose sbundle\&.jar\fP 695 .fi 696 .nf 697 \f3\fR 698 .fi 699 .nf 700 \f3 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST\&.MF\fP 701 .fi 702 .nf 703 \f3 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE\&.SF\fP 704 .fi 705 .nf 706 \f3 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE\&.DSA\fP 707 .fi 708 .nf 709 \f3 smk 2752 Fri Sep 26 16:12:30 PDT 1997 AclEx\&.class\fP 710 .fi 711 .nf 712 \f3 smk 849 Fri Sep 26 16:12:46 PDT 1997 test\&.class\fP 713 .fi 714 .nf 715 \f3\fR 716 .fi 717 .nf 718 \f3 s = signature was verified\fP 719 .fi 720 .nf 721 \f3 m = entry is listed in manifest\fP 722 .fi 723 .nf 724 \f3 k = at least one certificate was found in keystore\fP 725 .fi 726 .nf 727 \f3\fR 728 .fi 729 .nf 730 \f3 jar verified\&.\fP 731 .fi 732 .nf 733 \f3\fR 734 .fi 735 .sp 736 .SS VERIFICATION\ WITH\ CERTIFICATE\ INFORMATION 737 If you specify the \f3-certs\fR option with the \f3-verify\fR and \f3-verbose\fR options, then the output includes certificate information for each signer of the JAR file\&. The information includes the certificate type, the signer distinguished name information (when it is an X\&.509 certificate), and in parentheses, the keystore alias for the signer when the public key certificate in the JAR file matches the one in a keystore entry, for example: 738 .sp 739 .nf 740 \f3jarsigner \-keystore /working/mystore \-verify \-verbose \-certs myTest\&.jar\fP 741 .fi 742 .nf 743 \f3\fR 744 .fi 745 .nf 746 \f3 198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST\&.MF\fP 747 .fi 748 .nf 749 \f3 199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE\&.SF\fP 750 .fi 751 .nf 752 \f3 1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE\&.DSA\fP 753 .fi 754 .nf 755 \f3 208 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST\&.SF\fP 756 .fi 757 .nf 758 \f3 1087 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST\&.DSA\fP 759 .fi 760 .nf 761 \f3 smk 2752 Fri Sep 26 16:12:30 PDT 1997 Tst\&.class\fP 762 .fi 763 .nf 764 \f3\fR 765 .fi 766 .nf 767 \f3 X\&.509, CN=Test Group, OU=Java Software, O=Oracle, L=CUP, S=CA, C=US (javatest)\fP 768 .fi 769 .nf 770 \f3 X\&.509, CN=Jane Smith, OU=Java Software, O=Oracle, L=cup, S=ca, C=us (jane)\fP 771 .fi 772 .nf 773 \f3\fR 774 .fi 775 .nf 776 \f3 s = signature was verified\fP 777 .fi 778 .nf 779 \f3 m = entry is listed in manifest\fP 780 .fi 781 .nf 782 \f3 k = at least one certificate was found in keystore\fP 783 .fi 784 .nf 785 \f3\fR 786 .fi 787 .nf 788 \f3 jar verified\&.\fP 789 .fi 790 .nf 791 \f3\fR 792 .fi 793 .sp 794 If the certificate for a signer is not an X\&.509 certificate, then 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 \f3bob\fR, then you would get: \f3PGP, (bob)\fR\&. 795 .SH SEE\ ALSO 796 .TP 0.2i 797 \(bu 798 jar(1) 799 .TP 0.2i 800 \(bu 801 keytool(1) 802 .TP 0.2i 803 \(bu 804 Trail: Security Features in Java SE at http://docs\&.oracle\&.com/javase/tutorial/security/index\&.html 805 .RE 806 .br 807 'pl 8.5i 808 'bp | 1 .\"t 2 .\" Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved. 3 .\" DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 .\" 5 .\" This code is free software; you can redistribute it and/or modify it 6 .\" under the terms of the GNU General Public License version 2 only, as 7 .\" published by the Free Software Foundation. 8 .\" 9 .\" This code is distributed in the hope that it will be useful, but WITHOUT 10 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 .\" version 2 for more details (a copy is included in the LICENSE file that 13 .\" accompanied this code). 14 .\" 15 .\" You should have received a copy of the GNU General Public License version 16 .\" 2 along with this work; if not, write to the Free Software Foundation, 17 .\" Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 .\" 19 .\" Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 .\" or visit www.oracle.com if you need additional information or have any 21 .\" questions. 22 .\" 23 .\" Automatically generated by Pandoc 2.3.1 24 .\" 25 .TH "JARSIGNER" "1" "2019" "JDK 13" "JDK Commands" 26 .hy 27 .SH NAME 28 .PP 29 jarsigner \- sign and verify Java Archive (JAR) files 30 .SH SYNOPSIS 31 .PP 32 \f[CB]jarsigner\f[R] [\f[I]options\f[R]] \f[I]jar\-file\f[R] \f[I]alias\f[R] 33 .PP 34 \f[CB]jarsigner\f[R] \f[CB]\-verify\f[R] [\f[I]options\f[R]] 35 \f[I]jar\-file\f[R] [\f[I]alias\f[R] ...] 36 .TP 37 .B \f[I]options\f[R] 38 The command\-line options. 39 See \f[B]Options for jarsigner\f[R]. 40 .RS 41 .RE 42 .TP 43 .B \f[CB]\-verify\f[R] 44 The \f[CB]\-verify\f[R] option can take zero or more keystore alias names 45 after the JAR file name. 46 When the \f[CB]\-verify\f[R] option is specified, the \f[CB]jarsigner\f[R] 47 command checks that the certificate used to verify each signed entry in 48 the JAR file matches one of the keystore aliases. 49 The aliases are defined in the keystore specified by \f[CB]\-keystore\f[R] 50 or the default keystore. 51 .RS 52 .PP 53 If you also specify the \f[CB]\-strict\f[R] option, and the 54 \f[CB]jarsigner\f[R] command detects severe warnings, the message, "jar 55 verified, with signer errors" is displayed. 56 .RE 57 .TP 58 .B \f[I]jar\-file\f[R] 59 The JAR file to be signed. 60 .RS 61 .PP 62 If you also specified the \f[CB]\-strict\f[R] option, and the 63 \f[CB]jarsigner\f[R] command detected severe warnings, the message, "jar 64 signed, with signer errors" is displayed. 65 .RE 66 .TP 67 .B \f[I]alias\f[R] 68 The aliases are defined in the keystore specified by \f[CB]\-keystore\f[R] 69 or the default keystore. 70 .RS 71 .RE 72 .SH DESCRIPTION 73 .PP 74 The \f[CB]jarsigner\f[R] tool has two purposes: 75 .IP \[bu] 2 76 To sign Java Archive (JAR) files. 77 .IP \[bu] 2 78 To verify the signatures and integrity of signed JAR files. 79 .PP 80 The JAR feature enables the packaging of class files, images, sounds, 81 and other digital data in a single file for faster and easier 82 distribution. 83 A tool named \f[CB]jar\f[R] enables developers to produce JAR files. 84 (Technically, any ZIP file can also be considered a JAR file, although 85 when created by the \f[CB]jar\f[R] command or processed by the 86 \f[CB]jarsigner\f[R] command, JAR files also contain a 87 \f[CB]META\-INF/MANIFEST.MF\f[R] file.) 88 .PP 89 A digital signature is a string of bits that is computed from some data 90 (the data being signed) and the private key of an entity (a person, 91 company, and so on). 92 Similar to a handwritten signature, a digital signature has many useful 93 characteristics: 94 .IP \[bu] 2 95 Its authenticity can be verified by a computation that uses the public 96 key corresponding to the private key used to generate the signature. 97 .IP \[bu] 2 98 It can\[aq]t be forged, assuming the private key is kept secret. 99 .IP \[bu] 2 100 It is a function of the data signed and thus can\[aq]t be claimed to be 101 the signature for other data as well. 102 .IP \[bu] 2 103 The signed data can\[aq]t be changed. 104 If the data is changed, then the signature can\[aq]t be verified as 105 authentic. 106 .PP 107 To generate an entity\[aq]s signature for a file, the entity must first 108 have a public/private key pair associated with it and one or more 109 certificates that authenticate its public key. 110 A certificate is a digitally signed statement from one entity that says 111 that the public key of another entity has a particular value. 112 .PP 113 The \f[CB]jarsigner\f[R] command uses key and certificate information from 114 a keystore to generate digital signatures for JAR files. 115 A keystore is a database of private keys and their associated X.509 116 certificate chains that authenticate the corresponding public keys. 117 The \f[CB]keytool\f[R] command is used to create and administer keystores. 118 .PP 119 The \f[CB]jarsigner\f[R] command uses an entity\[aq]s private key to 120 generate a signature. 121 The signed JAR file contains, among other things, a copy of the 122 certificate from the keystore for the public key corresponding to the 123 private key used to sign the file. 124 The \f[CB]jarsigner\f[R] command can verify the digital signature of the 125 signed JAR file using the certificate inside it (in its signature block 126 file). 127 .PP 128 The \f[CB]jarsigner\f[R] command can generate signatures that include a 129 time stamp that enables a systems or deployer to check whether the JAR 130 file was signed while the signing certificate was still valid. 131 .PP 132 In addition, APIs allow applications to obtain the timestamp 133 information. 134 .PP 135 At this time, the \f[CB]jarsigner\f[R] command can only sign JAR files 136 created by the \f[CB]jar\f[R] command or zip files. 137 JAR files are the same as zip files, except they also have a 138 \f[CB]META\-INF/MANIFEST.MF\f[R] file. 139 A \f[CB]META\-INF/MANIFEST.MF\f[R] file is created when the 140 \f[CB]jarsigner\f[R] command signs a zip file. 141 .PP 142 The default \f[CB]jarsigner\f[R] command behavior is to sign a JAR or zip 143 file. 144 Use the \f[CB]\-verify\f[R] option to verify a signed JAR file. 145 .PP 146 The \f[CB]jarsigner\f[R] command also attempts to validate the 147 signer\[aq]s certificate after signing or verifying. 148 If there is a validation error or any other problem, the command 149 generates warning messages. 150 If you specify the \f[CB]\-strict\f[R] option, then the command treats 151 severe warnings as errors. 152 See \f[B]Errors and Warnings\f[R]. 153 .SH KEYSTORE ALIASES 154 .PP 155 All keystore entities are accessed with unique aliases. 156 .PP 157 When you use the \f[CB]jarsigner\f[R] command to sign a JAR file, you must 158 specify the alias for the keystore entry that contains the private key 159 needed to generate the signature. 160 If no output file is specified, it overwrites the original JAR file with 161 the signed JAR file. 162 .PP 163 Keystores are protected with a password, so the store password must be 164 specified. 165 You are prompted for it when you don\[aq]t specify it on the command 166 line. 167 Similarly, private keys are protected in a keystore with a password, so 168 the private key\[aq]s password must be specified, and you are prompted 169 for the password when you don\[aq]t specify it on the command line and 170 it isn\[aq]t the same as the store password. 171 .SH KEYSTORE LOCATION 172 .PP 173 The \f[CB]jarsigner\f[R] command has a \f[CB]\-keystore\f[R] option for 174 specifying the URL of the keystore to be used. 175 The keystore is by default stored in a file named \f[CB]\&.keystore\f[R] 176 in the user\[aq]s home directory, as determined by the 177 \f[CB]user.home\f[R] system property. 178 .PP 179 \f[B]Oracle Solaris, Linux, and OS X:\f[R] \f[CB]user.home\f[R] defaults to 180 the user\[aq]s home directory. 181 .PP 182 The input stream from the \f[CB]\-keystore\f[R] option is passed to the 183 \f[CB]KeyStore.load\f[R] method. 184 If \f[CB]NONE\f[R] is specified as the URL, then a null stream is passed 185 to the \f[CB]KeyStore.load\f[R] method. 186 \f[CB]NONE\f[R] should be specified when the \f[CB]KeyStore\f[R] class 187 isn\[aq]t file based, for example, when it resides on a hardware token 188 device. 189 .SH KEYSTORE IMPLEMENTATION 190 .PP 191 The \f[CB]KeyStore\f[R] class provided in the \f[CB]java.security\f[R] 192 package supplies a number of well\-defined interfaces to access and 193 modify the information in a keystore. 194 You can have multiple different concrete implementations, where each 195 implementation is for a particular type of keystore. 196 .PP 197 Currently, there are two command\-line tools that use keystore 198 implementations (\f[CB]keytool\f[R] and \f[CB]jarsigner\f[R]). 199 .PP 200 The default keystore implementation is \f[CB]PKCS12\f[R]. 201 This is a cross platform keystore based on the RSA PKCS12 Personal 202 Information Exchange Syntax Standard. 203 This standard is primarily meant for storing or transporting a 204 user\[aq]s private keys, certificates, and miscellaneous secrets. 205 There is another built\-in implementation, provided by Oracle. 206 It implements the keystore as a file with a proprietary keystore type 207 (format) named \f[CB]JKS\f[R]. 208 It protects each private key with its individual password, and also 209 protects the integrity of the entire keystore with a (possibly 210 different) password. 211 .PP 212 Keystore implementations are provider\-based, which means the 213 application interfaces supplied by the \f[CB]KeyStore\f[R] class are 214 implemented in terms of a Service Provider Interface (SPI). 215 There is a corresponding abstract \f[CB]KeystoreSpi\f[R] class, also in 216 the \f[CB]java.security\ package\f[R], that defines the Service Provider 217 Interface methods that providers must implement. 218 The term provider refers to a package or a set of packages that supply a 219 concrete implementation of a subset of services that can be accessed by 220 the Java Security API. 221 To provide a keystore implementation, clients must implement a provider 222 and supply a \f[CB]KeystoreSpi\f[R] subclass implementation, as described 223 in \f[B]How to Implement a Provider in the Java Cryptography 224 Architecture\f[R] 225 [https://www.oracle.com/pls/topic/lookup?ctx=en/java/javase/11/tools&id=JSSEC\-GUID\-2BCFDD85\-D533\-4E6C\-8CE9\-29990DEB0190]. 226 .PP 227 Applications can choose different types of keystore implementations from 228 different providers, with the \f[CB]getInstance\f[R] factory method in the 229 \f[CB]KeyStore\f[R] class. 230 A keystore type defines the storage and data format of the keystore 231 information and the algorithms used to protect private keys in the 232 keystore and the integrity of the keystore itself. 233 Keystore implementations of different types aren\[aq]t compatible. 234 .PP 235 The \f[CB]jarsigner\f[R] commands can read file\-based keystores from any 236 location that can be specified using a URL. 237 In addition, these commands can read non\-file\-based keystores such as 238 those provided by MSCAPI on Windows and PKCS11 on all platforms. 239 .PP 240 For the \f[CB]jarsigner\f[R] and \f[CB]keytool\f[R] commands, you can 241 specify a keystore type at the command line with the 242 \f[CB]\-storetype\f[R] option. 243 .PP 244 If you don\[aq]t explicitly specify a keystore type, then the tools 245 choose a keystore implementation based on the value of the 246 \f[CB]keystore.type\f[R] property specified in the security properties 247 file. 248 The security properties file is called \f[CB]java.security\f[R], and it 249 resides in the JDK security properties directory, 250 \f[CB]java.home/conf/security\f[R]. 251 .PP 252 Each tool gets the \f[CB]keystore.type\f[R] value and then examines all 253 the installed providers until it finds one that implements keystores of 254 that type. 255 It then uses the keystore implementation from that provider. 256 .PP 257 The \f[CB]KeyStore\f[R] class defines a static method named 258 \f[CB]getDefaultType\f[R] that lets applications retrieve the value of the 259 \f[CB]keystore.type\f[R] property. 260 The following line of code creates an instance of the default keystore 261 type as specified in the \f[CB]keystore.type\f[R] property: 262 .RS 263 .PP 264 \f[CB]KeyStore\ keyStore\ =\ KeyStore.getInstance(KeyStore.getDefaultType());\f[R] 265 .RE 266 .PP 267 The default keystore type is \f[CB]pkcs12\f[R], which is a cross platform 268 keystore based on the RSA PKCS12 Personal Information Exchange Syntax 269 Standard. 270 This is specified by the following line in the security properties file: 271 .RS 272 .PP 273 \f[CB]keystore.type=pkcs12\f[R] 274 .RE 275 .PP 276 Case doesn\[aq]t matter in keystore type designations. 277 For example, \f[CB]JKS\f[R] is the same as \f[CB]jks\f[R]. 278 .PP 279 To have the tools utilize a keystore implementation other than the 280 default, you can change that line to specify a different keystore type. 281 For example, if you want to use the Oracle\[aq]s \f[CB]jks\f[R] keystore 282 implementation, then change the line to the following: 283 .RS 284 .PP 285 \f[CB]keystore.type=jks\f[R] 286 .RE 287 .SH SUPPORTED ALGORITHMS 288 .PP 289 By default, the \f[CB]jarsigner\f[R] command signs a JAR file using one of 290 the following algorithms files depending on the type and size of the 291 private key: 292 .PP 293 .TS 294 tab(@); 295 l l l. 296 T{ 297 keyalg 298 T}@T{ 299 keysize 300 T}@T{ 301 default sigalg 302 T} 303 _ 304 T{ 305 DSA 306 T}@T{ 307 any size 308 T}@T{ 309 SHA256withDSA 310 T} 311 T{ 312 RSA \ \ \ 313 T}@T{ 314 <= 3072 315 T}@T{ 316 SHA256withRSA 317 T} 318 T{ 319 T}@T{ 320 <= 7680 321 T}@T{ 322 SHA384withRSA 323 T} 324 T{ 325 T}@T{ 326 > 7680 327 T}@T{ 328 SHA512withRSA 329 T} 330 T{ 331 EC 332 T}@T{ 333 < 384 334 T}@T{ 335 SHA256withECDSA 336 T} 337 T{ 338 T}@T{ 339 < 512 340 T}@T{ 341 SHA384withECDSA 342 T} 343 T{ 344 T}@T{ 345 = 512 346 T}@T{ 347 SHA512withECDSA 348 T} 349 .TE 350 .PP 351 These default signature algorithms can be overridden by using the 352 \f[CB]\-sigalg\f[R] option. 353 .PP 354 Signed JAR file algorithms are checked against the 355 \f[CB]jdk.jar.disabledAlgorithms\f[R] security property during 356 verification (\f[CB]\-verify\f[R]). 357 If the JAR file was signed with any algorithms that are disabled, it 358 will be treated as an unsigned JAR file. 359 For detailed verification output, include 360 \f[CB]\-J\-Djava.security.debug=jar\f[R]. 361 The default value for the \f[CB]jdk.jar.disabledAlgorithms\f[R] security 362 property is defined in the \f[CB]java.security\f[R] file (located in the 363 JRE\[aq]s \f[CB]$JAVA_HOME/conf/security\f[R] directory). 364 .PP 365 \f[B]Note:\f[R] 366 .PP 367 In order to improve out of the box security, default key size and 368 signature algorithm names are periodically updated to stronger values 369 with each release of the JDK. 370 If interoperability with older releases of the JDK is important, please 371 make sure the defaults are supported by those releases, or alternatively 372 use the \f[CB]\-sigalg\f[R] option to override the default values at your 373 own risk. 374 .SH THE SIGNED JAR FILE 375 .PP 376 When the \f[CB]jarsigner\f[R] command is used to sign a JAR file, the 377 output signed JAR file is exactly the same as the input JAR file, except 378 that it has two additional files placed in the META\-INF directory: 379 .IP \[bu] 2 380 A signature file with an \f[CB]\&.SF\f[R] extension 381 .IP \[bu] 2 382 A signature block file with a \f[CB]\&.DSA\f[R], \f[CB]\&.RSA\f[R], or 383 \f[CB]\&.EC\f[R] extension 384 .PP 385 The base file names for these two files come from the value of the 386 \f[CB]\-sigfile\f[R] option. 387 For example, when the option is \f[CB]\-sigfile\ MKSIGN\f[R], the files 388 are named \f[CB]MKSIGN.SF\f[R] and \f[CB]MKSIGN.DSA\f[R] 389 .PP 390 If no \f[CB]\-sigfile\f[R] option appears on the command line, then the 391 base file name for the \f[CB]\&.SF\f[R] and \f[CB]\&.DSA\f[R] files is the 392 first 8 characters of the alias name specified on the command line, all 393 converted to uppercase. 394 If the alias name has fewer than 8 characters, then the full alias name 395 is used. 396 If the alias name contains any characters that aren\[aq]t allowed in a 397 signature file name, then each such character is converted to an 398 underscore (_) character in forming the file name. 399 Valid characters include letters, digits, underscores, and hyphens. 400 .SH SIGNATURE FILE 401 .PP 402 A signature file (\f[CB]\&.SF\f[R] file) looks similar to the manifest 403 file that is always included in a JAR file when the \f[CB]jarsigner\f[R] 404 command is used to sign the file. 405 For each source file included in the JAR file, the \f[CB]\&.SF\f[R] file 406 has two lines, such as in the manifest file, that list the following: 407 .IP \[bu] 2 408 File name 409 .IP \[bu] 2 410 Name of the digest algorithm (SHA) 411 .IP \[bu] 2 412 SHA digest value 413 .PP 414 \f[B]Note:\f[R] 415 .PP 416 The name of the digest algorithm (SHA) and the SHA digest value are on 417 the same line. 418 .PP 419 In the manifest file, the SHA digest value for each source file is the 420 digest (hash) of the binary data in the source file. 421 In the \f[CB]\&.SF\f[R] file, the digest value for a specified source file 422 is the hash of the two lines in the manifest file for the source file. 423 .PP 424 The signature file, by default, includes a header with a hash of the 425 whole manifest file. 426 The header also contains a hash of the manifest header. 427 The presence of the header enables verification optimization. 428 See \f[B]JAR File Verification\f[R]. 429 .SH SIGNATURE BLOCK FILE 430 .PP 431 The \f[CB]\&.SF\f[R] file is signed and the signature is placed in the 432 signature block file. 433 This file also contains, encoded inside it, the certificate or 434 certificate chain from the keystore that authenticates the public key 435 corresponding to the private key used for signing. 436 The file has the extension \f[CB]\&.DSA\f[R], \f[CB]\&.RSA\f[R], or 437 \f[CB]\&.EC\f[R], depending on the digest algorithm used. 438 .SH SIGNATURE TIME STAMP 439 .PP 440 The \f[CB]jarsigner\f[R] command used with the following options generates 441 and stores a signature time stamp when signing a JAR file: 442 .IP \[bu] 2 443 \f[CB]\-tsa\f[R] \f[I]url\f[R] 444 .IP \[bu] 2 445 \f[CB]\-tsacert\f[R] \f[I]alias\f[R] 446 .IP \[bu] 2 447 \f[CB]\-tsapolicyid\f[R] \f[I]policyid\f[R] 448 .IP \[bu] 2 449 \f[CB]\-tsadigestalg\f[R] \f[I]algorithm\f[R] 450 .PP 451 See \f[B]Options for jarsigner\f[R]. 452 .SH JAR FILE VERIFICATION 453 .PP 454 A successful JAR file verification occurs when the signatures are valid, 455 and none of the files that were in the JAR file when the signatures were 456 generated have changed since then. 457 JAR file verification involves the following steps: 458 .IP "1." 3 459 Verify the signature of the \f[CB]\&.SF\f[R] file. 460 .RS 4 461 .PP 462 The verification ensures that the signature stored in each signature 463 block (\f[CB]\&.DSA\f[R]) file was generated using the private key 464 corresponding to the public key whose certificate (or certificate chain) 465 also appears in the \f[CB]\&.DSA\f[R] file. 466 It also ensures that the signature is a valid signature of the 467 corresponding signature (\f[CB]\&.SF\f[R]) file, and thus the 468 \f[CB]\&.SF\f[R] file wasn\[aq]t tampered with. 469 .RE 470 .IP "2." 3 471 Verify the digest listed in each entry in the \f[CB]\&.SF\f[R] file with 472 each corresponding section in the manifest. 473 .RS 4 474 .PP 475 The \f[CB]\&.SF\f[R] file by default includes a header that contains a 476 hash of the entire manifest file. 477 When the header is present, the verification can check to see whether or 478 not the hash in the header matches the hash of the manifest file. 479 If there is a match, then verification proceeds to the next step. 480 .PP 481 If there is no match, then a less optimized verification is required to 482 ensure that the hash in each source file information section in the 483 \f[CB]\&.SF\f[R] file equals the hash of its corresponding section in the 484 manifest file. 485 See Signature File. 486 .PP 487 One reason the hash of the manifest file that is stored in the 488 \f[CB]\&.SF\f[R] file header might not equal the hash of the current 489 manifest file is that one or more files were added to the JAR file (with 490 the \f[CB]jar\f[R] tool) after the signature and \f[CB]\&.SF\f[R] file were 491 generated. 492 When the \f[CB]jar\f[R] tool is used to add files, the manifest file is 493 changed by adding sections to it for the new files, but the 494 \f[CB]\&.SF\f[R] file isn\[aq]t changed. 495 A verification is still considered successful when none of the files 496 that were in the JAR file when the signature was generated have been 497 changed since then. 498 This happens when the hashes in the non\-header sections of the 499 \f[CB]\&.SF\f[R] file equal the hashes of the corresponding sections in 500 the manifest file. 501 .RE 502 .IP "3." 3 503 Read each file in the JAR file that has an entry in the \f[CB]\&.SF\f[R] 504 file. 505 While reading, compute the file\[aq]s digest and compare the result with 506 the digest for this file in the manifest section. 507 The digests should be the same or verification fails. 508 .RS 4 509 .PP 510 If any serious verification failures occur during the verification 511 process, then the process is stopped and a security exception is thrown. 512 The \f[CB]jarsigner\f[R] command catches and displays the exception. 513 .RE 514 .IP "4." 3 515 Check for disabled algorithm usage. 516 See \f[B]Supported Algorithms\f[R]. 517 .PP 518 \f[B]Note:\f[R] 519 .PP 520 You should read any addition warnings (or errors if you specified the 521 \f[CB]\-strict\f[R] option), as well as the content of the certificate (by 522 specifying the \f[CB]\-verbose\f[R] and \f[CB]\-certs\f[R] options) to 523 determine if the signature can be trusted. 524 .SH MULTIPLE SIGNATURES FOR A JAR FILE 525 .PP 526 A JAR file can be signed by multiple people by running the 527 \f[CB]jarsigner\f[R] command on the file multiple times and specifying the 528 alias for a different person each time, as follows: 529 .IP 530 .nf 531 \f[CB] 532 jarsigner\ myBundle.jar\ susan 533 jarsigner\ myBundle.jar\ kevin 534 \f[R] 535 .fi 536 .PP 537 When a JAR file is signed multiple times, there are multiple 538 \f[CB]\&.SF\f[R] and \f[CB]\&.DSA\f[R] files in the resulting JAR file, one 539 pair for each signature. 540 In the previous example, the output JAR file includes files with the 541 following names: 542 .IP 543 .nf 544 \f[CB] 545 SUSAN.SF 546 SUSAN.DSA 547 KEVIN.SF 548 KEVIN.DSA 549 \f[R] 550 .fi 551 .SH OPTIONS FOR JARSIGNER 552 .PP 553 The following sections describe the options for the \f[CB]jarsigner\f[R]. 554 Be aware of the following standards: 555 .IP \[bu] 2 556 All option names are preceded by a hyphen sign (\-). 557 .IP \[bu] 2 558 The options can be provided in any order. 559 .IP \[bu] 2 560 Items that are in italics or underlined (option values) represent the 561 actual values that must be supplied. 562 .IP \[bu] 2 563 The \f[CB]\-storepass\f[R], \f[CB]\-keypass\f[R], \f[CB]\-sigfile\f[R], 564 \f[CB]\-sigalg\f[R], \f[CB]\-digestalg\f[R], \f[CB]\-signedjar\f[R], and 565 TSA\-related options are only relevant when signing a JAR file; they 566 aren\[aq]t relevant when verifying a signed JAR file. 567 The \f[CB]\-keystore\f[R] option is relevant for signing and verifying a 568 JAR file. 569 In addition, aliases are specified when signing and verifying a JAR 570 file. 571 .TP 572 .B \f[CB]\-keystore\f[R] \f[I]url\f[R] 573 Specifies the URL that tells the keystore location. 574 This defaults to the file \f[CB]\&.keystore\f[R] in the user\[aq]s home 575 directory, as determined by the \f[CB]user.home\f[R] system property. 576 .RS 577 .PP 578 A keystore is required when signing. 579 You must explicitly specify a keystore when the default keystore 580 doesn\[aq]t exist or if you want to use one other than the default. 581 .PP 582 A keystore isn\[aq]t required when verifying, but if one is specified or 583 the default exists and the \f[CB]\-verbose\f[R] option was also specified, 584 then additional information is output regarding whether or not any of 585 the certificates used to verify the JAR file are contained in that 586 keystore. 587 .PP 588 The \f[CB]\-keystore\f[R] argument can be a file name and path 589 specification rather than a URL, in which case it is treated the same as 590 a file: URL, for example, the following are equivalent: 591 .IP \[bu] 2 592 \f[CB]\-keystore\f[R] \f[I]filePathAndName\f[R] 593 .IP \[bu] 2 594 \f[CB]\-keystore\ file:\f[R]\f[I]filePathAndName\f[R] 595 .PP 596 If the Sun PKCS #11 provider was configured in the 597 \f[CB]java.security\f[R] security properties file (located in the 598 JRE\[aq]s \f[CB]$JAVA_HOME/conf/security\f[R] directory), then the 599 \f[CB]keytool\f[R] and \f[CB]jarsigner\f[R] tools can operate on the PKCS 600 #11 token by specifying these options: 601 .RS 602 .PP 603 \f[CB]\-keystore\ NONE\ \-storetype\ PKCS11\f[R] 604 .RE 605 .PP 606 For example, the following command lists the contents of the configured 607 PKCS#11 token: 608 .RS 609 .PP 610 \f[CB]keytool\ \-keystore\ NONE\ \-storetype\ PKCS11\ \-list\f[R] 611 .RE 612 .RE 613 .TP 614 .B \f[CB]\-storepass\f[R] [\f[CB]:env\f[R] | \f[CB]:file\f[R]] \f[I]argument\f[R] 615 Specifies the password that is required to access the keystore. 616 This is only needed when signing (not verifying) a JAR file. 617 In that case, if a \f[CB]\-storepass\f[R] option isn\[aq]t provided at the 618 command line, then the user is prompted for the password. 619 .RS 620 .PP 621 If the modifier \f[CB]env\f[R] or \f[CB]file\f[R] isn\[aq]t specified, then 622 the password has the value \f[CB]argument\f[R]. 623 Otherwise, the password is retrieved as follows: 624 .IP \[bu] 2 625 \f[CB]env\f[R]: Retrieve the password from the environment variable named 626 \f[I]argument\f[R]. 627 .IP \[bu] 2 628 \f[CB]file\f[R]: Retrieve the password from the file named 629 \f[I]argument\f[R]. 630 .PP 631 \f[B]Note:\f[R] 632 .PP 633 The password shouldn\[aq]t be specified on the command line or in a 634 script unless it is for testing purposes, or you are on a secure system. 635 .RE 636 .TP 637 .B \f[CB]\-storetype\f[R] \f[I]storetype\f[R] 638 Specifies the type of keystore to be instantiated. 639 The default keystore type is the one that is specified as the value of 640 the \f[CB]keystore.type\f[R] property in the security properties file, 641 which is returned by the static \f[CB]getDefaultType\f[R] method in 642 \f[CB]java.security.KeyStore\f[R]. 643 .RS 644 .PP 645 The PIN for a PKCS #11 token can also be specified with the 646 \f[CB]\-storepass\f[R] option. 647 If none is specified, then the \f[CB]keytool\f[R] and \f[CB]jarsigner\f[R] 648 commands prompt for the token PIN. 649 If the token has a protected authentication path (such as a dedicated 650 PIN\-pad or a biometric reader), then the \f[CB]\-protected\f[R] option 651 must be specified and no password options can be specified. 652 .RE 653 .TP 654 .B \f[CB]\-keypass\f[R] [\f[CB]:env\f[R] | \f[CB]:file\f[R]] \f[I]argument\f[R] \f[CB]\-certchain\f[R] \f[I]file\f[R] 655 Specifies the password used to protect the private key of the keystore 656 entry addressed by the alias specified on the command line. 657 The password is required when using \f[CB]jarsigner\f[R] to sign a JAR 658 file. 659 If no password is provided on the command line, and the required 660 password is different from the store password, then the user is prompted 661 for it. 662 .RS 663 .PP 664 If the modifier \f[CB]env\f[R] or \f[CB]file\f[R] isn\[aq]t specified, then 665 the password has the value \f[CB]argument\f[R]. 666 Otherwise, the password is retrieved as follows: 667 .IP \[bu] 2 668 \f[CB]env\f[R]: Retrieve the password from the environment variable named 669 \f[I]argument\f[R]. 670 .IP \[bu] 2 671 \f[CB]file\f[R]: Retrieve the password from the file named 672 \f[I]argument\f[R]. 673 .PP 674 \f[B]Note:\f[R] 675 .PP 676 The password shouldn\[aq]t be specified on the command line or in a 677 script unless it is for testing purposes, or you are on a secure system. 678 .RE 679 .TP 680 .B \f[CB]\-certchain\f[R] \f[I]file\f[R] 681 Specifies the certificate chain to be used when the certificate chain 682 associated with the private key of the keystore entry that is addressed 683 by the alias specified on the command line isn\[aq]t complete. 684 This can happen when the keystore is located on a hardware token where 685 there isn\[aq]t enough capacity to hold a complete certificate chain. 686 The file can be a sequence of concatenated X.509 certificates, or a 687 single PKCS#7 formatted data block, either in binary encoding format or 688 in printable encoding format (also known as Base64 encoding) as defined 689 by \f[B]Internet RFC 1421 Certificate Encoding Standard\f[R] 690 [http://tools.ietf.org/html/rfc1421]. 691 .RS 692 .RE 693 .TP 694 .B \f[CB]\-sigfile\f[R] \f[I]file\f[R] 695 Specifies the base file name to be used for the generated \f[CB]\&.SF\f[R] 696 and \f[CB]\&.DSA\f[R] files. 697 For example, if file is \f[CB]DUKESIGN\f[R], then the generated 698 \f[CB]\&.SF\f[R] and \f[CB]\&.DSA\f[R] files are named \f[CB]DUKESIGN.SF\f[R] 699 and \f[CB]DUKESIGN.DSA\f[R], and placed in the \f[CB]META\-INF\f[R] 700 directory of the signed JAR file. 701 .RS 702 .PP 703 The characters in the file must come from the set 704 \f[CB]a\-zA\-Z0\-9_\-\f[R]. 705 Only letters, numbers, underscore, and hyphen characters are allowed. 706 All lowercase characters are converted to uppercase for the 707 \f[CB]\&.SF\f[R] and \f[CB]\&.DSA\f[R] file names. 708 .PP 709 If no \f[CB]\-sigfile\f[R] option appears on the command line, then the 710 base file name for the \f[CB]\&.SF\f[R] and \f[CB]\&.DSA\f[R] files is the 711 first 8 characters of the alias name specified on the command line, all 712 converted to upper case. 713 If the alias name has fewer than 8 characters, then the full alias name 714 is used. 715 If the alias name contains any characters that aren\[aq]t valid in a 716 signature file name, then each such character is converted to an 717 underscore (_) character to form the file name. 718 .RE 719 .TP 720 .B \f[CB]\-signedjar\f[R] \f[I]file\f[R] 721 Specifies the name of signed JAR file. 722 .RS 723 .RE 724 .TP 725 .B \f[CB]\-digestalg\f[R] \f[I]algorithm\f[R] 726 Specifies the name of the message digest algorithm to use when digesting 727 the entries of a JAR file. 728 .RS 729 .PP 730 For a list of standard message digest algorithm names, see Java Security 731 Standard Algorithm Names. 732 .PP 733 If this option isn\[aq]t specified, then \f[CB]SHA256\f[R] is used. 734 There must either be a statically installed provider supplying an 735 implementation of the specified algorithm or the user must specify one 736 with the \f[CB]\-addprovider\f[R] or \f[CB]\-providerClass\f[R] options; 737 otherwise, the command will not succeed. 738 .RE 739 .TP 740 .B \f[CB]\-sigalg\f[R] \f[I]algorithm\f[R] 741 Specifies the name of the signature algorithm to use to sign the JAR 742 file. 743 .RS 744 .PP 745 This algorithm must be compatible with the private key used to sign the 746 JAR file. 747 If this option isn\[aq]t specified, then use a default algorithm 748 matching the private key as described in the \f[B]Supported 749 Algorithms\f[R] section. 750 There must either be a statically installed provider supplying an 751 implementation of the specified algorithm or you must specify one with 752 the \f[CB]\-addprovider\f[R] or \f[CB]\-providerClass\f[R] option; 753 otherwise, the command doesn\[aq]t succeed. 754 .PP 755 For a list of standard message digest algorithm names, see Java Security 756 Standard Algorithm Names. 757 .RE 758 .TP 759 .B \f[CB]\-verify\f[R] 760 Verifies a signed JAR file. 761 .RS 762 .RE 763 .TP 764 .B \f[CB]\-verbose\f[R][\f[CB]:\f[R]\f[I]suboptions\f[R]] 765 When the \f[CB]\-verbose\f[R] option appears on the command line, it 766 indicates that the \f[CB]jarsigner\f[R] use the verbose mode when signing 767 or verifying with the suboptions determining how much information is 768 shown. 769 This causes the , which causes \f[CB]jarsigner\f[R] to output extra 770 information about the progress of the JAR signing or verification. 771 The \f[I]suboptions\f[R] can be \f[CB]all\f[R], \f[CB]grouped\f[R], or 772 \f[CB]summary\f[R]. 773 .RS 774 .PP 775 If the \f[CB]\-certs\f[R] option is also specified, then the default mode 776 (or suboption \f[CB]all\f[R]) displays each entry as it is being 777 processed, and after that, the certificate information for each signer 778 of the JAR file. 779 .PP 780 If the \f[CB]\-certs\f[R] and the \f[CB]\-verbose:grouped\f[R] suboptions 781 are specified, then entries with the same signer info are grouped and 782 displayed together with their certificate information. 783 .PP 784 If \f[CB]\-certs\f[R] and the \f[CB]\-verbose:summary\f[R] suboptions are 785 specified, then entries with the same signer information are grouped and 786 displayed together with their certificate information. 787 .PP 788 Details about each entry are summarized and displayed as \f[I]one entry 789 (and more)\f[R]. 790 See \f[B]Example of Verifying a Signed JAR File\f[R] and \f[B]Example of 791 Verification with Certificate Information\f[R]. 792 .RE 793 .TP 794 .B \f[CB]\-certs\f[R] 795 If the \f[CB]\-certs\f[R] option appears on the command line with the 796 \f[CB]\-verify\f[R] and \f[CB]\-verbose\f[R] options, then the output 797 includes certificate information for each signer of the JAR file. 798 This information includes the name of the type of certificate (stored in 799 the \f[CB]\&.DSA\f[R] file) that certifies the signer\[aq]s public key, 800 and if the certificate is an X.509 certificate (an instance of the 801 \f[CB]java.security.cert.X509Certificate\f[R]), then the distinguished 802 name of the signer. 803 .RS 804 .PP 805 The keystore is also examined. 806 If no keystore value is specified on the command line, then the default 807 keystore file (if any) is checked. 808 If the public key certificate for a signer matches an entry in the 809 keystore, then the alias name for the keystore entry for that signer is 810 displayed in parentheses. 811 .RE 812 .TP 813 .B \f[CB]\-tsa\f[R] \f[I]url\f[R] 814 If \f[CB]\-tsa\ http://example.tsa.url\f[R] appears on the command line 815 when signing a JAR file then a time stamp is generated for the 816 signature. 817 The URL, \f[CB]http://example.tsa.url\f[R], identifies the location of the 818 Time Stamping Authority (TSA) and overrides any URL found with the 819 \f[CB]\-tsacert\f[R] option. 820 The \f[CB]\-tsa\f[R] option doesn\[aq]t require the TSA public key 821 certificate to be present in the keystore. 822 .RS 823 .PP 824 To generate the time stamp, \f[CB]jarsigner\f[R] communicates with the TSA 825 with the Time\-Stamp Protocol (TSP) defined in RFC 3161. 826 When successful, the time stamp token returned by the TSA is stored with 827 the signature in the signature block file. 828 .RE 829 .TP 830 .B \f[CB]\-tsacert\f[R] \f[I]alias\f[R] 831 When \f[CB]\-tsacert\f[R] \f[I]alias\f[R] appears on the command line when 832 signing a JAR file, a time stamp is generated for the signature. 833 The alias identifies the TSA public key certificate in the keystore that 834 is in effect. 835 The entry\[aq]s certificate is examined for a Subject Information Access 836 extension that contains a URL identifying the location of the TSA. 837 .RS 838 .PP 839 The TSA public key certificate must be present in the keystore when 840 using the \f[CB]\-tsacert\f[R] option. 841 .RE 842 .TP 843 .B \f[CB]\-tsapolicyid\f[R] \f[I]policyid\f[R] 844 Specifies the object identifier (OID) that identifies the policy ID to 845 be sent to the TSA server. 846 If this option isn\[aq]t specified, no policy ID is sent and the TSA 847 server will choose a default policy ID. 848 .RS 849 .PP 850 Object identifiers are defined by X.696, which is an ITU 851 Telecommunication Standardization Sector (ITU\-T) standard. 852 These identifiers are typically period\-separated sets of non\-negative 853 digits like \f[CB]1.2.3.4\f[R], for example. 854 .RE 855 .TP 856 .B \f[CB]\-tsadigestalg\f[R] \f[I]algorithm\f[R] 857 Specifies the message digest algorithm that is used to generate the 858 message imprint to be sent to the TSA server. 859 If this option isn\[aq]t specified, SHA\-256 will be used. 860 .RS 861 .PP 862 See \f[B]Supported Algorithms\f[R]. 863 .PP 864 For a list of standard message digest algorithm names, see Java Security 865 Standard Algorithm Names. 866 .RE 867 .TP 868 .B \f[CB]\-internalsf\f[R] 869 In the past, the \f[CB]\&.DSA\f[R] (signature block) file generated when a 870 JAR file was signed included a complete encoded copy of the 871 \f[CB]\&.SF\f[R] file (signature file) also generated. 872 This behavior has been changed. 873 To reduce the overall size of the output JAR file, the \f[CB]\&.DSA\f[R] 874 file by default doesn\[aq]t contain a copy of the \f[CB]\&.SF\f[R] file 875 anymore. 876 If \f[CB]\-internalsf\f[R] appears on the command line, then the old 877 behavior is utilized. 878 This option is useful for testing. 879 In practice, don\[aq]t use the \f[CB]\-internalsf\f[R] option because it 880 incurs higher overhead. 881 .RS 882 .RE 883 .TP 884 .B \f[CB]\-sectionsonly\f[R] 885 If the \f[CB]\-sectionsonly\f[R] option appears on the command line, then 886 the \f[CB]\&.SF\f[R] file (signature file) generated when a JAR file is 887 signed doesn\[aq]t include a header that contains a hash of the whole 888 manifest file. 889 It contains only the information and hashes related to each individual 890 source file included in the JAR file. 891 See Signature File. 892 .RS 893 .PP 894 By default, this header is added, as an optimization. 895 When the header is present, whenever the JAR file is verified, the 896 verification can first check to see whether the hash in the header 897 matches the hash of the whole manifest file. 898 When there is a match, verification proceeds to the next step. 899 When there is no match, it is necessary to do a less optimized 900 verification that the hash in each source file information section in 901 the \f[CB]\&.SF\f[R] file equals the hash of its corresponding section in 902 the manifest file. 903 See \f[B]JAR File Verification\f[R]. 904 .PP 905 The \f[CB]\-sectionsonly\f[R] option is primarily used for testing. 906 It shouldn\[aq]t be used other than for testing because using it incurs 907 higher overhead. 908 .RE 909 .TP 910 .B \f[CB]\-protected\f[R] 911 Values can be either \f[CB]true\f[R] or \f[CB]false\f[R]. 912 Specify \f[CB]true\f[R] when a password must be specified through a 913 protected authentication path such as a dedicated PIN reader. 914 .RS 915 .RE 916 .TP 917 .B \f[CB]\-providerName\f[R] \f[I]providerName\f[R] 918 If more than one provider was configured in the \f[CB]java.security\f[R] 919 security properties file, then you can use the \f[CB]\-providerName\f[R] 920 option to target a specific provider instance. 921 The argument to this option is the name of the provider. 922 .RS 923 .PP 924 For the Oracle PKCS #11 provider, \f[I]providerName\f[R] is of the form 925 \f[CB]SunPKCS11\-\f[R]\f[I]TokenName\f[R], where \f[I]TokenName\f[R] is the 926 name suffix that the provider instance has been configured with, as 927 detailed in the configuration attributes table. 928 For example, the following command lists the contents of the 929 \f[CB]PKCS\ #11\f[R] keystore provider instance with name suffix 930 \f[CB]SmartCard\f[R]: 931 .RS 932 .PP 933 \f[CB]jarsigner\ \-keystore\ NONE\ \-storetype\ PKCS11\ \-providerName\ SunPKCS11\-SmartCard\ \-list\f[R] 934 .RE 935 .RE 936 .TP 937 .B \f[CB]\-addprovider\f[R] \f[I]name\f[R] [\f[CB]\-providerArg\f[R] \f[I]arg\f[R]] 938 Adds a security provider by name (such as SunPKCS11) and an optional 939 configure argument. 940 The value of the security provider is the name of a security provider 941 that is defined in a module. 942 .RS 943 .PP 944 Used with the \f[CB]\-providerArg\ ConfigFilePath\f[R] option, the 945 \f[CB]keytool\f[R] and \f[CB]jarsigner\f[R] tools install the provider 946 dynamically and use \f[CB]ConfigFilePath\f[R] for the path to the token 947 configuration file. 948 The following example shows a command to list a \f[CB]PKCS\ #11\f[R] 949 keystore when the Oracle PKCS #11 provider wasn\[aq]t configured in the 950 security properties file. 951 .RS 952 .PP 953 \f[CB]jarsigner\ \-keystore\ NONE\ \-storetype\ PKCS11\ \-addprovider\ SunPKCS11\ \-providerArg\ /mydir1/mydir2/token.config\f[R] 954 .RE 955 .RE 956 .TP 957 .B \f[CB]\-providerClass\f[R] \f[I]provider\-class\-name\f[R] [\f[CB]\-providerArg\f[R] \f[I]arg\f[R]] 958 Used to specify the name of cryptographic service provider\[aq]s master 959 class file when the service provider isn\[aq]t listed in the 960 \f[CB]java.security\f[R] security properties file. 961 Adds a security provider by fully\-qualified class name and an optional 962 configure argument. 963 .RS 964 .PP 965 \f[B]Note:\f[R] 966 .PP 967 The preferred way to load PKCS11 is by using modules. 968 See \f[CB]\-addprovider\f[R]. 969 .RE 970 .TP 971 .B \f[CB]\-J\f[R]\f[I]javaoption\f[R] 972 Passes through the specified \f[I]javaoption\f[R] string directly to the 973 Java interpreter. 974 The \f[CB]jarsigner\f[R] command is a wrapper around the interpreter. 975 This option shouldn\[aq]t contain any spaces. 976 It is useful for adjusting the execution environment or memory usage. 977 For a list of possible interpreter options, type \f[CB]java\ \-h\f[R] or 978 \f[CB]java\ \-X\f[R] at the command line. 979 .RS 980 .RE 981 .TP 982 .B \f[CB]\-strict\f[R] 983 During the signing or verifying process, the command may issue warning 984 messages. 985 If you specify this option, the exit code of the tool reflects the 986 severe warning messages that this command found. 987 See \f[B]Errors and Warnings\f[R]. 988 .RS 989 .RE 990 .TP 991 .B \f[CB]\-conf\f[R] \f[I]url\f[R] 992 Specifies a pre\-configured options file. 993 Read the \f[B]keytool documentation\f[R] for details. 994 The property keys supported are "jarsigner.all" for all actions, 995 "jarsigner.sign" for signing, and "jarsigner.verify" for verification. 996 \f[CB]jarsigner\f[R] arguments including the JAR file name and alias 997 name(s) cannot be set in this file. 998 .RS 999 .RE 1000 .SH DEPRECATED OPTIONS 1001 .PP 1002 The following \f[CB]jarsigner\f[R] options are deprecated as of JDK 9 and 1003 might be removed in a future JDK release. 1004 .TP 1005 .B \f[CB]\-altsigner\f[R] \f[I]class\f[R] 1006 This option specifies an alternative signing mechanism. 1007 The fully qualified class name identifies a class file that extends the 1008 \f[CB]com.sun.jarsigner.ContentSigner\f[R] abstract class. 1009 The path to this class file is defined by the \f[CB]\-altsignerpath\f[R] 1010 option. 1011 If the \f[CB]\-altsigner\f[R] option is used, then the \f[CB]jarsigner\f[R] 1012 command uses the signing mechanism provided by the specified class. 1013 Otherwise, the \f[CB]jarsigner\f[R] command uses its default signing 1014 mechanism. 1015 .RS 1016 .PP 1017 For example, to use the signing mechanism provided by a class named 1018 \f[CB]com.sun.sun.jarsigner.AuthSigner\f[R], use the \f[CB]jarsigner\f[R] 1019 option \f[CB]\-altsigner\ com.sun.jarsigner.AuthSigner\f[R]. 1020 .RE 1021 .TP 1022 .B \f[CB]\-altsignerpath\f[R] \f[I]classpathlist\f[R] 1023 Specifies the path to the class file and any JAR file it depends on. 1024 The class file name is specified with the \f[CB]\-altsigner\f[R] option. 1025 If the class file is in a JAR file, then this option specifies the path 1026 to that JAR file. 1027 .RS 1028 .PP 1029 An absolute path or a path relative to the current directory can be 1030 specified. 1031 If \f[I]classpathlist\f[R] contains multiple paths or JAR files, then 1032 they should be separated with a: 1033 .IP \[bu] 2 1034 Colon (\f[CB]:\f[R]) on Oracle Solaris, Linux, and macOS 1035 .IP \[bu] 2 1036 Semicolon (\f[CB];\f[R]) on Windows 1037 .PP 1038 This option isn\[aq]t necessary when the class is already in the search 1039 path. 1040 .PP 1041 The following example shows how to specify the path to a JAR file that 1042 contains the class file. 1043 The JAR file name is included. 1044 .RS 1045 .PP 1046 \f[CB]\-altsignerpath\ /home/user/lib/authsigner.jar\f[R] 1047 .RE 1048 .PP 1049 The following example shows how to specify the path to the JAR file that 1050 contains the class file. 1051 The JAR file name is omitted. 1052 .RS 1053 .PP 1054 \f[CB]\-altsignerpath\ /home/user/classes/com/sun/tools/jarsigner/\f[R] 1055 .RE 1056 .RE 1057 .SH ERRORS AND WARNINGS 1058 .PP 1059 During the signing or verifying process, the \f[CB]jarsigner\f[R] command 1060 may issue various errors or warnings. 1061 .PP 1062 If there is a failure, the \f[CB]jarsigner\f[R] command exits with code 1. 1063 If there is no failure, but there are one or more severe warnings, the 1064 \f[CB]jarsigner\f[R] command exits with code 0 when the \f[CB]\-strict\f[R] 1065 option is \f[B]not\f[R] specified, or exits with the OR\-value of the 1066 warning codes when the \f[CB]\-strict\f[R] is specified. 1067 If there is only informational warnings or no warning at all, the 1068 command always exits with code 0. 1069 .PP 1070 For example, if a certificate used to sign an entry is expired and has a 1071 KeyUsage extension that doesn\[aq]t allow it to sign a file, the 1072 \f[CB]jarsigner\f[R] command exits with code 12 (=4+8) when the 1073 \f[CB]\-strict\f[R] option is specified. 1074 .PP 1075 \f[B]Note:\f[R] Exit codes are reused because only the values from 0 to 1076 255 are legal on Oracle Solaris, Linux, and OS X. 1077 .PP 1078 The following sections describes the names, codes, and descriptions of 1079 the errors and warnings that the \f[CB]jarsigner\f[R] command can issue. 1080 .SH FAILURE 1081 .PP 1082 Reasons why the \f[CB]jarsigner\f[R] command fails include (but aren\[aq]t 1083 limited to) a command line parsing error, the inability to find a 1084 keypair to sign the JAR file, or the verification of a signed JAR fails. 1085 .TP 1086 .B failure 1087 Code 1. 1088 The signing or verifying fails. 1089 .RS 1090 .RE 1091 .SH SEVERE WARNINGS 1092 .PP 1093 \f[B]Note:\f[R] 1094 .PP 1095 Severe warnings are reported as errors if you specify the 1096 \f[CB]\-strict\f[R] option. 1097 .PP 1098 Reasons why the \f[CB]jarsigner\f[R] command issues a severe warning 1099 include the certificate used to sign the JAR file has an error or the 1100 signed JAR file has other problems. 1101 .TP 1102 .B hasExpiredCert 1103 Code 4. 1104 This JAR contains entries whose signer certificate has expired. 1105 .RS 1106 .RE 1107 .TP 1108 .B hasExpiredTsaCert 1109 Code 4. 1110 The timestamp has expired. 1111 .RS 1112 .RE 1113 .TP 1114 .B notYetValidCert 1115 Code 4. 1116 This JAR contains entries whose signer certificate isn\[aq]t yet valid. 1117 .RS 1118 .RE 1119 .TP 1120 .B chainNotValidated 1121 Code 4. 1122 This JAR contains entries whose certificate chain isn\[aq]t validated. 1123 .RS 1124 .RE 1125 .TP 1126 .B tsaChainNotValidated 1127 Code 64. 1128 The timestamp is invalid. 1129 .RS 1130 .RE 1131 .TP 1132 .B signerSelfSigned 1133 Code 4. 1134 This JAR contains entries whose signer certificate is self signed. 1135 .RS 1136 .RE 1137 .TP 1138 .B weakAlg 1139 Code 4. 1140 An algorithm specified on the command line is considered a security 1141 risk. 1142 .RS 1143 .RE 1144 .TP 1145 .B badKeyUsage 1146 Code 8. 1147 This JAR contains entries whose signer certificate\[aq]s KeyUsage 1148 extension doesn\[aq]t allow code signing. 1149 .RS 1150 .RE 1151 .TP 1152 .B badExtendedKeyUsage 1153 Code 8. 1154 This JAR contains entries whose signer certificate\[aq]s 1155 ExtendedKeyUsage extension doesn\[aq]t allow code signing. 1156 .RS 1157 .RE 1158 .TP 1159 .B badNetscapeCertType 1160 Code 8. 1161 This JAR contains entries whose signer certificate\[aq]s 1162 NetscapeCertType extension doesn\[aq]t allow code signing. 1163 .RS 1164 .RE 1165 .TP 1166 .B hasUnsignedEntry 1167 Code 16. 1168 This JAR contains unsigned entries which haven\[aq]t been 1169 integrity\-checked. 1170 .RS 1171 .RE 1172 .TP 1173 .B notSignedByAlias 1174 Code 32. 1175 This JAR contains signed entries which aren\[aq]t signed by the 1176 specified alias(es). 1177 .RS 1178 .RE 1179 .TP 1180 .B aliasNotInStore 1181 Code 32. 1182 This JAR contains signed entries that aren\[aq]t signed by alias in this 1183 keystore. 1184 .RS 1185 .RE 1186 .TP 1187 .B tsaChainNotValidated 1188 Code 64. 1189 This JAR contains entries whose TSA certificate chain is invalid. 1190 .RS 1191 .RE 1192 .SH INFORMATIONAL WARNINGS 1193 .PP 1194 Informational warnings include those that aren\[aq]t errors but regarded 1195 as bad practice. 1196 They don\[aq]t have a code. 1197 .TP 1198 .B hasExpiringCert 1199 This JAR contains entries whose signer certificate expires within six 1200 months. 1201 .RS 1202 .RE 1203 .TP 1204 .B hasExpiringTsaCert 1205 The timestamp will expire within one year on \f[CB]YYYY\-MM\-DD\f[R]. 1206 .RS 1207 .RE 1208 .TP 1209 .B noTimestamp 1210 This JAR contains signatures that doesn\[aq]t include a timestamp. 1211 Without a timestamp, users may not be able to validate this JAR file 1212 after the signer certificate\[aq]s expiration date 1213 (\f[CB]YYYY\-MM\-DD\f[R]) or after any future revocation date. 1214 .RS 1215 .RE 1216 .SH EXAMPLE OF SIGNING A JAR FILE 1217 .PP 1218 Use the following command to sign \f[CB]bundle.jar\f[R] with the private 1219 key of a user whose keystore alias is \f[CB]jane\f[R] in a keystore named 1220 \f[CB]mystore\f[R] in the \f[CB]working\f[R] directory and name the signed 1221 JAR file \f[CB]sbundle.jar\f[R]: 1222 .RS 1223 .PP 1224 \f[CB]jarsigner\ \-keystore\ /working/mystore\ \-storepass\f[R] 1225 \f[I]keystore_password\f[R] \f[CB]\-keypass\f[R] 1226 \f[I]private_key_password\f[R] 1227 \f[CB]\-signedjar\ sbundle.jar\ bundle.jar\ jane\f[R] 1228 .RE 1229 .PP 1230 There is no \f[CB]\-sigfile\f[R] specified in the previous command so the 1231 generated \f[CB]\&.SF\f[R] and \f[CB]\&.DSA\f[R] files to be placed in the 1232 signed JAR file have default names based on the alias name. 1233 They are named \f[CB]JANE.SF\f[R] and \f[CB]JANE.DSA\f[R]. 1234 .PP 1235 If you want to be prompted for the store password and the private key 1236 password, then you could shorten the previous command to the following: 1237 .RS 1238 .PP 1239 \f[CB]jarsigner\ \-keystore\ /working/mystore\ \-signedjar\ sbundle.jar\ bundle.jar\ jane\f[R] 1240 .RE 1241 .PP 1242 If the \f[CB]keystore\f[R] is the default \f[CB]keystore\f[R] 1243 (\f[CB]\&.keystore\f[R] in your home directory), then you don\[aq]t need 1244 to specify a \f[CB]keystore\f[R], as follows: 1245 .RS 1246 .PP 1247 \f[CB]jarsigner\ \-signedjar\ sbundle.jar\ bundle.jar\ jane\f[R] 1248 .RE 1249 .PP 1250 If you want the signed JAR file to overwrite the input JAR file 1251 (\f[CB]bundle.jar\f[R]), then you don\[aq]t need to specify a 1252 \f[CB]\-signedjar\f[R] option, as follows: 1253 .RS 1254 .PP 1255 \f[CB]jarsigner\ bundle.jar\ jane\f[R] 1256 .RE 1257 .SH EXAMPLE OF VERIFYING A SIGNED JAR FILE 1258 .PP 1259 To verify a signed JAR file to ensure that the signature is valid and 1260 the JAR file wasn\[aq]t been tampered with, use a command such as the 1261 following: 1262 .RS 1263 .PP 1264 \f[CB]jarsigner\ \-verify\ ButtonDemo.jar\f[R] 1265 .RE 1266 .PP 1267 When the verification is successful, \f[CB]jar\ verified\f[R] is 1268 displayed. 1269 Otherwise, an error message is displayed. 1270 You can get more information when you use the \f[CB]\-verbose\f[R] option. 1271 A sample use of \f[CB]jarsigner\f[R] with the \f[CB]\-verbose\f[R] option 1272 follows: 1273 .IP 1274 .nf 1275 \f[CB] 1276 jarsigner\ \-verify\ \-verbose\ ButtonDemo.jar 1277 1278 s\ \ \ \ \ \ \ 866\ Tue\ Sep\ 12\ 20:08:48\ EDT\ 2017\ META\-INF/MANIFEST.MF 1279 \ \ \ \ \ \ \ \ 825\ Tue\ Sep\ 12\ 20:08:48\ EDT\ 2017\ META\-INF/ORACLE_C.SF 1280 \ \ \ \ \ \ \ 7475\ Tue\ Sep\ 12\ 20:08:48\ EDT\ 2017\ META\-INF/ORACLE_C.RSA 1281 \ \ \ \ \ \ \ \ \ \ 0\ Tue\ Sep\ 12\ 20:07:54\ EDT\ 2017\ META\-INF/ 1282 \ \ \ \ \ \ \ \ \ \ 0\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ 1283 \ \ \ \ \ \ \ \ \ \ 0\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/ 1284 sm\ \ \ \ \ \ 523\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ButtonDemo$1.class 1285 sm\ \ \ \ \ 3440\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ButtonDemo.class 1286 sm\ \ \ \ \ 2346\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ButtonDemo.jnlp 1287 sm\ \ \ \ \ \ 172\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/left.gif 1288 sm\ \ \ \ \ \ 235\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/middle.gif 1289 sm\ \ \ \ \ \ 172\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/right.gif 1290 1291 \ \ s\ =\ signature\ was\ verified 1292 \ \ m\ =\ entry\ is\ listed\ in\ manifest 1293 \ \ k\ =\ at\ least\ one\ certificate\ was\ found\ in\ keystore 1294 1295 \-\ Signed\ by\ "CN="Oracle\ America,\ Inc.",\ OU=Software\ Engineering,\ O="Oracle\ America,\ Inc.",\ L=Redwood\ City,\ ST=California,\ C=US" 1296 \ \ \ \ Digest\ algorithm:\ SHA\-256 1297 \ \ \ \ Signature\ algorithm:\ SHA256withRSA,\ 2048\-bit\ key 1298 \ \ Timestamped\ by\ "CN=Symantec\ Time\ Stamping\ Services\ Signer\ \-\ G4,\ O=Symantec\ Corporation,\ C=US"\ on\ Tue\ Sep\ 12\ 20:08:49\ UTC\ 2017 1299 \ \ \ \ Timestamp\ digest\ algorithm:\ SHA\-1 1300 \ \ \ \ Timestamp\ signature\ algorithm:\ SHA1withRSA,\ 2048\-bit\ key 1301 1302 jar\ verified. 1303 1304 The\ signer\ certificate\ expired\ on\ 2018\-02\-01.\ However,\ the\ JAR\ will\ be\ valid\ until\ the\ timestamp\ expires\ on\ 2020\-12\-29. 1305 \f[R] 1306 .fi 1307 .SH EXAMPLE OF VERIFICATION WITH CERTIFICATE INFORMATION 1308 .PP 1309 If you specify the \f[CB]\-certs\f[R] option with the \f[CB]\-verify\f[R] 1310 and \f[CB]\-verbose\f[R] options, then the output includes certificate 1311 information for each signer of the JAR file. 1312 The information includes the certificate type, the signer distinguished 1313 name information (when it is an X.509 certificate), and in parentheses, 1314 the keystore alias for the signer when the public key certificate in the 1315 JAR file matches the one in a keystore entry, for example: 1316 .IP 1317 .nf 1318 \f[CB] 1319 jarsigner\ \-keystore\ $JAVA_HOME/lib/security/cacerts\ \-verify\ \-verbose\ \-certs\ ButtonDemo.jar 1320 1321 s\ k\ \ \ \ \ 866\ Tue\ Sep\ 12\ 20:08:48\ EDT\ 2017\ META\-INF/MANIFEST.MF 1322 1323 \ \ \ \ \ \ >>>\ Signer 1324 \ \ \ \ \ \ X.509,\ CN="Oracle\ America,\ Inc.",\ OU=Software\ Engineering,\ O="Oracle\ America,\ Inc.",\ L=Redwood\ City,\ ST=California,\ C=US 1325 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2017\-01\-30,\ 7:00\ PM\ to\ 2018\-02\-01,\ 6:59\ PM] 1326 \ \ \ \ \ \ X.509,\ CN=Symantec\ Class\ 3\ SHA256\ Code\ Signing\ CA,\ OU=Symantec\ Trust\ Network,\ O=Symantec\ Corporation,\ C=US 1327 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2013\-12\-09,\ 7:00\ PM\ to\ 2023\-12\-09,\ 6:59\ PM] 1328 \ \ \ \ \ \ X.509,\ CN=VeriSign\ Class\ 3\ Public\ Primary\ Certification\ Authority\ \-\ G5,\ OU="(c)\ 2006\ VeriSign,\ Inc.\ \-\ For\ authorized\ use\ only",\ OU=VeriSign\ Trust\ Network,\ O="VeriSign,\ Inc.",\ C=US\ (verisignclass3g5ca\ [jdk]) 1329 \ \ \ \ \ \ [trusted\ certificate] 1330 \ \ \ \ \ \ >>>\ TSA 1331 \ \ \ \ \ \ X.509,\ CN=Symantec\ Time\ Stamping\ Services\ Signer\ \-\ G4,\ O=Symantec\ Corporation,\ C=US 1332 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2012\-10\-17,\ 8:00\ PM\ to\ 2020\-12\-29,\ 6:59\ PM] 1333 \ \ \ \ \ \ X.509,\ CN=Symantec\ Time\ Stamping\ Services\ CA\ \-\ G2,\ O=Symantec\ Corporation,\ C=US 1334 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2012\-12\-20,\ 7:00\ PM\ to\ 2020\-12\-30,\ 6:59\ PM] 1335 1336 \ \ \ \ \ \ \ \ 825\ Tue\ Sep\ 12\ 20:08:48\ EDT\ 2017\ META\-INF/ORACLE_C.SF 1337 \ \ \ \ \ \ \ 7475\ Tue\ Sep\ 12\ 20:08:48\ EDT\ 2017\ META\-INF/ORACLE_C.RSA 1338 \ \ \ \ \ \ \ \ \ \ 0\ Tue\ Sep\ 12\ 20:07:54\ EDT\ 2017\ META\-INF/ 1339 \ \ \ \ \ \ \ \ \ \ 0\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ 1340 \ \ \ \ \ \ \ \ \ \ 0\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/ 1341 smk\ \ \ \ \ 523\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ButtonDemo$1.class 1342 1343 \ \ \ \ \ \ [entry\ was\ signed\ on\ 2017\-09\-12,\ 4:08\ PM] 1344 \ \ \ \ \ \ >>>\ Signer 1345 \ \ \ \ \ \ X.509,\ CN="Oracle\ America,\ Inc.",\ OU=Software\ Engineering,\ O="Oracle\ America,\ Inc.",\ L=Redwood\ City,\ ST=California,\ C=US 1346 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2017\-01\-30,\ 7:00\ PM\ to\ 2018\-02\-01,\ 6:59\ PM] 1347 \ \ \ \ \ \ X.509,\ CN=Symantec\ Class\ 3\ SHA256\ Code\ Signing\ CA,\ OU=Symantec\ Trust\ Network,\ O=Symantec\ Corporation,\ C=US 1348 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2013\-12\-09,\ 7:00\ PM\ to\ 2023\-12\-09,\ 6:59\ PM] 1349 \ \ \ \ \ \ X.509,\ CN=VeriSign\ Class\ 3\ Public\ Primary\ Certification\ Authority\ \-\ G5,\ OU="(c)\ 2006\ VeriSign,\ Inc.\ \-\ For\ authorized\ use\ only",\ OU=VeriSign\ Trust\ Network,\ O="VeriSign,\ Inc.",\ C=US\ (verisignclass3g5ca\ [jdk]) 1350 \ \ \ \ \ \ [trusted\ certificate] 1351 \ \ \ \ \ \ >>>\ TSA 1352 \ \ \ \ \ \ X.509,\ CN=Symantec\ Time\ Stamping\ Services\ Signer\ \-\ G4,\ O=Symantec\ Corporation,\ C=US 1353 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2012\-10\-17,\ 8:00\ PM\ to\ 2020\-12\-29,\ 6:59\ PM] 1354 \ \ \ \ \ \ X.509,\ CN=Symantec\ Time\ Stamping\ Services\ CA\ \-\ G2,\ O=Symantec\ Corporation,\ C=US 1355 \ \ \ \ \ \ [certificate\ is\ valid\ from\ 2012\-12\-20,\ 7:00\ PM\ to\ 2020\-12\-30,\ 6:59\ PM] 1356 1357 smk\ \ \ \ 3440\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ButtonDemo.class 1358 \&... 1359 smk\ \ \ \ 2346\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/ButtonDemo.jnlp 1360 \&... 1361 smk\ \ \ \ \ 172\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/left.gif 1362 \&... 1363 smk\ \ \ \ \ 235\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/middle.gif 1364 \&... 1365 smk\ \ \ \ \ 172\ Tue\ Sep\ 12\ 20:07:16\ EDT\ 2017\ components/images/right.gif 1366 \&... 1367 1368 \ \ s\ =\ signature\ was\ verified 1369 \ \ m\ =\ entry\ is\ listed\ in\ manifest 1370 \ \ k\ =\ at\ least\ one\ certificate\ was\ found\ in\ keystore 1371 1372 \-\ Signed\ by\ "CN="Oracle\ America,\ Inc.",\ OU=Software\ Engineering,\ O="Oracle\ America,\ Inc.",\ L=Redwood\ City,\ ST=California,\ C=US" 1373 \ \ \ \ Digest\ algorithm:\ SHA\-256 1374 \ \ \ \ Signature\ algorithm:\ SHA256withRSA,\ 2048\-bit\ key 1375 \ \ Timestamped\ by\ "CN=Symantec\ Time\ Stamping\ Services\ Signer\ \-\ G4,\ O=Symantec\ Corporation,\ C=US"\ on\ Tue\ Sep\ 12\ 20:08:49\ UTC\ 2017 1376 \ \ \ \ Timestamp\ digest\ algorithm:\ SHA\-1 1377 \ \ \ \ Timestamp\ signature\ algorithm:\ SHA1withRSA,\ 2048\-bit\ key 1378 1379 jar\ verified. 1380 1381 The\ signer\ certificate\ expired\ on\ 2018\-02\-01.\ However,\ the\ JAR\ will\ be\ valid\ until\ the\ timestamp\ expires\ on\ 2020\-12\-29. 1382 \f[R] 1383 .fi 1384 .PP 1385 If the certificate for a signer isn\[aq]t an X.509 certificate, then 1386 there is no distinguished name information. 1387 In that case, just the certificate type and the alias are shown. 1388 For example, if the certificate is a PGP certificate, and the alias is 1389 \f[CB]bob\f[R], then you would get: \f[CB]PGP,\ (bob)\f[R]. |