Keytool error: java.lang.Exception: Input not an X.509 certificate

Feb 3, 2017

This error occurs when one of the following conditions are true:
  • The incorrect alias was specified during the import command.
  • No alias was specified while trying to import the certificate.
  • The incorrect keystore file was used during the import command.
  • Improperly formatted certificate is being imported into the keystore.

To resolve this issue:

  1. Use the correct alias in your command.
  2. Verify that command points to the keystore using its exact name.
  3. Verify that certificate is formatted correctly. Open your certificate with a plain text editor (ie. notepad, vim):
    • The header and footer are included enclosed between five dashes.
    • There are no trailing spaces on each line.
    • The certificate is saved as a .p7b.
  4. Use the following syntax while performing the import function:

keytool -import -trustcacerts -alias alias_name -file certificate_file.p7b -keystore keystore_name

Note: Where alias_name, is the alias of the private key in your keystore, keystore_name is the path to your keystore and keystore_output.txt the file that will be created.
You will be prompted to enter the keystore password.

If you have forgotten your alias or need to verify your keystore details, please follow the steps below
To view the certificate information in a keystore, run the following command:
keytool -list -v -keystore keystore_name
To output the certificate information in a keystore to a text file, run the following command:
keytool -list -v -keystore keystore_name > keystore_output.txt 

Note: Where keystore_name is the path to your keystore and keystore_output.txt the file that will be created.
You will be prompted to enter the keystore password.

Note: If it is still giving the same error, check if you are using the right keystore file and alias. Ultimate step is you will have to start from scratch generating a new CSR and new keystore file> Perform a reissue of the SSL Certificate > then perform SSL Certificate installation.


Have any Questions

If you have any questions, feel free to call us