Generate Self Signed Certificate using Java Keytool

It is very important to secure your Java application with an SSL certificate. It is easy to do using Java Keytool. Most of the times you will buy a trusted certificate, but there are many cases when you can generate and use a self signed certificate for free like intranet ,development server.

Never use a self signed certificate on a production server that transfers imporatnt data like account number ,card details

Java Keytool is a key and certificate management utility. It allows users to manage their own public/private key pairs and certificates. It allows more functionality with it’s different set of commands.

Steps to create a Self Signed Certificate using Java Keytool

  • Open the command prompt on system at any folder if JAVA_HOME is set or else  navigate to the directory where keytool.exe is located (usually where the JRE is located, e.g. c:\Program Files\Java\jre6\bin on Windows machines).
  • Run the following command.
    keytool -genkey -keyalg RSA -sigalg SHA1withRSA -validity 730 -alias jbossfuse -keypass password -storepass password -keystore jbossfuse-dev.jks -dname “cn=localhost”
  • This will create a jbossfuse-dev.jks file containing a private key  Now you just need to configure your application server to use the .jks file.

Conclusion

This helps you to deploy and test your apps locally using SSL instead of testing it on managed dev environment .

One thought on “Generate Self Signed Certificate using Java Keytool

Leave a comment