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

https, keytool, tomcat6, x509

Solution

I had similar issue when I was trying to import .crt file into java keystore.

I am able to fix it by following below steps:

Generate pkcs12 format keystore:

Enter the password as you want in below two command:

openssl pkcs12 -export -name <domain_name> -in <certificate_name>.crt -inkey <certificate_name>.key -out keystore.p12

Convert pkcs12 keystore to java keystore

keytool -importkeystore -destkeystore tomcat.jks -srckeystore keystore.p12 -srcstoretype pkcs12 -alias <domain_name>

Check your certificate in keystore:

keytool -list -v -keystore tomcat.jks

Problem

I want to activate https in tomcat 6. When I import the SSL certificate then I got below stated error : ``` keytool error: java.lang.Exception: Input not an X.509 certificate ``` How can I solve this error??

Original source