Importing certificates to the Java Key Store
The following steps show, how to get the certificate from an HTTPS server an import it into JVM (Java Virtual Machine). Here I have used Google Chrome. The steps are similar for all other browsers.
Step 1: Open the browser and go to the HTTPS URL where the certificate resides and click on the green lock icon.
Step 2: Click on the ‘Certificate’ button of the appeared box.
Step 3: You will see the ‘Certificate Viewer’ box. Then go to the ‘Details’ tab in the in the same box.
Step 4: Click on ‘Export’ button which will lead you to a window to save the certificate.
Ignore warning alerts if any appeared.
Step 5: After the certificate is saved, open the terminal and run the following command.
For older versions of java,
keytool -import -noprompt -trustcacerts -alias <cert_alias> -file <public_key_name>.pem -keystore <key_store_name>.jks -storepass <key_store_password>
If you are using Java 7 or later versions,
keytool -import -alias <cert_alias> -file <public_key_name>.pem -keystore <key_store_name>.jks -storepass <key_store_password>
This will import the certificate into the Java key store.