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??
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??
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
I faced the same problem, and the actual problem was the end of line char, the certificate file should not contain end of line char. The decoded string should be in one line.
Eg. if your cer file contains char like below -----BEGIN CERTIFICATE----- SSFDsdfsSDfsGSDFasdfSFADsdSDFSsdf FGHJFGHfghRTURTYUTRYyrtRTYTRYRTYR ASDFRTYRTrtyrtyRTryrTRYrtyrTYRYrt werWERWer#$%&EEFGERedfgre$%#dfg^# -----END CERTIFICATE-----
Change it to
-----BEGIN CERTIFICATE-----
SSFDsdfsSDfsGSDFasdfSFADsdSDFSsdfFGHJFGHfghRTURTYUTRYyrtRTYTRYRTYRASDFRTYRTrtyrtyRTryrTRYrtyrTYRYrtwerWERWer#$%&EEFGERedfgre$%#dfg^#
-----END CERTIFICATE-----
No extra row or column. Hope it helps.