简体   繁体   中英

keytool error: java.lang.Exception: Keystore file exists, but is empty

I am new to SSL.

I am trying to create keystore for SSL connection using keytool. First I tried the following command

[aniket@localhost bin]$ keytool -genkey -alias myKeyStore -keyalg RSA -keystore
/home/aniket/keystore

It asked me password and other details and finally gave me following error

keytool error: java.io.FileNotFoundException: /home/aniket/keystore 
(Is a directory)

So I created a file keystoreFile.txt inside keystore folder and executed

[aniket@localhost bin]$ keytool -genkey -alias myKeyStore -keyalg RSA -keystore
/home/aniket/keystore/keystoreFile.txt

and now(no prompt for password etc) I am getting

keytool error: java.lang.Exception: Keystore file exists, but is empty:
/home/aniket/keystore/keystoreFile.tx

What should be the contents of the file. I though keytool will generate key pair (a public key and associated private

Delete the empty keystoreFile.txt, then run your 2nd command again

[aniket@localhost bin]$ keytool -genkey -alias myKeyStore -keyalg RSA -keystore
/home/aniket/keystore/keystoreFile.txt

It's trying to create the file you specify with the -keystore flag. The reason your first one command failed is that you gave it an existing directory name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM