Problem
When importing a certificate into a keystore file, you may receive the following error message:
"keytool error: java.security.cert.CertificateParsingException: invalid DER-encoded certificate data"
Cause
This error occurs when the certificate file containing invalid formatting characters or carriage returns.
Resolution
To resolve the problem, perform the following steps:
1. Open the certificate in an ASCII text editor (Use Notepad or another plain text editor)
2. Ensure that the first line starts with -----BEGIN CERTIFICATE----- and ends with -----END CERTIFICATE-----
3. Carefully ensure there is no space or blank within your certificate file, by selecting the entire text and looking for blank spaces.
4. If a blank space or line exists, delete it, and install your certificate file again.