Skip to main content

Keystore Errors and possible causes

You might have played with the keystore and java security objects many times.Some of these errors happen when you install it first time

# Java's default cacerts password is "changeit", unless you're on a Mac, where it's "changeme".
 # Better to execute it as root, hence sudo su
 sudo su - -c /usr/java6_64/bin/keytool -import -trustcacerts -file /tmp/ServerCertficate.crt -keystore /usr/java6_64/jre/lib/security/cacerts -alias diaryfolio_Certificate

#No need of any password while viewing (Just press enter)
 /usr/java6_64/bin/keytool -list -v -keystore /usr/java6_64/jre/lib/security/cacerts   >/tmp/java6.abc

Common Errors

1.  Keytool Error with Java lang Exception

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

This may be caused due to
- Not specifying an alias name correctly?
- Space or incorrect blanks
- Check in the certificate (.crt file), if there are any headers or footers before
 —–BEGIN CERTIFICATE—–


or anyting after
 —–END CERTIFICATE—–

SolutionRemove entries after head and footers and try importing again

 2.  Keytool Error with Java Filenotfound Exception

keytool error (likely untranslated): java.io.FileNotFoundException: /usr/java6_64/jre/lib/security/cacerts (Permission denied)

Solution:This happens because you don't have edit permission (or insert) for the keystore. Run as root.

 3.  Keytool Error with Java IO Exception

 keytool error (likely untranslated): java.io.IOException: Keystore was tampered with, or password was incorrect

Solution: Ensure the password is correct. Try  password "changeit"  (as it is the default) or the password might have been changed by someone. In which case contact your OS admin having root access and try to export the keytool entries as exporting doesn't require password. (Step at top of this page). Carefully find the entries which you feel is required for your organisation, later create a cacerts file of your own and import these custom entries.