jarsigner.1 53.9 KB
Newer Older
1
." Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
D
duke 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
." DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
."
." This code is free software; you can redistribute it and/or modify it
." under the terms of the GNU General Public License version 2 only, as
." published by the Free Software Foundation.
."
." This code is distributed in the hope that it will be useful, but WITHOUT
." ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
." FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
." version 2 for more details (a copy is included in the LICENSE file that
." accompanied this code).
."
." You should have received a copy of the GNU General Public License version
." 2 along with this work; if not, write to the Free Software Foundation,
." Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
."
18 19 20
." Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
." or visit www.oracle.com if you need additional information or have any
." questions.
D
duke 已提交
21
."
22
.TH jarsigner 1 "02 Jun 2010"
D
duke 已提交
23 24

.LP
T
tbell 已提交
25
.SH "Name"
D
duke 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
jarsigner \- JAR Signing and Verification Tool
.LP
.RS 3

.LP
.LP
Generates signatures for Java ARchive (JAR) files, and verifies the signatures of signed JAR files.
.LP
.RE
.SH "SYNOPSIS"
.LP

.LP
.nf
\f3
.fl
\fP\f3jarsigner\fP [ options ] jar\-file alias
.fl
T
tbell 已提交
44
\f3jarsigner\fP \-verify [ options ] jar\-file [alias...]
D
duke 已提交
45 46 47
.fl
.fi

T
tbell 已提交
48 49 50
.LP
.LP
The jarsigner \-verify command can take zero or more keystore alias names after the jar filename. When specified, jarsigner will check that the certificate used to verify each signed entry in the jar file matches one of the keystore aliases. The aliases are defined in the keystore specified by \-keystore, or the default keystore.
D
duke 已提交
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
.LP
.SH "DESCRIPTION"
.LP

.LP
.LP
The \f3jarsigner\fP tool is used for two purposes:
.LP
.RS 3
.TP 3
1.
to sign Java ARchive (JAR) files, and 
.TP 3
2.
to verify the signatures and integrity of signed JAR files. 
.RE

.LP
.LP
T
tbell 已提交
70
The JAR feature enables the packaging of class files, images, sounds, and other digital data in a single file for faster and easier distribution. A tool named jar(1) enables developers to produce JAR files. (Technically, any zip file can also be considered a JAR file, although when created by \f3jar\fP or processed by \f3jarsigner\fP, JAR files also contain a META\-INF/MANIFEST.MF file.)
D
duke 已提交
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
.LP
.LP
A \f2digital signature\fP is a string of bits that is computed from some data (the data being "signed") and the private key of an entity (a person, company, etc.). Like a handwritten signature, a digital signature has many useful characteristics:
.LP
.RS 3
.TP 2
o
Its authenticity can be verified, via a computation that uses the public key corresponding to the private key used to generate the signature. 
.TP 2
o
It cannot be forged, assuming the private key is kept secret. 
.TP 2
o
It is a function of the data signed and thus can't be claimed to be the signature for other data as well. 
.TP 2
o
The signed data cannot be changed; if it is, the signature will no longer verify as being authentic. 
.RE

.LP
.LP
In order for an entity's signature to be generated for a file, the entity must first have a public/private key pair associated with it, and also one or more certificates authenticating its public key. A \f2certificate\fP is a digitally signed statement from one entity, saying that the public key of some other entity has a particular value.
.LP
.LP
T
tbell 已提交
95
\f3jarsigner\fP uses key and certificate information from a \f2keystore\fP to generate digital signatures for JAR files. A keystore is a database of private keys and their associated X.509 certificate chains authenticating the corresponding public keys. The keytool(1) utility is used to create and administer keystores.
D
duke 已提交
96 97 98 99 100
.LP
.LP
\f3jarsigner\fP uses an entity's private key to generate a signature. The signed JAR file contains, among other things, a copy of the certificate from the keystore for the public key corresponding to the private key used to sign the file. \f3jarsigner\fP can verify the digital signature of the signed JAR file using the certificate inside it (in its signature block file).
.LP
.LP
T
tbell 已提交
101
\f3jarsigner\fP can generate signatures that include a timestamp, thus enabling systems/deployer (including Java Plug\-in) to check whether the JAR file was signed while the signing certificate was still valid. In addition, APIs will allow applications to obtain the timestamp information.
D
duke 已提交
102 103
.LP
.LP
T
tbell 已提交
104
At this time, \f3jarsigner\fP can only sign JAR files created by the SDK jar(1) tool or zip files. (JAR files are the same as zip files, except they also have a META\-INF/MANIFEST.MF file. Such a file will automatically be created when \f3jarsigner\fP signs a zip file.)
D
duke 已提交
105 106 107 108 109
.LP
.LP
The default \f3jarsigner\fP behavior is to \f2sign\fP a JAR (or zip) file. Use the \f2\-verify\fP option to instead have it \f2verify\fP a signed JAR file.
.LP
.SS 
T
tbell 已提交
110
Keystore Aliases
D
duke 已提交
111 112 113 114 115
.LP
.RS 3

.LP
.LP
T
tbell 已提交
116
All keystore entities are accessed via unique \f2aliases\fP.
D
duke 已提交
117 118
.LP
.LP
T
tbell 已提交
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
When using \f3jarsigner\fP to sign a JAR file, you must specify the alias for the keystore entry containing the private key needed to generate the signature. For example, the following will sign the JAR file named "MyJARFile.jar", using the private key associated with the alias "duke" in the keystore named "mystore" in the "working" directory. Since no output file is specified, it overwrites MyJARFile.jar with the signed JAR file.
.LP
.nf
\f3
.fl
    jarsigner \-keystore /working/mystore \-storepass myspass
.fl
      \-keypass dukekeypasswd MyJARFile.jar duke 
.fl
\fP
.fi

.LP
.LP
Keystores are protected with a password, so the store password (in this case "myspass") must be specified. You will be prompted for it if you don't specify it on the command line. Similarly, private keys are protected in a keystore with a password, so the private key's password (in this case "dukekeypasswd") must be specified, and you will be prompted for it if you don't specify it on the command line and it isn't the same as the store password.
.LP
.RE
.SS 
Keystore Location
.LP
.RS 3

.LP
.LP
\f3jarsigner\fP has a \f2\-keystore\fP option for specifying the URL of the keystore to be used. The keystore is by default stored in a file named \f2.keystore\fP in the user's home directory, as determined by the \f2user.home\fP system property. On Solaris systems \f2user.home\fP defaults to the user's home directory.
.LP
.LP
Note that the input stream from the \f2\-keystore\fP option is passed to the \f2KeyStore.load\fP method. If \f2NONE\fP is specified as the URL, then a null stream is passed to the \f2KeyStore.load\fP method. \f2NONE\fP should be specified if the \f2KeyStore\fP is not file\-based, for example, if it resides on a hardware token device.
.LP
.RE
.SS 
Keystore Implementation
.LP
.RS 3

