|
The Java Development Kit contains the tools that you need to sign JAR files. Depending on which version of the Java Development Kit you're using, you will use either:
The JDK 1.2 JAR Signing and Verification Tool
The JAR Signing and Verification Tool is invoked by using the
To sign a JAR file, you must first have a private key. Private keys and their associated public-key certificates are stored in password-protected databases called keystores. A keystore can hold the keys of many potential signers. Each key in the keystore can be identified by an alias which is typically the name of the signer who owns the key. The key belonging to Rita Jones might have the alias "rita", for example. The basic form of the command for signing a JAR file is jarsigner jar-file alias In this command:
The Jarsigner tool will prompt you for the passwords for the keystore and alias.
This basic form of the command assumes that the keystore to be used
is in a file named
In practice, you may want to use this command in conjunction with
one or more of these options, which must precede the
ExampleLet's look at a couple of examples of signing a JAR file with the Jarsigner tool. In these examples we will assume:
Under these assumptions, you could use this command to sign a JAR file named
jarsigner -keystore mykeys -storepass abc123
-keypass mypass app.jar johndoe
Because this command doesn't make use of the Let's look at what would happen if you used a different combination of options:
jarsigner -keystore mykeys -sigfile SIG
-signedjar SignedApp.jar app.jar johndoe
This time, you would be prompted to enter the passwords for both the
keystore and your alias because the passwords aren't specified on the
command line. The signature and
signature block files would be named Jarsigner Reference PageComplete reference pages for the JAR Signing and Verification Tool are on-line: The Java Development Kit provides the Key and Certificate Management Tool (Keytool) for managing keystores: The JDK 1.1 Java Security Tool
If you're working with version 1.1 of the Java Development Kit, you'll use
the Java Security Tool to sign JAR files. You invoke the Java Security
Tool with the
The Javakey tool manages a database containing public/private key
pairs and related certificates. In order to sign a JAR file with
the Javakey tool, you need to have a public/private key pair in Javakey's
database. The Javakey tool will look for the database at the location
specified by the In addition to key pairs, Javakey's database contains certificates for the public keys. When a certificate is added to the database, Javakey assigns it a unique number for identification purposes. To sign a file, you must provide Javakey with several pieces of information:
You provide this information to Javakey by using a directive file, which is basically a property file that Javakey reads when signing a JAR file. Here's a sample directive file:
Once your directive file is ready, you sign a JAR file by using a command of this form: javakey -gs directive-file jar-file In this command:
Javakey will place the signed JAR file in the current directory. Javakey can perform many other functions related to managing the key/certificate database. See the on-line JDK documentation for more information about Javakey:
| ||||||||||||||||||
Oracle is reviewing the Sun product roadmap and will provide guidance to customers in accordance with Oracle's standard product communication policies. Any resulting features and timing of release of such features as determined by Oracle's review of roadmaps, are at the sole discretion of Oracle. All product roadmap information, whether communicated by Sun Microsystems or by Oracle, does not represent a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions. It is intended for information purposes only, and may not be incorporated into any contract.
|
| ||||||||||||