NAME
jarsigner - JAR signing and verification tool
SYNOPSIS
jjaarrssiiggnneerr [ options ] jar-file alias
jjaarrssiiggnneerr -vveerriiffyy [ options ] jar-file alias
DESCRIPTION
The jjaarrssiiggnneerr tool is used for two purposes: 1. to sign Java ARchive (JAR) files, and 2. to verify the signatures and integrity of signed JAR files. The JAR feature enables the packaging of class files, images, sounds,and other digital data in a single file for faster and easier distribu-
tion. A tool named jjaarr enables developers to produce JAR files. 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, etc.). Like a handwritten signature, a digital signature has many useful characteristics: +o Its authenticity can be verified, via a computation that uses thepublic key corresponding to the private key used to generate the sig-
nature. +o It cannot be forged, assuming the private key is kept secret. +o It is a function of the data signed and thus can't be claimed to be the signature for other data as well. +o The signed data cannot be changed; if it is, the signature will no longer verify as being authentic. 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 cer-
tificate is a digitally signed statement from one entity, saying that the public key of some other entity has a particular value.jjaarrssiiggnneerr uses key and certificate information from a keystore to gen-
erate digital signatures for JAR files. A keystore is a database ofprivate keys and their associated X.509 certificate chains authenticat-
ing the corresponding public keys. The kkeeyyttooooll utility is used to cre-
ate and administer keystores. jjaarrssiiggnneerr 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. jjaarrssiiggnneerr can verify the digital signature of the signed JAR file using the certificate inside it (in its signature block file). At this time, jjaarrssiiggnneerr can only sign JAR files created by the JDK jjaarr tool or zip files. (JAR files are the same as zip files, except theyalso have a MMEETTAA-IINNFF//MMAANNIIFFEESSTT..MMFF file. Such a file will automatically
be created when jjaarrssiiggnneerr signs a zip file.)The default jjaarrssiiggnneerr behavior is to sign a JAR file. Use the -vveerriiffyy
option to instead have it verify a signed JAR file. CCoommppaattiibbiilliittyy wwiitthh JJDDKK 11..11 The kkeeyyttooooll and jjaarrssiiggnneerr tools completely replace the jjaavvaakkeeyy tool provided in JDK 1.1. These new tools provide more features than jjaavvaakkeeyy, including the ability to protect the keystore and private keys with passwords, and the ability to verify signatures in addition to generating them. The new keystore architecture replaces the identity database that jjaavvaakkeeyy created and managed. There is no backwards compatibility between the keystore format and the database format used by jjaavvaakkeeyy in 1.1. However: +o It is possible to import the information from an identity databaseinto a keystore, via the kkeeyyttooooll -iiddeennttiittyyddbb command
+o jjaarrssiiggnneerr can sign JAR files also previously signed using jjaavvaakkeeyy+o jjaarrssiiggnneerr can verify JAR files signed using jjaavvaakkeeyy Thus, it recog-
nizes and can work with signer aliases that are from a JDK 1.1 iden-
tity database rather than a JDK 1.2 keystore. The following table explains how JAR files that were signed in JDK 1.1.x are treated in the Java 2 Platform. TTrruusstteedd IIddeennttiittyy iimmppoorrtteedd PPoolliiccyy FFiillee JJAARR FFiillee IIddeennttiittyy iinn iinnttoo 11..22 ggrraannttss PPrriivviilleeggeess TTyyppee 11..11 ddaattaabbaassee kkeeyyssttoorree pprriivviilleeggeess ttoo GGrraanntteedd ffrroomm 11..11 IIddeennttiittyy//AAlliiaass ddaattaabbaassee ((44)) SSiiggnneedd DDeeffaauulltt JJAARR NNOO NNOO NNOO pprriivvaalleeggeess ggrraanntteedd ttoo aallll ccooddee.. UUnnssiiggnneedd DDeeffaauulltt JJAARR NNOO NNOO NNOO pprriivviilleeggeess ggrraanntteedd ttoo aallll ccooddee.. SSiiggnneedd DDeeffaauulltt JJAARR NNOO YYEESS NNOO pprriivviilleeggeess ggrraanntteedd ttoo aallll ccooddee.. SSiiggnneedd DDeeffaauulltt JJAARR YYEESS//UUnnttrruusstteedd NNOO NNOO pprriivviilleeggeess ggrraanntteedd ttoo aallll ccooddee.. ((33)) SSiiggnneedd DDeeffaauulltt JJAARR YYEESS//UUnnttrruusstteedd NNOO YYEESS pprriivviilleeggeess ggrraanntteedd ttoo aallll ccooddee.. ((11,,33)) SSiiggnneedd DDeeffaauulltt JJAARR NNOO YYEESS YYEESS pprriivviilleeggeess ggrraanntteedd ttoo aallll ccooddee pplluuss pprriivviilleeggeess ggrraanntteedd iinn ppoolliiccyy ffiillee.. SSiiggnneedd DDeeffaauulltt JJAARR YYEESS//TTrruusstteedd YYEESS YYEESS pprriivviilleeggeess ggrraanntteedd ttoo aallll ccooddee pplluuss pprriivviilleeggeess ggrraanntteedd iinn ppoolliiccyy ffiillee.. ((22)) SSiiggnneedd AAllll JJAARR YYEESS//TTrruusstteedd NNOO NNOO pprriivviilleeggeess SSiiggnneedd AAllll JJAARR YYEESS//TTrruusstteedd YYEESS NNOO pprriivviilleeggeess ((11)) SSiiggnneedd AAllll JJAARR YYEESS//TTrruusstteedd NNOO YYEESS pprriivviilleeggeess ((11)) Notes: 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. 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. 2. The policy file/keystore combination has precedence over a trusted identity in the identity database. 3. Untrusted identities are ignored in the Java 2 platform. 4. Only trusted identities can be imported into Java 2 SDK keystores. KKeeyyssttoorree AAlliiaasseess All keystore entities are accessed via unique aliases. When using jjaarrssiiggnneerr 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 MMyyJJAARRFFiillee..jjaarr, using the private key associated with the alias dduukkee in the keystore named mmyyssttoorree in the "working" directory. Since no output file is specified, it overwrites MMyyJJAARRFFiillee..jjaarr with the signed JAR file.jjaarrssiiggnneerr -kkeeyyssttoorree //wwoorrkkiinngg//mmyyssttoorree -ssttoorreeppaassss
mmyyssppaassss -kkeeyyppaassss dduukkeekkeeyyppaasssswwdd MMyyJJAARRFFiillee..jjaarr dduukkee
Keystores are protected with a password, so the store password (in this case mmyyssppaassss) must be specified. You will be prompted for it if youdon't specify it on the command line. Similarly, private keys are pro-
tected in a keystore with a password, so the private key's password (in this case dduukkeekkeeyyppaasssswwdd) 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. KKeeyyssttoorree LLooccaattiioonnjjaarrssiiggnneerr has a -kkeeyyssttoorree option for specifying the name and location
of the keystore to be used. The keystore is by default stored in a file named ..kkeeyyssttoorree in the user's home directory, as determined by the uusseerr..hhoommee system property.Note that the input stream from the -keystore option is passed to the
KKeeyySSttoorree..llooaadd method. If NONE is specified as the URL, then a null stream is passed to the KKeeyySSttoorree..llooaadd method. NONE should be specifiedif the KeyStore is not file-based, for example, if it resides on a
hardware token device. KKeeyyssttoorree IImmpplleemmeennttaattiioonnThe KeyStore class provided in the jjaavvaa..sseeccuurriittyy package supplies well-
defined interfaces to access and modify the information in a keystore.It is possible for there to be multiple different concrete implementa-
tions, where each implementation is that for a particular type of key-
store.Currently, there are two command-line tools that make use of KKeeyySSttoorree:
kkeeyyttooooll and jjaarrssiiggnneerr, and also a GUI-based tool named ppoolliiccyyttooooll.
Since KKeeyySSttoorree is publicly available, JDK users can write additional security applications that use it.There is a built-in default implementation, provided by Sun Microsys-
tems. 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.Keystore implementations are provider-based. More specifically, the
application interfaces supplied by KKeeyySSttoorree are implemented in terms of a "Service Provider Interface" (SPI). That is, there is a corresponding abstract KKeeyyssttoorreeSSppii class, also in the jjaavvaa..sseeccuurriittyy package, which defines the Service Provider Interface methods that "providers" mustimplement. (The term "provider" refers to a package or a set of pack-
ages that supply a concrete implementation of a subset of services that can be accessed by the Java Security API.) Thus, to provide a keystoreimplementation, clients must implement a provider and supply a KKeeyy-
ssttoorreeSSppii subclass implementation, as described in How to Implement a Provider for the Java Cryptography Architecture. Applications can choose different types of keystore implementations from different providers, using the ggeettIInnssttaannccee factory method supplied in the KKeeyySSttoorree 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.kkeeyyttooooll 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 FFiilleeIInnppuuttSSttrreeaamm, from which it loads the keystore information.) The jjaarrssiiggnneerr and ppoolliiccyyttooooll tools, on the other hand, can read a keystore from any location that can be specified using a URL.For jjaarrssiiggnneerr and kkeeyyttooooll, you can specify a keystore type at the com-
mand line, via the -ssttoorreettyyppee option. For ppoolliiccyyttooooll, you can specify a
keystore type via the "Change Keystore" command in the Edit menu. If you don't explicitly specify a keystore type, the tools choose a keystore implementation based simply on the value of the kkeeyyssttoorree..ttyyppeeproperty specified in the security properties file. The security prop-
erties file is called jjaavvaa..sseeccuurriittyy, and it resides in the security properties directory, jjaavvaa..hhoommee//lliibb//sseeccuurriittyy, where jjaavvaa..hhoommee is the runtime environment's directory (the jre directory in the SDK or thetop-level directory of the Java 2 Runtime Environment).
Each tool gets the kkeeyyssttoorree..ttyyppee value and then examines all the cur-
rently-installed providers until it finds one that implements keystores
of that type. It then uses the keystore implementation from that provider. The KKeeyySSttoorree class defines a static method named ggeettDDeeffaauullttTTyyppee that lets applications and applets retrieve the value of the kkeeyyssttoorree..ttyyppee property. The following line of code creates an instance of the default keystore type (as specified in the kkeeyyssttoorree..ttyyppee property):KKeeyySSttoorree kkeeyySSttoorree == KKeeyySSttoorree..ggeettIInnssttaannccee((KKeeyySSttoorree..ggeettDDeeffaauulltt-
TTyyppee(())));;The default keystore type is "jks" (the proprietary type of the key-
store implementation provided by Sun). This is specified by the follow-
ing line in the security properties file: kkeeyyssttoorree..ttyyppee==jjkkss 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 kkeeyyssttoorree..ttyyppee==ppkkccss1122 Note: case doesn't matter in keystore type designations. For example, "JKS" would be considered the same as "jks". SSuuppppoorrtteedd AAllggoorriitthhmmss aanndd KKeeyy SSiizzeess At this time, jjaarrssiiggnneerr can sign a JAR file using either+o DSA (Digital Signature Algorithm) with the SHA-1 digest algorithm, or
+o the RSA algorithm with the MD5 digest algorithm.That is, if the signer's public and private keys are DSA keys, jjaarr-
ssiiggnneerr will attempt to sign the JAR file using the SHA-1/DSA algorithm.
If the signer's keys are RSA keys, jjaarrssiiggnneerr will sign the JAR fileusing the MD5/RSA algorithm. This is only possible if there is a stati-
cally installed provider supplying an implementation for the MD5/RSAalgorithm. (There is always a SHA-1/DSA algorithm available, from the
default "SUN" provider.) The Signed JAR File When jjaarrssiiggnneerr is used to sign a JAR file, the output signed JAR fileis exactly the same as the input JAR file, except that it has two addi-
tional files placed in the MMEETTAA-IINNFF directory:
+o a signature file, with a ..SSFF extension, and +o a signature block file, with a ..DDSSAA extension. The base file names for these two files come from the value of the-ssiiggFFiillee option. For example, if the option appears as
-ssiiggFFiillee MMKKSSIIGGNN
the files are named MMKKSSIIGGNN..SSFF and MMKKSSIIGGNN..DDSSAA.If no -ssiiggffiillee option appears on the command line, the base file name
for the ..SSFF and ..DDSSAA 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. Ifthe alias name contains any characters that are not allowed in a signa-
ture file name, each such character is converted to an underscore ("") character in forming the file name. Legal characters include letters, digits, underscores, and hyphens. The Signature (..SSFF) File A signature file (the ..SSFF file) looks similar to the manifest file that is always included in a JAR file generated by the jjaarr tool. That is, for each source file included in the JAR file, the ..SSFF file has three lines, just as in the manifest file, listing the following: +o the file name, +o the name of the digest algorithm used (SHA), and +o a SHA digest value. 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 ..SSFF 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. 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. The Signature Block (..DDSSAA) File The ..SSFF file is signed and the signature is placed in the ..DDSSAA file.The ..DDSSAA file also contains, encoded inside it, a certificate authenti-
cating the public key corresponding to the private key used for sign-
ing. JJAARR FFiillee VVeerriiffiiccaattiioonn A successful JAR file verification occurs if the signature(s) arevalid, and none of the files that were in the JAR file when the signa-
tures were generated have been changed since then. JAR file verifica-
tion involves the following steps: 1. Verify the signature of the ..SSFF file itself. That is, the verification ensures that the signature stored in each signature block (..DDSSAA) file was in fact generated using the private key corresponding to the public key whose certificate also appears in the ..DDSSAA file. It also ensures that the signature is a valid signature of the corresponding signature (..SSFF) file, and thus the ..SSFF file has not been tampered with. 2. Verify the digest listed in each entry in the ..SSFF file with each corresponding section in the manifest. The ..SSFF file by default includes a header containing a hash of theentire manifest file. When the header is present, then the verifi-
cation 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. 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 ..SSFF file equals the hash of its corresponding section in the manifest file (see The Signature (..SSFF) File). One reason the hash of the manifest file that is stored in the ..SSFF 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 jjaarr tool) after the signature (and thus the ..SSFF file)was generated. When the jjaarr tool is used to add files, the mani-
fest file is changed (sections are added to it for the new files),but the ..SSFF file is not. A verification is still considered suc-
cessful if none of the files that were in the JAR file when the signature was generated have been changed since then, which is thecase if the hashes in the non-header sections of the ..SSFF file
equal the hashes of the corresponding sections in the manifest file. 3. Read each file in the JAR file that has an entry in the ..SSFF 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. 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 jjaarrssiiggnneerr. MMuullttiippllee SSiiggnnaattuurreess ffoorr aa JJAARR FFiilleeA JAR file can be signed by multiple people simply by running the jjaarr-
ssiiggnneerr tool on the file multiple times, specifying the alias for a dif-
ferent person each time, as in: jjaarrssiiggnneerr mmyyBBuunnddllee..jjaarr ssuussaann jjaarrssiiggnneerr mmyyBBuunnddllee..jjaarr kkeevviinn When a JAR file is signed multiple times, there are multiple ..SSFF and ..DDSSAA 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: SSUUSSAANN..SSFF SSUUSSAANN..DDSSAA KKEEVVIINN..SSFF KKEEVVIINN..DDSSAA Note: It is also possible for a JAR file to have mixed signatures, somegenerated by the JDK 1.1 javakey tool and others by jarsigner. That is,
jarsigner can be used to sign JAR files already previously signed using
javakey. OOPPTTIIOONNSS The various jjaarrssiiggnneerr options are listed and described below. Note:+o All option names are preceded by a minus sign (-).
+o The options may be provided in any order. +o Items in italics (option values) represent the actual values that must be supplied.+o The -kkeeyyssttoorree, -ssttoorreeppaassss, -kkeeyyppaassss, -ssiiggffiillee, and -ssiiggnneeddjjaarr 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.-kkeeyyssttoorree url Specifies the URL that tells the keystore location. This
defaults to the file ..kkeeyyssttoorree in the user's home direc-
tory, as determined by the uusseerr..hhoommee system property.A keystore is required when signing, so you must explic-
itly specify one if the default keystore does not exist (or you want to use one other than the default). A keystore is not required when verifying, but if one isspecified, or the default exists, and the -vveerrbboossee
option was also specified, additional information is output regarding whether or not any of the certificatesused to verify the JAR file are contained in that key-
store.Note: the -kkeeyyssttoorree 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,-kkeeyyssttoorree ffiilleePPaatthhAAnnddNNaammee
is treated as equivalent to-kkeeyyssttoorree ffiillee::ffiilleePPaatthhAAnnddNNaammee
-ssttoorreettyyppee storetype
Specifies the type of keystore to be instantiated. The default keystore type is the one that is specified asthe value of the "keystore.type" property in the secu-
rity properties file, which is returned by the static ggeettDDeeffaauullttTTyyppee method in jjaavvaa..sseeccuurriittyy..KKeeyySSttoorree.-ssttoorreeppaassss password
Specifies the password which is required to access thekeystore. This is only needed when signing (not verify-
ing) a JAR file. In that case, if a -ssttoorreeppaassss option is
not provided at the command line, the user is prompted for the password. 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.-kkeeyyppaassss 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 jjaarrssiiggnneerr to sign a JAR file. If no password is providedon the command line, and the required password is dif-
ferent from the store password, the user is prompted for it. 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.-ssiiggffiillee file Specifies the base file name to be used for the gener-
ated ..SSFF and ..DDSSAA files. For example, if file is DDUUKKEE-
SSIIGGNN, the generated ..SSFF and ..DDSSAA files will be named DDUUKKEESSIIGGNN..SSFF and DDUUKKEESSIIGGNN..DDSSAA, and will be placed in theMMEETTAA-IINNFF directory of the signed JAR file.
The characters in file 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 ..SSFF and ..DDSSAA file names.If no -ssiiggffiillee option appears on the command line, the
base file name for the ..SSFF and ..DDSSAA 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 thatare not legal in a signature file name, each such char-
acter is converted to an underscore ("") character in forming the file name.-ssiiggnneeddjjaarr file
Specifies the name to be used for the signed JAR file. 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.-vveerriiffyy 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 (for example, RSA when you don't have an RSA provider installed), the following is displayed: "jar is unsigned. (signatures missing or not parsable)" It is possible to verify JAR files signed using either jjaarrssiiggnneerr or the JDK 1.1 jjaavvaakkeeyy tool, or both. For further information on verification, see JAR File Verification.-cceerrttss If this appears on the command line, along with the
-vveerriiffyy and -vveerrbboossee options, the output includes cer-
tificate information for each signer of the JAR file. This information includes: +o the name of the type of certificate (stored in the ..DDSSAA file) that certifies the signer's public key +o if the certificate is an X.509 certificate (morespecifically, an instance of java.secu-
rity.cert.X509Certificate): the distinguished name of the signer 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: +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.-vveerrbboossee If this appears on the command line, it indicates "ver-
bose" mode, which causes jjaarrssiiggnneerr to output extra information as to the progress of the JAR signing or verification.-iinntteerrnnaallssff In the past, the ..DDSSAA (signature block) file generated
when a JAR file was signed used to include a completeencoded copy of the ..SSFF file (signature file) also gen-
erated. This behavior has been changed. To reduce the overall size of the output JAR file, the ..DDSSAA file by default doesn't contain a copy of the ..SSFF file anymore.But if -iinntteerrnnaallssff appears on the command line, the old
behavior is utilized. This option is mainly useful for testing; in practice, it should not be used, since doing so eliminates a useful optimization.-sseeccttiioonnssoonnllyy If this appears on the command line, the ..SSFF file (sig-
nature file) generated when a JAR file is signed doesnot include a header containing a hash of the whole man-
ifest file. It just contains information and hashes related to each individual source file included in the JAR file, as described in The Signature (..SSFF) File . 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 ..SSFF file equals the hash of its corresponding section in the manifest file. For further information, see JAR File Verification. This option is mainly useful for testing; in practice,it should not be used, since doing so eliminates a use-
ful optimization.-pprroovviiddeerr providerclassname
Used to specify the name of the cryptographic service provider's master class file when the service provider is not listed in the security properties file.-JJjavaoption Passes the specified javaoption string directly to the
runtime system. (jjaarrssiiggnneerr 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 possibleflags, type jjaavvaa -hh or jjaavvaa -XX at the command line.
EEXXAAMMPPLLEESS SSiiggnniinngg aa JJAARR FFiillee Suppose you have a JAR file named bbuunnddllee..jjaarr and you'd like to sign it using the private key of the user whose keystore alias is "jane" in thekeystore named "mystore" in the "working" directory. Suppose the key-
store password is "myspass" and the password for jane's private key is "j638klm". You can use the following to sign the JAR file and name the signed JAR file "sbundle.jar":jjaarrssiiggnneerr -kkeeyyssttoorree ""//wwoorrkkiinngg//mmyyssttoorree"" -ssttoorreeppaassss mmyyssppaassss
-kkeeyyppaassss jj663388kkllmm -ssiiggnneeddjjaarr ssbbuunnddllee..jjaarr bbuunnddllee..jjaarr jjaannee
Note that there is no -ssiiggffiillee specified in the command above, so the
generated ..SSFF and ..DDSSAA files to be placed in the signed JAR file will have default names based on the alias name. That is, they will be named JJAANNEE..SSFF and JJAANNEE..DDSSAA. If you want to be prompted for the store password and the private key password, you could shorten the above command tojjaarrssiiggnneerr -kkeeyyssttoorree //wwoorrkkiinngg//mmyyssttoorree
-ssiiggnneeddjjaarr ssbbuunnddllee..jjaarr bbuunnddllee..jjaarr jjaannee
If the keystore to be used is the default keystore (the one named ..kkeeyy-
ssttoorree in your home directory), you don't need to specify a keystore, as in:jjaarrssiiggnneerr -ssiiggnneeddjjaarr ssbbuunnddllee..jjaarr bbuunnddllee..jjaarr jjaannee
Finally, if you want the signed JAR file to simply overwrite the inputJAR file (bundle.jar), you don't need to specify a -ssiiggnneeddjjaarr option:
jjaarrssiiggnneerr bbuunnddllee..jjaarr jjaannee VVeerriiffyyiinngg aa SSiiggnneedd JJAARR FFiillee 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:jjaarrssiiggnneerr -vveerriiffyy ssbbuunnddllee..jjaarr
If the verification is successful, jjaarr vveerriiffiieedd.. is displayed. Otherwise, an error message appears.You can get more information if you use the -vveerrbboossee option. A sample
use of jjaarrssiiggnneerr with the -vveerrbboossee option is shown below, along with
sample output:jjaarrssiiggnneerr -vveerriiffyy -vveerrbboossee ssbbuunnddllee..jjaarr
119988 FFrrii SSeepp 2266 1166::1144::0066 PPDDTT 11999977 MMEETTAA-IINNFF//MMAANNIIFFEESSTT..MMFF
119999 FFrrii SSeepp 2266 1166::2222::1100 PPDDTT 11999977 MMEETTAA-IINNFF//JJAANNEE..SSFF
11001133 FFrrii SSeepp 2266 1166::2222::1100 PPDDTT 11999977 MMEETTAA-IINNFF//JJAANNEE..DDSSAA
ssmmkk 22775522 FFrrii SSeepp 2266 1166::1122::3300 PPDDTT 11999977 AAccllEExx..ccllaassss ssmmkk 884499 FFrrii SSeepp 2266 1166::1122::4466 PPDDTT 11999977 tteesstt..ccllaassss ss == ssiiggnnaattuurree wwaass vveerriiffiieedd mm == eennttrryy iiss lliisstteedd iinn mmaanniiffeesstt kk == aatt lleeaasstt oonnee cceerrttiiffiiccaattee wwaass ffoouunndd iinn kkeeyyssttoorree jjaarr vveerriiffiieedd.. VVeerriiffiiccaattiioonn wwiitthh CCeerrttiiffiiccaattee IInnffoorrmmaattiioonnIf you specify the -cceerrttss option when verifying, along with the -vveerriiffyy
and -vveerrbboossee options, the output includes certificate information for
each signer of the JAR file, including the certificate type, the signer distinguished name information (if it's an X.509 certificate), and, inparentheses, the keystore alias for the signer if the public key cer-
tificate in the JAR file matches that in a keystore entry. For example,eexxaammppllee%% jjaarrssiiggnneerr -kkeeyyssttoorree //wwoorrkkiinngg//mmyyssttoorree -vveerriiffyy -vveerrbboossee -cceerrttss mmyyTTeesstt..jjaarr
119988 FFrrii SSeepp 2266 1166::1144::0066 PPDDTT 11999977 MMEETTAA-IINNFF//MMAANNIIFFEESSTT..MMFF
119999 FFrrii SSeepp 2266 1166::2222::1100 PPDDTT 11999977 MMEETTAA-IINNFF//JJAANNEE..SSFF
11001133 FFrrii SSeepp 2266 1166::2222::1100 PPDDTT 11999977 MMEETTAA-IINNFF//JJAANNEE..DDSSAA
220088 FFrrii SSeepp 2266 1166::2233::3300 PPDDTT 11999977 MMEETTAA-IINNFF//JJAAVVAATTEESSTT..SSFF
11008877 FFrrii SSeepp 2266 1166::2233::3300 PPDDTT 11999977 MMEETTAA-IINNFF//JJAAVVAATTEESSTT..DDSSAA
ssmmkk 22775522 FFrrii SSeepp 2266 1166::1122::3300 PPDDTT 11999977 TTsstt..ccllaassss XX..550099,, CCNN==TTeesstt GGrroouupp,, OOUU==JJaavvaa SSooffttwwaarree,, OO==SSuunn MMiiccrroossyysstteemmss,, LL==CCUUPP,, SS==CCAA,, CC==UUSS ((jjaavvaatteesstt)) XX..550099,, CCNN==JJaannee SSmmiitthh,, OOUU==JJaavvaa SSooffttwwaarree,, OO==SSuunn,, LL==ccuupp,, SS==ccaa,, CC==uuss ((jjaannee)) ss == ssiiggnnaattuurree wwaass vveerriiffiieedd mm == eennttrryy iiss lliisstteedd iinn mmaanniiffeesstt kk == aatt lleeaasstt oonnee cceerrttiiffiiccaattee wwaass ffoouunndd iinn kkeeyyssttoorree jjaarr vveerriiffiieedd.. 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 PPGGPP,, ((bboobb)) VVeerriiffiiccaattiioonn ooff aa JJAARR FFiillee tthhaatt IInncclluuddeess IIddnneettiittyy DDaattaabbaassee SSiiggnneerrss If a JAR file has been signed using the JDK 1.1 jjaavvaakkeeyy 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.When the -cceerrttss option is used, any identity database aliases are shown
in square brackets rather than the parentheses used for keystore aliases. For example:jjaarrssiiggnneerr -kkeeyyssttoorree //wwoorrkkiinngg//mmyyssttoorree -vveerriiffyy -vveerrbboossee -cceerrttss wwrriitteeFFiillee..jjaarr
119988 FFrrii SSeepp 2266 1166::1144::0066 PPDDTT 11999977 MMEETTAA-IINNFF//MMAANNIIFFEESSTT..MMFF
119999 FFrrii SSeepp 2266 1166::2222::1100 PPDDTT 11999977 MMEETTAA-IINNFF//JJAANNEE..SSFF
11001133 FFrrii SSeepp 2266 1166::2222::1100 PPDDTT 11999977 MMEETTAA-IINNFF//JJAANNEE..DDSSAA
119999 FFrrii SSeepp 2277 1122::2222::3300 PPDDTT 11999977 MMEETTAA-IINNFF//DDUUKKEE..SSFF
11001133 FFrrii SSeepp 2277 1122::2222::3300 PPDDTT 11999977 MMEETTAA-IINNFF//DDUUKKEE..DDSSAA
ssmmkkii 22775522 FFrrii SSeepp 2266 1166::1122::3300 PPDDTT 11999977 wwrriitteeFFiillee..hhttmmll XX..550099,, CCNN==JJaannee SSmmiitthh,, OOUU==JJaavvaa SSooffttwwaarree,, OO==SSuunn,, LL==ccuupp,, SS==ccaa,, CC==uuss ((jjaannee)) XX..550099,, CCNN==DDuukkee,, OOUU==JJaavvaa SSooffttwwaarree,, OO==SSuunn,, LL==ccuupp,, SS==ccaa,, CC==uuss [[dduukkee]] ss == ssiiggnnaattuurree wwaass vveerriiffiieedd mm == eennttrryy iiss lliisstteedd iinn mmaanniiffeesstt kk == aatt lleeaasstt oonnee cceerrttiiffiiccaattee wwaass ffoouunndd iinn kkeeyyssttoorree ii == aatt lleeaasstt oonnee cceerrttiiffiiccaattee wwaass ffoouunndd iinn iiddeennttiittyy ssccooppee jjaarr vveerriiffiieedd..Note that the alias "duke" is in brackets to denote that it is an iden-
tity database alias, not a keystore alias.SEE ALSO
jjaarr(1), kkeeyyttooooll(1)23 Jun 2004 jarsigner(1)