.LP
.LP
The \f2KeyStore\fP class provided in the \f2java.security\fP package supplies well\-defined interfaces to access and modify the information in a keystore. It is possible for there to be multiple different concrete implementations, where each implementation is that for a particular \f2type\fP of keystore.
.LP
.LP
Currently, there are two command\-line tools that make use of keystore implementations (\f3keytool\fP and \f3jarsigner\fP), and also a GUI\-based tool named \f3Policy Tool\fP. Since \f2KeyStore\fP is publicly available, Java 2 SDK users can write additional security applications that use it.
.LP
.LP
There is a built\-in default implementation, provided by Sun Microsystems. It implements the keystore as a file, utilizing a proprietary keystore type (format) named "JKS". It protects each private key with its individual password, and also protects the integrity of the entire keystore with a (possibly different) password.
.LP
.LP
Keystore implementations are provider\-based. More specifically, the application interfaces supplied by \f2KeyStore\fP are implemented in terms of a "Service Provider Interface" (SPI). That is, there is a corresponding abstract \f2KeystoreSpi\fP class, also in the \f2java.security\fP package, which defines the Service Provider Interface methods that "providers" must implement. (The term "provider" refers to a package or a set of packages that supply a concrete implementation of a subset of services that can be accessed by the Java Security API.) Thus, to provide a keystore implementation, clients must implement a provider and supply a KeystoreSpi subclass implementation, as described in 
.na
\f2How to Implement a Provider for the Java Cryptography Architecture\fP @
.fi
http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/HowToImplAProvider.html.
.LP
.LP
Applications can choose different \f2types\fP of keystore implementations from different providers, using the "getInstance" factory method supplied in the \f2KeyStore\fP class. A keystore type defines the storage and data format of the keystore information, and the algorithms used to protect private keys in the keystore and the integrity of the keystore itself. Keystore implementations of different types are not compatible.
.LP
.LP
\f3keytool\fP works on any file\-based keystore implementation. (It treats the keytore location that is passed to it at the command line as a filename and converts it to a FileInputStream, from which it loads the keystore information.) The \f3jarsigner\fP and \f3policytool\fP tools, on the other hand, can read a keystore from any location that can be specified using a URL.
.LP
.LP
For \f3jarsigner\fP and \f3keytool\fP, you can specify a keystore type at the command line, via the \f2\-storetype\fP option. For \f3Policy Tool\fP, you can specify a keystore type via the "Change Keystore" command in the Edit menu.
.LP
.LP
If you don't explicitly specify a keystore type, the tools choose a keystore implementation based simply on the value of the \f2keystore.type\fP property specified in the security properties file. The security properties file is called \f2java.security\fP, and it resides in the SDK security properties directory, \f2java.home\fP/lib/security, where \f2java.home\fP is the runtime environment's directory (the \f2jre\fP directory in the SDK or the top\-level directory of the Java 2 Runtime Environment).
.LP
.LP
Each tool gets the \f2keystore.type\fP value and then examines all the currently\-installed providers until it finds one that implements keystores of that type. It then uses the keystore implementation from that provider.
.LP
.LP
The \f2KeyStore\fP class defines a static method named \f2getDefaultType\fP that lets applications and applets retrieve the value of the \f2keystore.type\fP property. The following line of code creates an instance of the default keystore type (as specified in the \f2keystore.type\fP property):
.LP
.nf
\f3
.fl
    KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
.fl
\fP
.fi

.LP
.LP
The default keystore type is "jks" (the proprietary type of the keystore implementation provided by Sun). This is specified by the following line in the security properties file:
.LP
.nf
\f3
.fl
    keystore.type=jks
.fl
\fP
.fi

.LP
.LP
Note: Case doesn't matter in keystore type designations. For example, "JKS" would be considered the same as "jks".
.LP
.LP
To have the tools utilize a keystore implementation other than the default, change that line to specify a different keystore type. For example, if you have a provider package that supplies a keystore implementation for a keystore type called "pkcs12", change the line to
.LP
.nf
\f3
.fl
    keystore.type=pkcs12
.fl
\fP
.fi

.LP
.LP
Note that if you us the PKCS#11 provider package, you should refer to the 
.na
\f2KeyTool and JarSigner\fP @
.fi
http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#KeyToolJarSigner section of the Java PKCS#11 Reference Guide for details.
.LP
.RE
.SS 
Supported Algorithms
.LP
.RS 3

.LP
.LP
By default, \f3jarsigner\fP signs a JAR file using either
D
duke 已提交
241 242 243 244
.LP
.RS 3
.TP 2
o
T
tbell 已提交
245
DSA (Digital Signature Algorithm) with the SHA\-1 digest algorithm, or 
D
duke 已提交
246 247
.TP 2
o
248
the RSA algorithm with the SHA\-256 digest algorithm. 
T
tbell 已提交
249 250 251 252
.RE

.LP
.LP
253
That is, if the signer's public and private keys are DSA keys, \f3jarsigner\fP will sign the JAR file using the "SHA1withDSA" algorithm. If the signer's keys are RSA keys, \f3jarsigner\fP will attempt to sign the JAR file using the "SHA256withRSA" algorithm.
T
tbell 已提交
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
.LP
.LP
These default signature algorithms can be overridden using the \f2\-sigalg\fP option.
.LP
.RE
.SS 
The Signed JAR File
.LP
.RS 3

.LP
.LP
When \f3jarsigner\fP is used to sign a JAR file, the output signed JAR file is exactly the same as the input JAR file, except that it has two additional files placed in the META\-INF directory:
.LP
.RS 3
D
duke 已提交
269 270
.TP 2
o
T
tbell 已提交
271 272 273 274
a signature file, with a .SF extension, and 
.TP 2
o
a signature block file, with a .DSA extension. 
D
duke 已提交
275 276 277 278
.RE

.LP
.LP
T
tbell 已提交
279
The base file names for these two files come from the value of the \f2\-sigFile\fP option. For example, if the option appears as
D
duke 已提交
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
.LP
.nf
\f3
.fl
  \-sigFile MKSIGN
.fl
\fP
.fi

.LP
.LP
the files are named "MKSIGN.SF" and "MKSIGN.DSA".
.LP
.LP
If no \f2\-sigfile\fP option appears on the command line, the base file name for the .SF and .DSA files will be the first 8 characters of the alias name specified on the command line, all converted to upper case. If the alias name has fewer than 8 characters, the full alias name is used. If the alias name contains any characters that are not allowed in a signature file name, each such character is converted to an underscore ("_") character in forming the file name. Legal characters include letters, digits, underscores, and hyphens.
.LP
\f3The Signature (.SF) File\fP
.LP
.RS 3

.LP
.LP
A signature file (the .SF file) looks similar to the manifest file that is always included in a JAR file when \f3jarsigner\fP is used to sign the file. That is, for each source file included in the JAR file, the .SF file has three lines, just as in the manifest file, listing the following:
.LP
.RS 3
.TP 2
o
the file name, 
.TP 2
o
the name of the digest algorithm used (SHA), and 
.TP 2
o
a SHA digest value. 
.RE

