Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To import multiple certificates in a single file using keytool, you can use the following steps:

  1. Create a text file with the .pem extension that includes all the certificates you want to import. i.e. cert.pem

  2. Open the command prompt or terminal and navigate to the directory where your .pem file is located.

  3. Run the following command to convert the .pem file to a .pfx file:

openssl pkcs12 -export -in cert.pem -out cert.pfx
  1. Enter a password for the .pfx file and confirm it.

  2. Run the following command to import the .pfx file with all the certificates to the keystore:

keytool -importkeystore -deststorepass <keystore-password> -destkeypass <key-password> -destkeystore <keystore-name.jks> -srckeystore cert.pfx -srcstoretype PKCS12 -srcstorepass <pfx-password> -alias <alias-name>

Replace the <keystore-password> with your desired password to the keystore, <key-password> with your desired password to the private key, <keystore-name.jks> with the name of your keystore file, <pfx-password> with the password you created in step 4 and <alias-name> with the desired alias name for the imported certificates.

  1. Type Yes when prompted to trust the certificate(s) and then press Enter.

  2. Verify that the certificates were successfully imported by running the following command:

keytool -list -keystore <keystore-name.jks>

This will display the list of certificates included in your keystore file.