Importing a SSL certificate using the keytool utility results in an Illegal Header error

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

Attempting to import a new certificate into your local keystore using the keytool utility results in an error:

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

Cause

This error is generally caused by a white space character in the header of the certificate. See this Stackflow discussion for more details.

Resolution

Locate and remove any whitespace from the header of the certificate. See this discussion for tips on how this can be accomplished.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.