keytool -genkey error: Keystore file does not exist

85,125

Solution 1

Generating a key pair (and a new keystore) has to be done as a separate operation to creating a self-signed certificate for that key.

i.e.

keytool -genkey -alias myKey -keystore store.jks
keytool -selfcert -alias myKey -keystore store.jks

Solution 2

Run command prompt as Administrator and it will be done.

Solution 3

First generate the upload key using below command:

keytool -genkeypair -v -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

then run

keytool -exportcert -keystore path-to-debug-or-production-keystore -list -v 
Share:
85,125
Admin
Author by

Admin

Updated on October 22, 2020

Comments

  • Admin
    Admin over 3 years

    I try to create a new self certified keystore file

    The command I use is:

    keytool -genkey -selfcert -dname "cn=My Name, ou=Orga unit" -alias selfcertified -keypass somepass -keystore keystore.jks -storepass anotherpass -validity 365
    

    but I always get this annoying error:

    keytool error: java.lang.Exception: Keystore file does not exist: keystore.jks
    

    I do not understand why I'm getting this error. The command above should create a new keystore, so why is it complaining about a non existing store?

  • Admin
    Admin over 13 years
    from the keytool online documentation: A keystore is created whenever you use a -genkey, -import, or -identitydb command to add data to a keystore that doesn't yet exist. (download.oracle.com/javase/1.4.2/docs/tooldocs/solaris/…). according to this, the keytool command should create a new keystore instead of saying it does not exist. could you plz give an example of how to perform these two steps you mentioned?
  • OrangeDog
    OrangeDog over 13 years
    @Chris Friedl - -genkey and -selfcert are separate commands: you can't do both at once.
  • Admin
    Admin over 13 years
    thanks! - two separate commands did it finally. the funny thing is, there are several sites providing tutorials with the two commands in one line as i have written above.
  • Mann
    Mann almost 12 years
    It says store file not found? what is store.jks here?