Attempting to add a certificate to the keystore so I can use it in an java based application. This is a new concept to me.
I have a .p7b certificate for the site and I put together a keytool command. When I enter it, I am prompted to specify a pwd and then I am prompted with the following error
keytool error: java.lang.Exception: Input not an X.509 certificate
Can anyone provide insight?
C:\Users\Desktop\>keytool -import -trustcacerts -file "service.site.com - SSL Cert.p7b" -keystore service.site.com.jks
Enter keystore password:
Re-enter new password:
keytool error: java.lang.Exception: Input not an X.509 certificate
Best Answer
You could try converting the key to CER (X509) and then try importing it:
I have encountered a similar problem even though I was trying to import a .pem file. The file contained only the a single certificate in both humain readable form and encapsulated within —–BEGIN CERTIFICATE—– and —–END CERTIFICATE—–. In java 7 (patch 71) the keytool failed to parse such file and threw the same error you've got. Once I removed the text portion of the file:
it worked alright for me.
Please also take a look at the following article (https://myonlineusb.wordpress.com/2011/06/19/what-are-the-differences-between-pem-der-p7bpkcs7-pfxpkcs12-certificates/) as it explains the differences between various formats and provides commands how to convert from one format to another