First download certificate in java file
1 2 | echo -n | openssl s_client -servername <hostname> -connect <hostname>: 443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /tmp/key.cert |
Import it using keytool command
1 | keytool - import -alias <alias> -file key.cert -keystore <keystore_location> |
Java Trust store location : <JRE_HOME>/lib/security/cacerts