Create a keystore file with a single command

I have a script that creates and signs a keystore file for an Android application.

It works fine, but I would prefer it to work without human intervention

what I need to create a keystore:

keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -keysize 2048 -validity 10000 

Then I am asked to enter the following values ​​manually using the terminal: cache password, full name, organization unit, organization name, city, state, county code, key password.

what I need to sign the application:

 jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore my-release-key.keystore my_application.apk alias_name 

Then I am asked to enter a passphrase for the keystore.

In any case, can I pass these values ​​as parameters, so does the full script work without any interaction?

PS: I am using ubuntu 14.04 LTS.

Thank you for your time:)

+6
source share
1 answer

You can do something like this to create a keystore:

 keytool -genkey -alias replserver \ -keyalg RSA -keystore keystore.jks \ -dname "CN=Mark Smith, OU=JavaSoft, O=Sun, L=Cupertino, S=California, C=US" \ -storepass password -keypass password 

Here is a good link: https://pubs.vmware.com/continuent/tungsten-replicator-3.0/deployment-ssl-stores.html . And for jarsigner there is a "storepass" parameter for the keystore password. And if you put both in a script, you should be good.

+16
source

All Articles