Search code examples
javakeystore

keytool error Keystore was tampered with, or password was incorrect


I am getting following error while generating certificates on my local machine.

C:\Users\abc>keytool -genkey -alias tomcat -keyalg RSA
Enter keystore password:
keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect

I think there is some problems in jdk version.I ran the same command on my collegues machine and it is working fine.

Please share your inputs.


Solution

  • From your description I assume you are on windows machine and your home is abc

    So Now : Cause

    When you run this command

    keytool -genkey -alias tomcat -keyalg RSA

    because you are not specifying an explicit keystore it will try to generate (and in your case as you are getting exception so to update) keystore C:\users\abc>.keystore and of course you need to provide old password for .keystore while I believe you are providing your version (a new one).

    Solution

    1. Either delete .keystore from C:\users\abc> location and try the command

    2. or try following command which will create a new xyzkeystore:

      keytool -genkey -keystore xyzkeystore -alias tomcat -keyalg RSA

    Note: -genkey is old now rather use -genkeypair althought both work equally.