3

I know this has been asked before but almost only workarounds have been provided. None that solved my problem just yet.

I'm trying to create my own .sh file which will generate an apk. After using jarsigner it asks for a password of my keystore. Now the security on this part doesn't play a role a.t.m. so I was just wondering, how can I (either remove the password of my .keystore file or enter the password as plain text) achieve this?

The full command:

jarsigner -sigalg SHA1withRSA -digestalg SHA1 -verbose -keystore keyForApk.keystore 
  apk/android-release-unsigned.apk alias_name

Where it then prompts me the following:

Enter Passphrase for keystore:

Now via which command can I enter this dynamically after the jarsigner command?

  • I'm not familiar with jarsigner, but it's possible that it's trying to directly read your terminal; test it out with echo | jarsigner -sigalg .... rest of it – Jeff Schaller Oct 17 '16 at 13:44
  • for testing you can provide passwords in the command line with options -storepass and -keypass. see man jarsigner. – meuh Oct 17 '16 at 13:51
2

You could use expect utility to automate your passphrase input. Create launcher script auto-jar.sh:

#! /usr/bin/expect

spawn jarsigner ... # actual command here
expect "Enter Passphrase for keystore: "
send "jar_password\r"
| improve this answer | |
  • "spawn" is not found. I installed expect and "expect" is found – canbax Jul 26 '19 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.