9

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??

2

2 Answers 2

6

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
Sign up to request clarification or add additional context in comments.

Comments

4

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.