Java.lang.Exception: enter no X.509 certificate: keytool error

I want to activate https in tomcat 6. When I import the SSL certificate, I received the error below stated:

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

How can I solve this error?

+8
tomcat6 x509 keytool
source share
2 answers

I had a similar problem when I tried to import a .crt file into java keystore.

I can fix this by following these steps:

Create a pkcs12 format keystore:

Enter the password as you want in two commands:

 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> 

Verify your certificate in the keystore:

 keytool -list -v -keystore tomcat.jks 
+6
source share

I had the same problem and the actual problem was the end of the char string, the certificate file should not contain the end of the char string. The decoded string must be on 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 $% # ^ # DF

  ----- END CERTIFICATE ----- 

No extra rows or columns. Hope this helps.

+4
source share

All Articles