36

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

2
  • Keystores aren't text files. Don't use the .txt extension for things that aren't text. Commented Sep 20, 2013 at 12:26
  • @EJP yeah changed it to keystoreFile.jks. Commented Sep 20, 2013 at 12:41

1 Answer 1

40

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.