.LP
.LP
In the manifest file, the SHA digest value for each source file is the digest (hash) of the binary data in the source file. In the .SF file, on the other hand, the digest value for a given source file is the hash of the three lines in the manifest file for the source file.
.LP
.LP
The signature file also, by default, includes a header containing a hash of the whole manifest file. The presence of the header enables verification optimization, as described in JAR File Verification.
.LP
.RE
\f3The Signature Block (.DSA) File\fP
.LP
.RS 3

.LP
.LP
The .SF file is signed and the signature is placed in the .DSA file. The .DSA file also contains, encoded inside it, the certificate or certificate chain from the keystore which authenticates the public key corresponding to the private key used for signing.
.LP
.RE
.RE
.SS 
Signature Timestamp
.LP
.RS 3

.LP
.LP
T
tbell 已提交
341
\f2jarsigner\fP tool can now generate and store a signature timestamp when signing a JAR file. In addition, \f2jarsigner\fP supports alternative signing mechanisms. This behavior is optional and is controlled by the user at the time of signing through these options:
D
duke 已提交
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
.LP
.RS 3
.TP 2
o
\f2\-tsa url\fP 
.TP 2
o
\f2\-tsacert alias\fP 
.TP 2
o
\f2\-altsigner class\fP 
.TP 2
o
\f2\-altsignerpath classpathlist\fP 
.RE

.LP
.LP
Each of these options is detailed in the Options section below.
.LP
.RE
.SS 
JAR File Verification
.LP
.RS 3

.LP
.LP
A successful JAR file verification occurs if the signature(s) are valid, and none of the files that were in the JAR file when the signatures were generated have been changed since then. JAR file verification involves the following steps:
.LP
.RS 3
.TP 3
1.
Verify the signature of the .SF file itself. 
.LP
That is, the verification ensures that the signature stored in each signature block (.DSA) file was in fact generated using the private key corresponding to the public key whose certificate (or certificate chain) also appears in the .DSA file. It also ensures that the signature is a valid signature of the corresponding signature (.SF) file, and thus the .SF file has not been tampered with.  
.TP 3
2.
Verify the digest listed in each entry in the .SF file with each corresponding section in the manifest. 
.LP
The .SF file by default includes a header containing a hash of the entire manifest file. When the header is present, then the verification can check to see whether or not the hash in the header indeed matches the hash of the manifest file. If that is the case, verification proceeds to the next step. 
.LP
If that is not the case, a less optimized verification is required to ensure that the hash in each source file information section in the .SF file equals the hash of its corresponding section in the manifest file (see The Signature (.SF) File). 
.LP
One reason the hash of the manifest file that is stored in the .SF file header may not equal the hash of the current manifest file would be because one or more files were added to the JAR file (using the \f2jar\fP tool) after the signature (and thus the .SF file) was generated. When the \f2jar\fP tool is used to add files, the manifest file is changed (sections are added to it for the new files), but the .SF file is not. A verification is still considered successful if none of the files that were in the JAR file when the signature was generated have been changed since then, which is the case if the hashes in the non\-header sections of the .SF file equal the hashes of the corresponding sections in the manifest file.  
.TP 3
3.
Read each file in the JAR file that has an entry in the .SF file. While reading, compute the file's digest, and then compare the result with the digest for this file in the manifest section. The digests should be the same, or verification fails. 
.RE

.LP
.LP
If any serious verification failures occur during the verification process, the process is stopped and a security exception is thrown. It is caught and displayed by \f3jarsigner\fP.
.LP
.RE
.SS 
Multiple Signatures for a JAR File
.LP
.RS 3

.LP
.LP
A JAR file can be signed by multiple people simply by running the \f3jarsigner\fP tool on the file multiple times, specifying the alias for a different person each time, as in:
.LP
.nf
\f3
.fl
  jarsigner myBundle.jar susan
.fl
  jarsigner myBundle.jar kevin
.fl
\fP
.fi

.LP
.LP
When a JAR file is signed multiple times, there are multiple .SF and .DSA files in the resulting JAR file, one pair for each signature. Thus, in the example above, the output JAR file includes files with the following names:
.LP
.nf
\f3
.fl
  SUSAN.SF
.fl
  SUSAN.DSA
.fl
  KEVIN.SF
.fl
  KEVIN.DSA
.fl
\fP
.fi

.LP
.LP
Note: It is also possible for a JAR file to have mixed signatures, some generated by the JDK 1.1 \f3javakey\fP tool and others by \f3jarsigner\fP. That is, \f3jarsigner\fP can be used to sign JAR files already previously signed using \f3javakey\fP.
.LP
.RE
.SH "OPTIONS"
.LP

.LP
.LP
The various \f3jarsigner\fP options are listed and described below. Note:
.LP
.RS 3
.TP 2
o
All option names are preceded by a minus sign (\-). 
.TP 2
o
The options may be provided in any order. 
.TP 2
o
Items in italics (option values) represent the actual values that must be supplied. 
.TP 2
o
The \f2\-keystore\fP, \f2\-storepass\fP, \f2\-keypass\fP, \f2\-sigfile\fP, \f2\-sigalg\fP, \f2\-digestalg\fP, and \f2\-signedjar\fP options are only relevant when signing a JAR file, not when verifying a signed JAR file. Similarly, an alias is only specified on the command line when signing a JAR file. 
.RE

.LP
.RS 3
.TP 3
\-keystore url 
Specifies the URL that tells the keystore location. This defaults to the file \f2.keystore\fP in the user's home directory, as determined by the "user.home" system property. 
.LP
A keystore is required when signing, so you must explicitly specify one if the default keystore does not exist (or you want to use one other than the default). 
.LP
A keystore is \f2not\fP required when verifying, but if one is specified, or the default exists, and the \f2\-verbose\fP option was also specified, additional information is output regarding whether or not any of the certificates used to verify the JAR file are contained in that keystore. 
.LP
Note: the \f2\-keystore\fP argument can actually be a file name (and path) specification rather than a URL, in which case it will be treated the same as a "file:" URL. That is, 
.nf
\f3
.fl
  \-keystore \fP\f4filePathAndName\fP\f3
.fl
\fP
.fi
is treated as equivalent to 
.nf
\f3
.fl
  \-keystore file:\fP\f4filePathAndName\fP\f3
.fl
\fP
.fi
If the Sun PKCS#11 provider has been configured in the \f2java.security\fP security properties file (located in the JRE's \f2$JAVA_HOME/lib/security\fP directory), then keytool and jarsigner can operate on the PKCS#11 token by specifying these options: 
.RS 3
.TP 2
o
\f2\-keystore NONE\fP 
.TP 2
o
\f2\-storetype PKCS11\fP 
.RE
For example, this command lists the contents of the configured PKCS#11 token: 
.RS 3

