Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create keystore file with one command

I have a script which creates and signs a keystore file for an android app.

It is working perfectly fine but i would rather have it run without human intervention

what i have to create the keystore:

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

This then prompts me to enter the following values manually using the terminal: keystore password, full name , organisation unit, organisation name, city , state, county code, key password.

what i have to sign the app:

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

This then prompts me to enter passphrase for keystore.

Is there anyway i can pass these values in as parameters so the full script runs without anyother interaction needed?

PS: i'm using ubuntu 14.04 LTS.

Thanks For your time :)

like image 947
PeterG Avatar asked May 27 '16 16:05

PeterG


People also ask

How do I run a keystore in command prompt?

In the command prompt, invoke the keytool utility: (For Microsoft Windows) Type keytool.exe and press Enter. (For UNIX) Type keytool and press Enter.


1 Answers

You can do something like this to generate the 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 reference : https://pubs.vmware.com/continuent/tungsten-replicator-3.0/deployment-ssl-stores.html. And for the jarsigner there is "storepass" parameter for the keystore password. And if you put both in a script you should be good.

like image 89
Sanjeev Avatar answered Oct 22 '22 10:10

Sanjeev