Igor Simic
3 years ago

How to generate SSL certificate for JAVA Tomcat local server

In order to generate SSL certificate for your local JAVA environment and be able to run local sites under https protocol here is what you have to do.

Open your terminal and go to your Java project folder ->src->main->resources and then type this command (replace myCompany with your company name, and password with your strong password):
keytool -genkey -keyalg RSA -alias myCompany -keystore keystore.jks -storepass password -validity 4000 -keysize 2048
after this command is executed, you will get some questions from terminal that you need to answer:

SSL key generated

Next step is go to Java application.yml and add configuration for our new SSL key. Go to src->main->resources->application.yml and add this configuration
    key-store: keystore.jks # name of generated file
    key-store-password: password # your password
    key-store-type: JKS
    key-alias: pixuelle # from keytool command
    key-password: password #your password
Copy keystore.jks to folder where your -boot-app-0.0.1-SNAPSHOT.jar
 is located and then  rebuild your app and start server!