Accessing the Keystore

The JDK comes with a program called keytool that lets you manage a database of keys and certificates. With keytool, you can create new keys, request a digital certificate, and manage a database of keys and certificates. The keystore would be useless, however, if you couldn't access it from a Java program.

You can create an RSA key with the following keytool command:

keytool –genkey –alias j2eetest –keyalg "RSA"

Note

When you create a key, you have the option of supplying a separate password for the key itself. The examples in this chapter use a password of "kspass" for the keystore and "thekeypass" for the key password.

To access the keystore, you create a KeyStore object and then load the keys from the keystore file ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.