.LP
.nf
\f3
.fl
   jarsigner \-keystore NONE \-storetype PKCS11 \-list
.fl
  
.fl
\fP
.fi
.RE
.TP 3
\-storetype storetype 
Specifies the type of keystore to be instantiated. The default keystore type is the one that is specified as the value of the "keystore.type" property in the security properties file, which is returned by the static \f2getDefaultType\fP method in \f2java.security.KeyStore\fP. 
.LP
The PIN for a PCKS#11 token can also be specified using the \f2\-storepass\fP option. If none has been specified, keytool and jarsigner will prompt for the token PIN. If the token has a protected authentication path (such as a dedicated PIN\-pad or a biometric reader), then the \f2\-protected\fP option must be specified and no password options can be specified.  
.TP 3
\-storepass password 
Specifies the password which is required to access the keystore. This is only needed when signing (not verifying) a JAR file. In that case, if a \f2\-storepass\fP option is not provided at the command line, the user is prompted for the password. 
.LP
T
tbell 已提交
519
Note: The password shouldn't be specified on the command line or in a script unless it is for testing purposes, or you are on a secure system.  
D
duke 已提交
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542
.TP 3
\-keypass password 
Specifies the password used to protect the private key of the keystore entry addressed by the alias specified on the command line. The password is required when using \f3jarsigner\fP to sign a JAR file. If no password is provided on the command line, and the required password is different from the store password, the user is prompted for it. 
.LP
Note: The password shouldn't be specified on the command line or in a script unless it is for testing purposes, or you are on a secure system. Also, when typing in a password at the password prompt, the password is echoed (displayed exactly as typed), so be careful not to type it in front of anyone.  
.TP 3
\-sigfile file 
Specifies the base file name to be used for the generated .SF and .DSA files. For example, if \f2file\fP is "DUKESIGN", the generated .SF and .DSA files will be named "DUKESIGN.SF" and "DUKESIGN.DSA", and will be placed in the "META\-INF" directory of the signed JAR file. 
.LP
The characters in \f2file\fP must come from the set "a\-zA\-Z0\-9_\-". That is, only letters, numbers, underscore, and hyphen characters are allowed. Note: All lowercase characters will be converted to uppercase for the .SF and .DSA file names. 
.LP
If no \f2\-sigfile\fP option appears on the command line, the base file name for the .SF and .DSA files will be the first 8 characters of the alias name specified on the command line, all converted to upper case. If the alias name has fewer than 8 characters, the full alias name is used. If the alias name contains any characters that are not legal in a signature file name, each such character is converted to an underscore ("_") character in forming the file name.  
.TP 3
\-sigalg algorithm 
.RS 3

