-
Notifications
You must be signed in to change notification settings - Fork 1
Set up SSL Keystore for Java Case API Application
⏮API Prev | API Next⏭ |
---|
- Locate the private key file (*.pfx) and its password on your local box. This private key should be created by your team, or even created by you as self-signed certificate on your local box.
- Install Java JDK.
-
Open the Command Prompt as administrator.
-
Navigate to JRE bin folder. JRE folder shall be located inside Java folder along with JDK folder.
-
Create a keystore with the following command.
keytool -genkeypair -alias mydomain -keyalg RSA -keystore myFavKeyStoreName.jks
-
Answer several questions (or left some blank). Type y or yes to confirm the information. If prompted for domain password, it may be left blank and simply press Return/Enter to proceed.
-
Import private key certificate with the following command.
keytool -importkeystore -srckeystore "yourPath\yourPrivateKey.pfx" -srcstoretype pkcs12 -destkeystore myFavKeyStoreName.jks -deststoretype JKS
-
Supply both keystore (Enter destination keystore password) and private key (Enter source keystore password) passwords. Press Enter key and verify the result.
-
Verify the Certificate info inside the keystore with the following command. Per Oracle, use the -list command to print the contents of the keystore entry identified by -alias to stdout. If -alias alias is not specified, then the contents of the entire keystore are printed.
keytool -list -keystore myFavKeyStoreName.jks
📑Record the certificate alias for later reference in the code📑
-
After supplying Keystore password, at least 2 certificates will appear. Ignore mydomain certificate.
-
optional Alternatively, we can run the same command with verbose option. Per Oracle, the difference with/without -v is that, without verbose option, it prints the SHA-256 fingerprint of a certificate. With it, the certificate is printed in human-readable format, with additional information such as the owner, issuer, serial number, and any extensions.
keytool -list -keystore myFavKeyStoreName.jks -v
📑Record the folder path to this keystore for later reference in the code📑
-
Unless specifically specified otherwise, the newly-created keystore will be located in Java JRE bin folder.
-
Now, you are ready to proceed to coding.
- Now you are ready to install and run the sample application.