James
James

Reputation: 3805

keytool error: java.io.IOException: Illegal header: -----BEGIN CERTIFICATE-----

Using the following command:

/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.55.x86_64/bin/keytool -import -alias tomcat -trustcacerts -file certificate.crt -keystore $OBM_HOMEconf/keystore

I receive the error:

keytool error: java.security.cert.CertificateException: java.io.IOException: Illegal header: -----BEGIN CERTIFICATE-----

I generated the certificate on GoDaddy, as I had done previously for the server I'm trying to install this cert on, and downloaded the Tomcat version of the files from them.

I ensured all of the hyphens are actual hyphens (I've had an issue before where they came out as em dashes) in both the cert and the command. I do not understand why it is saying that the cert header is an illegal header.

Upvotes: 1

Views: 6139

Answers (1)

Omikron
Omikron

Reputation: 4143

Java's PEM parser is a bit finicky when it comes to extra whitespace. A trailing space character in the header line causes this error message.

Upvotes: 5

Related Questions