While I am working in Web Services I call a third party Web Service URL. The service URL requires some set of certificates to be stored on the client side.
Java JDK stores the certificate in Keystore file called cacerts.
For JDK 8 and below it will be in the JRE security folder
C:\Program Files\Java\jdk1.8\jre\lib\security\cacerts
For JDK 9 to JDK 16 and below it will be in the JDK security folder
C:\Program Files\Java\jdk-16.0.2\lib\security\cacerts
Keytool is used to list all the certificates in cacerts keytore file
keytool executable application file will be found in the JDK bin folder.
C:\ Program Files\ Java\jdk1.8\bin\keytool.exe
The certificates can be listed using keytool -list command
List all Certificates
Syntax
keytool -list -v -keystore keystore_file_path
Command
keytool -list -v -keystore cacerts
//or specify full path to cacerts like this
keytool -list -v -keystore "C:/Program Files/Java/jdk1.8/jre/lib/security/cacerts"
List only one Certificate using an alias
Syntax
keytool -list -v -keystore keystore_file_path -alias certificate_alias_name
Command
keytool -list -v -keystore cacerts -alias CertificateA
//or with cacerts full path. Both command should work.
keytool -list -v -keystore "C:/Program Files/Java/jdk1.8/jre/lib/security/cacerts" -alias CertificateA
All of the above command's are run from the jdk bin path in the command prompt,
C:\ Program Files\ Java\jdk1.8\bin>