keytool -delete -noprompt -alias ${cert.alias} -keystore ${keystore.file}
-storepass ${keystore.pass}
Anotherexample of deleting a certicate from a keystore is shown in “Deleting a Certicate
Usingthe keytool Utility”on page 115
Generatinga Certicate Using the keytool Utility
Usekeytool togenerate, import, and export certicates. By default, keytool createsa keystore
lein the directory where it is run.
1. Changetothe directory where the certicate is to be run.
Alwaysgenerate the certicate in the directory containing the keystore and truststore les,
bydefault domain-dir/config. For information on changing the location of these les, see
“Changingthe Location of Certicate Files” on page 112.
2. Enterthefollowing keytool commandto generate the certicate in the keystore le,
keystore.jks:
keytool -genkey -alias keyAlias-keyalg RSA
-keypass changeit
-storepass changeit
-keystore keystore.jks
Useany unique name as your keyAlias. If you have changed the keystore or private key
passwordfrom their default, then substitute the new password for changeit inthe above
command.The default key password alias is “s1as.”
Aprompt appears that asks for your name, organization, and other information that
keytooluses to generate the certicate.
3. Enterthefollowing keytool commandto export the generated certicate to the le
server.cer(or client.cer ifyou prefer):
keytool -export -alias keyAlias-storepass changeit
-file server.cer
-keystore keystore.jks
4. Ifacerticate signed by a certicate authority is required, see “Signing a Digital Certicate
Usingthe keytool Utility”on page 115.
5. Tocreatethe truststore le cacerts.jks andadd the certicate to the truststore, enter the
followingkeytool command:
keytool -import -v -trustcacerts
-alias keyAlias
-file server.cer
-keystore cacerts.jks
-keypass changeit
UsingJavaSecure Socket Ex tension( JSSE)Tools
SunGlassFishEnterprise Ser ver2.1 Administration Guide December 2008114