Error: "keytool error: java.lang.Exception: Input not an X.509 certificate" when Installing a Sun Java Code Signing Certificate

The Problem

The following error occurs when importing a Sun Java™ certificate into a Keystore:

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

There are a few causes for this error.

  • The incorrect alias was specified while trying to install the certificate.
  • The certificate being imported is improperly formatted.
  • The certificate is being imported into an incorrect keystore.

The Solution

Please review each of the possible options below and their fixes to troubleshoot this error:

Option 1 - Incorrect Alias Specified:

This error can occur if the wrong Alias was specified when attempting to install the Sun Java Code Signing certificate to the Keystore.  The correct Alias to use would be the Alias used when generating the Certificate Signing Request (CSR) that was submitted for the enrollment of the certificate.


Option 2 - Improper Format:

If the Sun Java Code Signing certificate was saved in an improper way, this error can occur.


Option 3 - Incorrect Keystore being Used:

If a different Keystore is being used other than the Keystore that was used to generate the CSR that was submitted for the enrollment of the certificate, this error can occur.

If the correct Keystore to use is unknown or lost, a replacement of the certificate is needed.