.LP
Specifies the name of the signature algorithm to use to sign the JAR file. 
.LP
See 
.na
\f2Appendix A\fP @
.fi
543
http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#AppA of the Java Cryptography Architecture for a list of standard signature algorithm names. This algorithm must be compatible with the private key used to sign the JAR file. If this option is not specified, SHA1withDSA or SHA256withRSA will be used depending on the type of private key. There must either be a statically installed provider supplying an implementation of the specified algorithm or the user must specify one with the \f2\-providerClass\fP option, otherwise the command will not succeed.
D
duke 已提交
544 545 546 547 548 549 550 551 552 553 554
.LP
.RE
.TP 3
\-digestalg algorithm 
.RS 3
Specifies the name of the message digest algorithm to use when digesting the entries of a jar file. 
.LP
See 
.na
\f2Appendix A\fP @
.fi
555
http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html#AppA of the Java Cryptography Architecture for a list of standard message digest algorithm names. If this option is not specified, SHA\-256 will be used. There must either be a statically installed provider supplying an implementation of the specified algorithm or the user must specify one with the \f2\-providerClass\fP option, otherwise the command will not succeed.
D
duke 已提交
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588
.LP
.RE
.TP 3
\-signedjar file 
Specifies the name to be used for the signed JAR file. 
.LP
If no name is specified on the command line, the name used is the same as the input JAR file name (the name of the JAR file to be signed); in other words, that file is overwritten with the signed JAR file.  
.TP 3
\-verify 
If this appears on the command line, the specified JAR file will be verified, not signed. If the verification is successful, "jar verified" will be displayed. If you try to verify an unsigned JAR file, or a JAR file signed with an unsupported algorithm (e.g., RSA when you don't have an RSA provider installed), the following is displayed: "jar is unsigned. (signatures missing or not parsable)" 
.LP
It is possible to verify JAR files signed using either \f3jarsigner\fP or the JDK 1.1 \f3javakey\fP tool, or both. 
.LP
For further information on verification, see JAR File Verification.  
.TP 3
\-certs 
If this appears on the command line, along with the \f2\-verify\fP and \f2\-verbose\fP options, the output includes certificate information for each signer of the JAR file. This information includes 
.RS 3
.TP 2
o
the name of the type of certificate (stored in the .DSA file) that certifies the signer's public key 
.TP 2
o
if the certificate is an X.509 certificate (more specifically, an instance of \f2java.security.cert.X509Certificate\fP): the distinguished name of the signer 
.RE
.LP
The keystore is also examined. If no keystore value is specified on the command line, the default keystore file (if any) will be checked. If the public key certificate for a signer matches an entry in the keystore, then the following information will also be displayed: 
.RS 3
.TP 2
o
in parentheses, the alias name for the keystore entry for that signer. If the signer actually comes from a JDK 1.1 identity database instead of from a keystore, the alias name will appear in brackets instead of parentheses. 
.RE
.TP 3
T
tbell 已提交
589 590 591
\-certchain file 
Specifies the certificate chain to be used, if the certificate chain associated with the private key of the keystore entry, addressed by the alias specified on the command line, is not complete. This may happen if the keystore is located on a hardware token where there is not enough capacity to hold a complete certificate chain. The file can be a sequence of X.509 certificates concatenated together, or a single PKCS#7 formatted data block, either in binary encoding format or in printable encoding format (also known as BASE64 encoding) as defined by the Internet RFC 1421 standard. 
.TP 3
D
duke 已提交
592 593 594 595 596 597 598 599 600 601 602 603 604
\-verbose 
If this appears on the command line, it indicates "verbose" mode, which causes \f3jarsigner\fP to output extra information as to the progress of the JAR signing or verification. 
.TP 3
\-internalsf 
In the past, the .DSA (signature block) file generated when a JAR file was signed used to include a complete encoded copy of the .SF file (signature file) also generated. This behavior has been changed. To reduce the overall size of the output JAR file, the .DSA file by default doesn't contain a copy of the .SF file anymore. But if \f2\-internalsf\fP appears on the command line, the old behavior is utilized. \f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP 
.TP 3
\-sectionsonly 
If this appears on the command line, the .SF file (signature file) generated when a JAR file is signed does \f2not\fP include a header containing a hash of the whole manifest file. It just contains information and hashes related to each individual source file included in the JAR file, as described in The Signature (.SF) File . 
.LP
By default, this header is added, as an optimization. When the header is present, then whenever the JAR file is verified, the verification can first check to see whether or not the hash in the header indeed matches the hash of the whole manifest file. If so, verification proceeds to the next step. If not, it is necessary to do a less optimized verification that the hash in each source file information section in the .SF file equals the hash of its corresponding section in the manifest file. 
.LP
For further information, see JAR File Verification. 
.LP
T
tbell 已提交
605
\f3This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.\fP  
D
duke 已提交
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
.TP 3
\-protected 
Either \f2true\fP or \f2false\fP. This value should be specified as \f2true\fP if a password must be given via a protected authentication path such as a dedicated PIN reader. 
.RE
.RS 3
.TP 3
\-provider provider\-class\-name 
Used to specify the name of cryptographic service provider's master class file when the service provider is not listed in the security properties file, \f2java.security\fP. 
.LP
Used in conjunction with the \f2\-providerArg\fP \f2ConfigFilePath\fP option, keytool and jarsigner will install the provider dynamically (where \f2ConfigFilePath\fP is the path to the token configuration file). Here's an example of a command to list a PKCS#11 keystore when the Sun PKCS#11 provider has not been configured in the security properties file. 
.RS 3

.LP
.nf
\f3
.fl
T
tbell 已提交
622
jarsigner \-keystore NONE \-storetype PKCS11 \\ 
D
duke 已提交
623
.fl
T
tbell 已提交
624
          \-providerClass sun.security.pkcs11.SunPKCS11 \\ 
D
duke 已提交
625
.fl
T
tbell 已提交
626
          \-providerArg /foo/bar/token.config \\ 
D
duke 已提交
627 628 629 630 631 632 633 634 635 636 637 638 639 640
.fl
          \-list
.fl
\fP
.fi
.RE
.TP 3
\-providerName providerName 
If more than one provider has been configured in the \f2java.security\fP security properties file, you can use the \f2\-providerName\fP option to target a specific provider instance. The argument to this option is the name of the provider. 
.LP
For the Sun PKCS#11 provider, \f2providerName\fP is of the form \f2SunPKCS11\-\fP\f2TokenName\fP, where \f2TokenName\fP is the name suffix that the provider instance has been configured with, as detailed in the 
.na
\f2configuration attributes table\fP @
.fi
T
tbell 已提交
641
http://java.sun.com/javase/6/docs/technotes/guides/security/p11guide.html#ATTRS. For example, the following command lists the contents of the PKCS#11 keystore provider instance with name suffix \f2SmartCard\fP: 
D
duke 已提交
642 643 644 645 646 647
.RS 3

.LP
.nf
\f3
.fl
T
tbell 已提交
648
jarsigner \-keystore NONE \-storetype PKCS11 \\ 
D
duke 已提交
649
.fl
T
tbell 已提交
650
        \-providerName SunPKCS11\-SmartCard \\ 
D
duke 已提交
651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707
.fl
        \-list
.fl
\fP
.fi
.RE
.TP 3
\-Jjavaoption 
Passes through the specified \f2javaoption\fP string directly to the Java interpreter. (\f3jarsigner\fP is actually a "wrapper" around the interpreter.) This option should not contain any spaces. It is useful for adjusting the execution environment or memory usage. For a list of possible interpreter options, type \f2java \-h\fP or \f2java \-X\fP at the command line. 
.LP
.TP 3
\-tsa url 
If \f2"\-tsa http://example.tsa.url"\fP appears on the command line when signing a JAR file then a timestamp is generated for the signature. The URL, \f2http://example.tsa.url\fP, identifies the location of the Time Stamping Authority (TSA). It overrides any URL found via the \f2\-tsacert\fP option. The \f2\-tsa\fP option does not require the TSA's public key certificate to be present in the keystore. 
.LP
To generate the timestamp, \f2jarsigner\fP communicates with the TSA using the Time\-Stamp Protocol (TSP) defined in 
.na
\f2RFC 3161\fP @
.fi
http://www.ietf.org/rfc/rfc3161.txt. If successful, the timestamp token returned by the TSA is stored along with the signature in the signature block file. 
.LP
.TP 3
\-tsacert alias 
If \f2"\-tsacert alias"\fP appears on the command line when signing a JAR file then a timestamp is generated for the signature. The \f2alias\fP identifies the TSA's public key certificate in the keystore that is currently in effect. The entry's certificate is examined for a Subject Information Access extension that contains a URL identifying the location of the TSA. 
.LP
The TSA's public key certificate must be present in the keystore when using \f2\-tsacert\fP. 
.LP
.TP 3
\-altsigner class 
Specifies that an alternative signing mechanism be used. The fully\-qualified class name identifies a class file that extends the \f2com.sun.jarsigner.ContentSigner abstract class\fP. The path to this class file is defined by the \f2\-altsignerpath\fP option. If the \f2\-altsigner\fP option is used, \f2jarsigner\fP uses the signing mechanism provided by the specified class. Otherwise, \f2jarsigner\fP uses its default signing mechanism. 
.LP
For example, to use the signing mechanism provided by a class named \f2com.sun.sun.jarsigner.AuthSigner\fP, use the \f2jarsigner\fP option \f2"\-altsigner com.sun.jarsigner.AuthSigner"\fP 
.LP
.TP 3
\-altsignerpath classpathlist 
Specifies the path to the class file (the class file name is specified with the \f2\-altsigner\fP option described above) and any JAR files it depends on. If the class file is in a JAR file, then this specifies the path to that JAR file, as shown in the example below. 
.LP
An absolute path or a path relative to the current directory may be specified. If \f2classpathlist\fP contains multiple paths or JAR files, they should be separated with a colon (\f2:\fP) on Solaris and a semi\-colon (\f2;\fP) on Windows. This option is not necessary if the class is already in the search path. 
.LP
Example of specifying the path to a jar file that contains the class file: 
.RS 3

.LP
.LP
\f2\-altsignerpath /home/user/lib/authsigner.jar\fP
.LP
.RE
.LP
Note that the JAR file name is included. 
.LP
Example of specifying the path to the jar file that contains the class file: 
.RS 3
.LP
\f2\-altsignerpath /home/user/classes/com/sun/tools/jarsigner/\fP
.LP
.RE
.LP
Note that the JAR file name is omitted.  
T
tbell 已提交
708 709 710 711 712 713
.TP 3
\-strict 
During the signing or verifying process, some warning messages may be shown. If this option appears on the command line, the exit code of the tool will reflect the warning messages that are found. Read the "WARNINGS" section for details. 
.TP 3
\-verbose:sub\-options 
For the verifying process, the \f2\-verbose\fP option takes sub\-options to determine how much information will be shown. If \f2\-certs\fP is also specified, the default mode (or sub\-option all) displays each entry as it is being processed and following that, the certificate information for each signer of the JAR file. If \f2\-certs\fP and the \f2\-verbose:grouped\fP sub\-option are specified, entries with the same signer info are grouped and displayed together along with their certificate information. If \f2\-certs\fP and the \f2\-verbose:summary\fP sub\-option are specified, then entries with the same signer info are grouped and displayed together along with their certificate information but details about each entry are summarized and displayed as "one entry (and more)". See the examples section for more information. 
D
duke 已提交
714 715 716 717 718 719 720 721 722 723 724 725
.RE
.SH "EXAMPLES"
.LP

.LP
.SS 
Signing a JAR File
.LP
.RS 3

.LP
.LP
T
tbell 已提交
726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965
Suppose you have a JAR file named "bundle.jar" and you'd like to sign it using the private key of the user whose keystore alias is "jane" in the keystore named "mystore" in the "working" directory. Suppose the keystore password is "myspass" and the password for \f2jane\fP's private key is "j638klm". You can use the following to sign the JAR file and name the signed JAR file "sbundle.jar":
.LP
.nf
\f3
.fl
    jarsigner \-keystore /working/mystore \-storepass myspass
.fl
      \-keypass j638klm \-signedjar sbundle.jar bundle.jar jane 
.fl
\fP
.fi

.LP
.LP
Note that there is no \f2\-sigfile\fP specified in the command above, so the generated .SF and .DSA files to be placed in the signed JAR file will have default names based on the alias name. That is, they will be named \f2JANE.SF\fP and \f2JANE.DSA\fP.
.LP
.LP
If you want to be prompted for the store password and the private key password, you could shorten the above command to
.LP
.nf
\f3
.fl
    jarsigner \-keystore /working/mystore
.fl
      \-signedjar sbundle.jar bundle.jar jane 
.fl
\fP
.fi

.LP
.LP
If the keystore to be used is the default keystore (the one named ".keystore" in your home directory), you don't need to specify a keystore, as in:
.LP
.nf
\f3
.fl
    jarsigner \-signedjar sbundle.jar bundle.jar jane 
.fl
\fP
.fi

.LP
.LP
Finally, if you want the signed JAR file to simply overwrite the input JAR file (\f2bundle.jar\fP), you don't need to specify a \f2\-signedjar\fP option:
.LP
.nf
\f3
.fl
    jarsigner bundle.jar jane 
.fl
\fP
.fi
.RE

.LP
.SS 
Verifying a Signed JAR File
.LP
.RS 3

.LP
.LP
To verify a signed JAR file, that is, to verify that the signature is valid and the JAR file has not been tampered with, use a command such as the following:
.LP
.nf
\f3
.fl
    jarsigner \-verify sbundle.jar 
.fl
\fP
.fi

.LP
.LP
If the verification is successful,
.LP
.nf
\f3
.fl
    jar verified.
.fl
\fP
.fi

.LP
.LP
is displayed. Otherwise, an error message appears.
.LP
.LP
You can get more information if you use the \f2\-verbose\fP option. A sample use of \f3jarsigner\fP with the \f2\-verbose\fP option is shown below, along with sample output:
.LP
.nf
\f3
.fl
    jarsigner \-verify \-verbose sbundle.jar
.fl

.fl
           198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
.fl
           199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
.fl
          1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
.fl
    smk   2752 Fri Sep 26 16:12:30 PDT 1997 AclEx.class
.fl
    smk    849 Fri Sep 26 16:12:46 PDT 1997 test.class
.fl

.fl
      s = signature was verified
.fl
      m = entry is listed in manifest
.fl
      k = at least one certificate was found in keystore
.fl

.fl
    jar verified.
.fl
\fP
.fi

.LP
.SS 
Verification with Certificate Information
.LP
.LP
If you specify the \f2\-certs\fP option when verifying, along with the \f2\-verify\fP and \f2\-verbose\fP options, the output includes certificate information for each signer of the JAR file, including the certificate type, the signer distinguished name information (iff it's an X.509 certificate), and, in parentheses, the keystore alias for the signer if the public key certificate in the JAR file matches that in a keystore entry. For example,
.LP
.nf
\f3
.fl
    jarsigner \-keystore /working/mystore \-verify \-verbose \-certs myTest.jar
.fl

.fl
           198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
.fl
           199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
.fl
          1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
.fl
           208 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST.SF
.fl
          1087 Fri Sep 26 16:23:30 PDT 1997 META\-INF/JAVATEST.DSA
.fl
    smk   2752 Fri Sep 26 16:12:30 PDT 1997 Tst.class
.fl

.fl
      X.509, CN=Test Group, OU=Java Software, O=Sun Microsystems, L=CUP, S=CA, C=US (javatest)
.fl
      X.509, CN=Jane Smith, OU=Java Software, O=Sun, L=cup, S=ca, C=us (jane)
.fl

.fl
      s = signature was verified
.fl
      m = entry is listed in manifest
.fl
      k = at least one certificate was found in keystore
.fl

.fl
    jar verified.
.fl
\fP
.fi

.LP
.LP
If the certificate for a signer is not an X.509 certificate, there is no distinguished name information. In that case, just the certificate type and the alias are shown. For example, if the certificate is a PGP certificate, and the alias is "bob", you'd get
.LP
.nf
\f3
.fl
      PGP, (bob)
.fl
\fP
.fi

.LP
.SS 
Verification of a JAR File that Includes Identity Database Signers
.LP
.LP
If a JAR file has been signed using the JDK 1.1 \f3javakey\fP tool, and thus the signer is an alias in an identity database, the verification output includes an "i" symbol. If the JAR file has been signed by both an alias in an identity database and an alias in a keystore, both "k" and "i" appear.
.LP
.LP
When the \f2\-certs\fP option is used, any identity database aliases are shown in square brackets rather than the parentheses used for keystore aliases. For example:
.LP
.nf
\f3
.fl
    jarsigner \-keystore /working/mystore \-verify \-verbose \-certs writeFile.jar
.fl

.fl
           198 Fri Sep 26 16:14:06 PDT 1997 META\-INF/MANIFEST.MF
.fl
           199 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.SF
.fl
          1013 Fri Sep 26 16:22:10 PDT 1997 META\-INF/JANE.DSA
.fl
           199 Fri Sep 27 12:22:30 PDT 1997 META\-INF/DUKE.SF
.fl
          1013 Fri Sep 27 12:22:30 PDT 1997 META\-INF/DUKE.DSA
.fl
   smki   2752 Fri Sep 26 16:12:30 PDT 1997 writeFile.html
.fl

.fl
      X.509, CN=Jane Smith, OU=Java Software, O=Sun, L=cup, S=ca, C=us (jane)
.fl
      X.509, CN=Duke, OU=Java Software, O=Sun, L=cup, S=ca, C=us [duke]
.fl

.fl
      s = signature was verified
.fl
      m = entry is listed in manifest
.fl
      k = at least one certificate was found in keystore
.fl
      i = at least one certificate was found in identity scope
.fl

.fl
    jar verified.
.fl
\fP
.fi

.LP
.LP
Note that the alias "duke" is in brackets to denote that it is an identity database alias, not a keystore alias.
.LP
.RE
.SH "WARNINGS"
D
duke 已提交
966
.LP
T
tbell 已提交
967 968 969

.LP
During the signing/verifying process, jarsigner may display various warnings. These warning codes are defined as follows: 
D
duke 已提交
970 971 972
.nf
\f3
.fl
T
tbell 已提交
973
         hasExpiringCert         2
D
duke 已提交
974
.fl
T
tbell 已提交
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035
             This jar contains entries whose signer certificate will expire within six months
.fl

.fl
         hasExpiredCert          4
.fl
             This jar contains entries whose signer certificate has expired.
.fl
         
.fl
         notYetValidCert         4
.fl
             This jar contains entries whose signer certificate is not yet valid.
.fl
         
.fl
         chainNotValidated       4
.fl
             This jar contains entries whose certificate chain cannot be correctly validated.
.fl
         
.fl
         badKeyUsage             8
.fl
             This jar contains entries whose signer certificate's KeyUsage extension doesn't allow code signing.
.fl
         
.fl
         badExtendedKeyUsage     8
.fl
             This jar contains entries whose signer certificate's ExtendedKeyUsage extension
.fl
             doesn't allow code signing.
.fl
         
.fl
         badNetscapeCertType     8
.fl
             This jar contains entries whose signer certificate's NetscapeCertType extension 
.fl
             doesn't allow code signing.
.fl
         
.fl
         hasUnsignedEntry        16
.fl
             This jar contains unsigned entries which have not been integrity\-checked.
.fl
         
.fl
         notSignedByAlias        32
.fl
             This jar contains signed entries which are not signed by the specified alias(es)
.fl
         
.fl
         aliasNotInStore         32
.fl
             This jar contains signed entries that are not signed by alias in this keystore
.fl
   
D
duke 已提交
1036 1037 1038 1039 1040 1041
.fl
\fP
.fi

.LP
.LP
T
tbell 已提交
1042
When the \f2\-strict\fP option is provided, an OR\-value of warnings detected will be returned as the exit code of the tool. For example, if a certificate used to sign an entry is expired and has a keyUsage extension that does not allow it to sign a file, an exit code 12 (=4+8) will be returned.
D
duke 已提交
1043 1044
.LP
.LP
T
tbell 已提交
1045
\f3Note\fP: Exit codes are reused because only 0\-255 is legal for Unix. In any case, if the signing/verifying process fails, the exit code
D
duke 已提交
1046 1047 1048 1049
.LP
.nf
\f3
.fl
T
tbell 已提交
1050
failure                 1 
D
duke 已提交
1051 1052 1053 1054 1055
.fl
\fP
.fi

.LP
T
tbell 已提交
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
will be returned. 
.SS 
Compatibility with JDK 1.1
.LP
.RS 3

.LP
.LP
The \f3keytool\fP and \f3jarsigner\fP tools completely replace the \f3javakey\fP tool provided in JDK 1.1. These new tools provide more features than \f3javakey\fP, including the ability to protect the keystore and private keys with passwords, and the ability to verify signatures in addition to generating them.
.LP
.LP
The new keystore architecture replaces the identity database that \f3javakey\fP created and managed. There is no backwards compatibility between the keystore format and the database format used by \f3javakey\fP in 1.1. However,
.LP
.RS 3
.TP 2
o
It is possible to import the information from an identity database into a keystore, via the \f3keytool\fP \f2\-identitydb\fP command. 
.TP 2
o
\f3jarsigner\fP can sign JAR files also previously signed using \f3javakey\fP. 
.TP 2
o
\f3jarsigner\fP can verify JAR files signed using \f3javakey\fP. Thus, it recognizes and can work with signer aliases that are from a JDK 1.1 identity database rather than a Java 2 SDK keystore. 
.RE

.LP
.LP
The following table explains how JAR files that were signed in JDK 1.1.x are treated in the Java 2 platform.
D
duke 已提交
1084 1085
.LP
.LP
T
tbell 已提交
1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
.TS
.if \n+(b.=1 .nr d. \n(.c-\n(c.-1
.de 35
.ps \n(.s
.vs \n(.vu
.in \n(.iu
.if \n(.u .fi
.if \n(.j .ad
.if \n(.j=0 .na
..
.nf
.nr #~ 0
.if n .nr #~ 0.6n
.ds #d .d
.if \(ts\n(.z\(ts\(ts .ds #d nl
.fc
.nr 33 \n(.s
.rm 80 81 82 83 84
.nr 34 \n(.lu
.eo
.am 82
.br
.di a+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(82 .ll \n(82u
.in 0
\f3Trusted Identity imported into Java 2 Platform keystore from 1.1 database (4)\fP
.br
.di
.nr a| \n(dn
.nr a- \n(dl
..
.ec \
.eo
.am 83
.br
.di b+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(83 .ll \n(83u
.in 0
\f3Policy File grants privileges to Identity/Alias\fP
.br
.di
.nr b| \n(dn
.nr b- \n(dl
..
.ec \
.eo
.am 84
.br
.di c+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code.
.br
.di
.nr c| \n(dn
.nr c- \n(dl
..
.ec \
.eo
.am 84
.br
.di d+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code.
.br
.di
.nr d| \n(dn
.nr d- \n(dl
..
.ec \
.eo
.am 84
.br
.di e+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code.
.br
.di
.nr e| \n(dn
.nr e- \n(dl
..
.ec \
.eo
.am 84
.br
.di f+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code. (3)
.br
.di
.nr f| \n(dn
.nr f- \n(dl
..
.ec \
.eo
.am 84
.br
.di g+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code. (1,3)
.br
.di
.nr g| \n(dn
.nr g- \n(dl
..
.ec \
.eo
.am 84
.br
.di h+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code plus privileges granted in policy file.
.br
.di
.nr h| \n(dn
.nr h- \n(dl
..
.ec \
.eo
.am 84
.br
.di i+
.35
.ft \n(.f
.ll \n(34u*1u/6u
.if \n(.l<\n(84 .ll \n(84u
.in 0
Default privileges granted to all code plus privileges granted in policy file. (2)
.br
.di
.nr i| \n(dn
.nr i- \n(dl
..
.ec \
.35
.nf
.ll \n(34u
.nr 80 0
.nr 38 \w\f3JAR File Type\fP
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wUnsigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.nr 38 \wSigned JAR
.if \n(80<\n(38 .nr 80 \n(38
.80
.rm 80
.nr 81 0
.nr 38 \w\f3Identity in 1.1 database\fP
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wNO
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wNO
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wNO
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wYES/Untrusted
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wYES/Untrusted
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wNO
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wYES/Trusted
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wYES/Trusted
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wYES/Trusted
.if \n(81<\n(38 .nr 81 \n(38
.nr 38 \wYES/Trusted
.if \n(81<\n(38 .nr 81 \n(38
.81
.rm 81
.nr 82 0
.nr 38 \wNO
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wNO
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wYES
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wNO
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wNO
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wYES
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wYES
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wNO
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wYES
.if \n(82<\n(38 .nr 82 \n(38
.nr 38 \wNO
.if \n(82<\n(38 .nr 82 \n(38
.82
.rm 82
.nr 38 \n(a-
.if \n(82<\n(38 .nr 82 \n(38
.nr 83 0
.nr 38 \wNO
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wNO
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wNO
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wNO
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wYES
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wYES
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wYES
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wNO
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wNO
.if \n(83<\n(38 .nr 83 \n(38
.nr 38 \wYES
.if \n(83<\n(38 .nr 83 \n(38
.83
.rm 83
.nr 38 \n(b-
.if \n(83<\n(38 .nr 83 \n(38
.nr 84 0
.nr 38 \w\f3Privileges Granted\fP
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \wAll privileges
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \wAll privileges (1)
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \wAll privileges (1)
.if \n(84<\n(38 .nr 84 \n(38
.84
.rm 84
.nr 38 \n(c-
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \n(d-
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \n(e-
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \n(f-
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \n(g-
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \n(h-
.if \n(84<\n(38 .nr 84 \n(38
.nr 38 \n(i-
.if \n(84<\n(38 .nr 84 \n(38
.35
D
duke 已提交
1378
.nf
T
tbell 已提交
1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392
.ll \n(34u
.nr 38 1n
.nr 79 0
.nr 40 \n(79+(0*\n(38)
.nr 80 +\n(40
.nr 41 \n(80+(3*\n(38)
.nr 81 +\n(41
.nr 42 \n(81+(3*\n(38)
.nr 82 +\n(42
.nr 43 \n(82+(3*\n(38)
.nr 83 +\n(43
.nr 44 \n(83+(3*\n(38)
.nr 84 +\n(44
.nr TW \n(84
1393
.if t .if \n(TW>\n(.li .tm Table at line 1128 file Input is too wide - \n(TW units
T
tbell 已提交
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570
.fc  
.nr #T 0-1
.nr #a 0-1
.eo
.de T#
.ds #d .d
.if \(ts\n(.z\(ts\(ts .ds #d nl
.mk ##
.nr ## -1v
.ls 1
.ls
..
.ec
.ne \n(a|u+\n(.Vu
.ne \n(b|u+\n(.Vu
.if (\n(a|+\n(#^-1v)>\n(#- .nr #- +(\n(a|+\n(#^-\n(#--1v)
.if (\n(b|+\n(#^-1v)>\n(#- .nr #- +(\n(b|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'\f3JAR File Type\fP\h'|\n(41u'\f3Identity in 1.1 database\fP\h'|\n(42u'\h'|\n(43u'\h'|\n(44u'\f3Privileges Granted\fP
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(42u
.in +\n(37u
.a+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(##u-1v
.nr 37 \n(43u
.in +\n(37u
.b+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(c|u+\n(.Vu
.if (\n(c|+\n(#^-1v)>\n(#- .nr #- +(\n(c|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.c+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(d|u+\n(.Vu
.if (\n(d|+\n(#^-1v)>\n(#- .nr #- +(\n(d|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Unsigned JAR\h'|\n(41u'NO\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.d+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(e|u+\n(.Vu
.if (\n(e|+\n(#^-1v)>\n(#- .nr #- +(\n(e|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'YES\h'|\n(43u'NO\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.e+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(f|u+\n(.Vu
.if (\n(f|+\n(#^-1v)>\n(#- .nr #- +(\n(f|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Untrusted\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.f+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(g|u+\n(.Vu
.if (\n(g|+\n(#^-1v)>\n(#- .nr #- +(\n(g|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Untrusted\h'|\n(42u'NO\h'|\n(43u'YES\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.g+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(h|u+\n(.Vu
.if (\n(h|+\n(#^-1v)>\n(#- .nr #- +(\n(h|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'NO\h'|\n(42u'YES\h'|\n(43u'YES\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.h+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ne \n(i|u+\n(.Vu
.if (\n(i|+\n(#^-1v)>\n(#- .nr #- +(\n(i|+\n(#^-\n(#--1v)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'YES\h'|\n(43u'YES\h'|\n(44u'
.mk ##
.nr 31 \n(##
.sp |\n(##u-1v
.nr 37 \n(44u
.in +\n(37u
.i+
.in -\n(37u
.mk 32
.if \n(32>\n(31 .nr 31 \n(32
.sp |\n(31u
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'NO\h'|\n(43u'NO\h'|\n(44u'All privileges
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'YES\h'|\n(43u'NO\h'|\n(44u'All privileges (1)
.ta \n(80u \n(81u \n(82u \n(83u \n(84u 
.nr 31 \n(.f
.nr 35 1m
\&\h'|\n(40u'Signed JAR\h'|\n(41u'YES/Trusted\h'|\n(42u'NO\h'|\n(43u'YES\h'|\n(44u'All privileges (1)
.fc
.nr T. 1
.T# 1
.35
.rm a+
.rm b+
.rm c+
.rm d+
.rm e+
.rm f+
.rm g+
.rm h+
.rm i+
.TE
.if \n-(b.=0 .nr c. \n(.c-\n(d.-42
D
duke 已提交
1571 1572 1573

.LP
.LP
T
tbell 已提交
1574
Notes:
D
duke 已提交
1575 1576
.LP
.RS 3
T
tbell 已提交
1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589
.TP 3
1.
If an identity/alias is mentioned in the policy file, it must be imported into the keystore for the policy file to have any effect on privileges granted. 
.TP 3
2.
The policy file/keystore combination has precedence over a trusted identity in the identity database. 
.TP 3
3.
Untrusted identities are ignored in the Java 2 platform. 
.TP 3
4.
Only trusted identities can be imported into Java 2 SDK keystores. 
.RE
D
duke 已提交
1590 1591 1592 1593 1594 1595 1596 1597 1598

.LP
.SH "SEE ALSO"
.LP

.LP
.RS 3
.TP 2
o
T
tbell 已提交
1599
jar(1) tool documentation 
D
duke 已提交
1600 1601
.TP 2
o
T
tbell 已提交
1602
keytool(1) tool documentation 
D
duke 已提交
1603 1604 1605 1606 1607 1608
.TP 2
o
the 
.na
\f4Security\fP @
.fi
T
tbell 已提交
1609
http://java.sun.com/docs/books/tutorial/security/index.html trail of the 
D
duke 已提交
1610 1611 1612
.na
\f4Java Tutorial\fP @
.fi
T
tbell 已提交
1613
http://java.sun.com/docs/books/tutorial/index.html for examples of the use of the \f3jarsigner\fP tool 
D
duke 已提交
1614 1615 1616
.RE

.LP
T
tbell 已提交
1617
.RE
D
duke 已提交
1618