A keytool error occurs when attempting to import certificate. The error syntax is:
keytool error: Input not an X.509 certificate
This can occur as you attempt to import a root path certificate to a J2EE environment using the class keystore and a cacerts file to establish trust with the Web certificate authority.
- Class Keystore (KeyStore.TrustedCertificateEntry). Contains a single public key certificate belonging to another party.
- File Cacerts. A certificates file that represents a system-wide keystore with CA certificates and contains root CA certificates from several public CAs.
- Source: Sun Developer Network
This error results from Java expecting the certificate to be available in base-64 encoded X.509 format while the default encoding from the Microsoft certificate authority for the certificate is DER binary.
To resolve this issue, you must convert the root path certificate into base-64 encoded X.509 format. This involves creating an SSL request file through the Internet Services Manager.
To Convert a Certificate
- In the Administrative Tools, click Internet Services Manager.
- In the IIS Manager, select and expand the listed Web sites.
- Select PLUS and right-click. In the shortcut menu, click Properties.
- In the Properties dialog box, click Directory Security.
- Click Server Certificate.
- In the Certificate Wizard, select Create a new certificate and click Next.
- Select Prepare the request now, but send it later and click Next.
- Continue to complete the requested fields within the Certificate Wizard.
- In the Certificate Request File Name dialog box, save the request file to a folder on the local machine and click Next.
- On the local machine, open the certreq.txt in a text editor. Do not exit or close the Wizard at this point.
- Copy the contents of the certreq.txt file and paste into the Saved Request text box in the Wizard Certificate Server Request dialog box. You can also insert the entire file.
- In the Wizard Certificate Server Request dialog box, click Submit.
- Download the certificate response file and name the file certnew.cer.
- Download the certificate chain of root path certificate and name it certnew.p7b.
- In the Internet Services Manager, open (double-click) the certnew.p7b root chain.
- Select the certificate chain and right-click. In the shortcut menu, click Certifcate Export Wizard.
- In the Certificate Export Wizard, click Next.
- Select Base-64 encoded X.509 (.CER) and click Next.
- Rename the certificate to rootcert.cer and save it as Base-64 encoded X.509 format.
- Import the new certificate into the Java Keystore using the command:
- keytool import keystore /path to cacerts alias nameofalias file certname
- Import the certnew.cer or the webcert in the same manner using a separate alias.