Thursday 4 July 2013

Java – Keytool - Create a KeyStore and Generate a Public-Private Key using RSA Algorithm

 

Open a console/command prompt (in admin mode if on windows), ‘cd’ to your JDK’s bin directory (if you do not have the JDK’s bin setup in your PATH) and run following command:

NOTE – Following command was named -genkey in previous releases. This old name is still supported in this release and will be supported in future releases, but for clarify the new name, -genkeypair, is preferred going forward.

Once you run above command, it will create a new keystore (if not already exists) at following location:

Windows : %JAVA_HOME%\bin\test-keystore

Linux/Mac/Solaris : $Java_HOME/bin/test-keystore

To make sure the key generated above is saved in the newly created keystore, run following command:

NOTE that I’ve used the same keystore password for the key as well and I did that intentionally because not all SSL clients allows you to specify a different password for the key and the keystore.

No comments:

Post a Comment