Lead your team forward
OCT 24 / 9AM ET Register nowImport Certificates to Java Truststore
This article describes how to import certificates to the Java trustsore using the keytool tool.
The default truststore is <JAVA_HOME>/lib/security/cacerts
file.
After each of the following commands, you are prompted to enter the keystore password. Make sure you know passwords to the source and the target keystore. |
Import all certificates
To import all certificates from an existing keystore, run the following command in Java:
keytool -importkeystore -srckeystore <source_keystore> -destkeystore <target_keystore>
keytool -importkeystore -srckeystore gateway.jks -destkeystore dest.jsk
Import specific certificate
Alternatively, you can also import a specific certificate from a keystore:
-
List the certificates that are in the source Java keystore (JKS) file with the command
keytool -list -v -keystore <source_keystore>
.List keystore certificateskeytool -list -v -keystore gateway.jks
-
Export the selected certificate from the source keystore to the certificate file with the command
keytool -exportcert -alias <certificate_alias> -file <certificate> -keystore <source_keystore>
.Export certificatekeytool -exportcert -alias certificate-alias -file C:/myCertificate -keystore gateway.jks
-
Import the certificate to the Java truststore with the command
keytool -importcert -alias <certificate_alias> -file <certificate> -keystore <target_keystore>
.When asked whether you
Trust this certificate?
, enteryes
.Import certificatekeytool -importcert -alias certificate-alias -file C:/myCertificate -keystore <JAVA_HOME>/lib/security/cacerts
Was this page useful?