We'll use the keytool -export command to extract
the public key into a file, and then use the keytool
-import command to insert it into a new keystore.
Here's the command to extract the client's public key:
keytool -export -alias clientprivate -keystore client.private -file
temp.key -storepass clientpw
And here's the command to insert the client's private key into its
own keystore:
keytool -import -noprompt -alias clientpublic -keystore client.public
-file temp.key -storepass public
We'll also extract and store the server's public key. Here's the
command to extract the key:
keytool -export -alias serverprivate -keystore server.private -file
temp.key -storepass serverpw
And here's the command to place it in its own keystore:
keytool -import -noprompt -alias serverpublic -keystore server.public
-file temp.key -storepass public
The script generatekeys.sh (for UNIX) and generatekeys.bat (for DOS or Microsoft Windows)
automatically generates the client and server key files for you
and cleans up any temporary files. See Resources to
download the script.