Validate the server’s certificate.
By default, the Sun Java System Application Server generates a self-signed certificate and stores it in a key store file at the location
where appServerRoot is the root directory in which the Application Server is installed.
If necessary, you can use the JDK Key Tool utility to generate a key store of your own and use it in place of the default key store. For more information, see the section “Establishing a Secure Connection Using SSL” in Chapter 28, “Introduction to Security in Java EE,” of the Java EE 5 Tutorial at
Make the directory containing the key store file your current directory.
For example, to use the Application Server’s default key store file (as shown above), navigate to its directory with the command
where appServerRoot is, again, the root directory in which the Application Server is installed.
List the contents of the key store file.
The Key Tool utility’s -list option lists the contents of a specified key store file. For example, the following command lists the Application Server’s default key store file (keystore.jks):
keytool -list -keystore keystore.jks -v
The -v option tells the Key Tool utility to display certificate fingerprints in human-readable form.
Enter the key store password.
The Key Tool utility prompts you for the key store file’s password:
Enter keystore password:
By default, the key store password is set to changeit; you can use the Key Tool utility’s -storepasswd option to change it to something more secure. After you have entered a valid password, the Key Tool utility will respond with output like the following:
Verify the certificate’s fingerprints.
Obtain the correct fingerprints for the Application Server’s self-signed certificate by independent means (such as by telephone) and compare them with the fingerprints displayed by the keytool -list command. Do not accept the certificate and install it in your application’s trust store unless the fingerprints match.
Export the Application Server’s certificate to a certificate file.
Use the Key Tool utility’s -export option to export the certificate from the Application Server’s key store to a separate certificate file, from which you can then import it into your application’s trust store. For example, the following command exports the certificate shown above, whose alias is slas, from the Application Server’s default key store (keystore.jks) to a certificate file named slas.cer:
keytool -export -keystore keystore.jks -storepass changeit -alias slas -file slas.cer
The Key Tool utility responds with the output
Certificate stored in file <slas.cer>
Verify the contents of the certificate file.
If you wish, you can double-check the contents of the certificate file to make sure it contains the correct certificate:
List the contents of the certificate file.
The Key Tool utility’s -printcert option lists the contents of a specified certificate file. For example, the following command lists the certificate file slas.cer that was created in the preceding step:
keytool -printcert -file slas.cer -v
Once again, the -v option tells the Key Tool utility to display the certificate’s fingerprints in human-readable form. The resulting output looks like the following:
Confirm the certificate’s contents.
Examine the output from the keytool -printcert command to make sure that the certificate is correct.
Import the certificate into your application’s trust store.
The Key Tool utility’s -import option installs a certificate from a certificate file in a specified trust store. For example, if your client application’s trust store is kept in the file /local/tmp/imqhttps/appKeyStore, the following command will install the certificate from the file slas.cer created above:
keytool -import -file slas.cer -keystore "/local/tmp/imqhttps/appKeyStore"