Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make keytool not prompt for password for the key?

Tags:

keytool

jks

I am trying to generate a keystore. I have set a password for the keystore but I am trying to not set a password for the key.

keytool -storepass "$password" -keystore ${PFX_broker}server.keystore.jks -alias $brokerCertAlias -validity $validity -genkey -dname "CN=$CN" -noprompt;

The above command will prompt me for a key password which defaults to the store pass when I press enter.

Is it possible to skip setting a password for the key altogether and not have a prompt?

like image 729
Dikshant Adhikari Avatar asked Jan 18 '18 19:01

Dikshant Adhikari


People also ask

Can I create a keystore without password?

You cannot create a keystore with a blank password with keytool since a while, but you can still do it programmatically.

What is the difference between keystore password and key password?

Keystore is a binary file that contains a set of private keys. Private key represents the entity to be identified with the app, such as a person or a company. So Keystore password is used to open a keystore and simple password is password of private entity stored in keystore file..!!

Which argument is specifies the password for the key in the keystore?

The password which is used to protect the integrity of the keystore. If the modifier env or file is not specified, then the password has the value argument, which must be at least 6 characters long. Otherwise, the password is retrieved as follows: env: Retrieve the password from the environment variable named argument.


2 Answers

There are parameters to specify key and store passwords

-keypass <your-pass> and -storepass <your-pass>

E.g.

keytool -storepass pass123 -keypass pass123 -keystore keystore.jks -alias myalias -validity 99 -genkey -noprompt

keytool reference

like image 200
Alex Avatar answered Sep 20 '22 13:09

Alex


I know this is an old question but I'm facing the same issue and adding -keypass password and because I have a store source too, I'm adding -srcstorepass password for me works. Try this:

keytool -storepass "$password" -keystore ${PFX_broker}server.keystore.jks -alias $brokerCertAlias -validity $validity -genkey -dname "CN=$CN" -noprompt -keypass "$password" -srcstorepass "$password"

But might be different in your case.

like image 40
David Aleu Avatar answered Sep 18 '22 13:09

David Aleu