Most recently, I had a problem with a keystore. I know that there are many questions about this issue. I read them all and google fiercely.
Mistake:
keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect java.io.IOException: Keystore was tampered with, or password was incorrect at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:772) at sun.security.provider.JavaKeyStore$JKS.engineLoad(JavaKeyStore.java:55) at java.security.KeyStore.load(KeyStore.java:1214) at sun.security.tools.KeyTool.doCommands(KeyTool.java:885) at sun.security.tools.KeyTool.run(KeyTool.java:340) at sun.security.tools.KeyTool.main(KeyTool.java:333) Caused by: java.security.UnrecoverableKeyException: Password verification failed at sun.security.provider.JavaKeyStore.engineLoad(JavaKeyStore.java:770) ... 5 more
The software I use:
Java
java version "1.7.0_21" Java(TM) SE Runtime Environment (build 1.7.0_21-b11) Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)
Eclipse
Version: 3.8.0 Build id: I20120502-2000
Latest ADT Plugin
Latest Android SDK
Here is what I know:
- I have not lost my password, and it never changed.
- I can not get the password (I know the password).
- I cannot sign an existing application with a different key without releasing a completely new application (therefore, I cannot publish updates).
Here is what I did:
- I uninstalled and reinstalled Eclipse many times.
- I uninstalled and reinstalled the Android ADT plugin.
- I uninstalled and reloaded the latest version of the Android SDK many times.
- I uninstalled and reinstalled JDK7.
- I tried using backups of my keystore.
- I checked the MD5 checksums using "md5sum KEYSTORE" and compared them with the backups (the same MD5 output was not faked).
- I tried forcibly using the keystore (I received a password that I knew).
- I created a test key (with the current setting) and tested the password, and it seemed to work fine (so something changed).
- I tried to export android.apk manually and then tried to sign it (outside of Eclipse).
This is how I export a signed application:
- Via Eclipse: Export File> Export> Export Android Applications.
- Prior to JDK7: jarsigner -verbose -keystore ALIAS KEY FILES.
- With JDK7: jarsigner -verbose -sigalg MD5withRSA -digestalg SHA1 -keystore ALIAS KEY FILES.
What is left to find out or try?
Do some links / urls indicate the removal of the "trusted.certs" file?Try to remove "debug.keystore"?Will an update to Eclipse or any of the Android development tools affect my keystore?Will updating Java from jdk6 to jdk7 cause any problems?Could this mess up or change the way jarsigner works?
User recommendations:
- Try using JDK6, but I was able to export the application recently.
Checked key.store.password or key.alias.password in my local.propertiesCancel auto build in eclipse and clean your projectTry to delete the .metadata folder in the workspace and clear all temporary folders.
Summary
- Keystores haven't changed
- I have passwords for keystores,
- I recently successfully exported an application using:
- Eclipse 3.8 (and Eclipse 4.0 +),
- The latest version of Java 7,
- The latest ADT plugin.
- My last successful export and build was a few weeks ago using Eclipse 3.8, the latest Android and Java 7 tools with the same password.
Update (6/29/14)
- I used: keytool -list -keystore KEYSTORE to successfully prove and show that 3 of my 4 keys work.
- I checked the last key and got the password from the keystore (the walkthrough I already knew), but the password does not work when I log in to sign it. I used: java -jar AndroidKeystoreBrute_v1.02.jar -m 3 -k KEYSTORE -d WORDLIST.
- Oddly enough, sometimes when I type in my password in eclipse very quickly, my alias will be displayed and I can successfully export my application. (I know this is crazy).
- Updated version of Java.
If I type in a password very quickly, it sometimes works.
It seems that opening Eclipse and entering the password for the first time allows me to use the keystore.
Obviously, if all else fails, I will need to create a new key store. I really would like it to be allowed, I'm just not sure what to do now, besides re-publishing the new key.
If the key cannot be restored properly, I can open it on Github.
Solution (6/29/14):
Special thanks to Erhannis!
Here is what I did:
The command will change every time:
keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -v
Since you told me that we can extract private keys from Java Keystore (.jks), I go deeper and end up using a variant of the command. I followed your links here and here :
keytool -importkeystore -srckeystore old.keystore -destkeystore new.keystore -deststoretype pkcs12
After extracting the private key and storing it as PKCS12, I think I extracted my private key and returned it to the brand new Java Keystore:
keytool -importkeystore -srckeystore new.keystore -srcstoretype pkcs12 -destkeystore final.keystore -deststoretype jks
Literature:
http://developer.android.com/tools/publishing/app-signing.html#signapp
http://code.google.com/p/android-keystore-password-recover/
List of StackOverflow URLs I read:
How to handle lost KeyStore password in Android?
Wrong problem with Keystore?
Android: I lost the keystore for Android, what should I do?
Am I missing a .keystore file?
I forgot the vault password, thinking about Brute-Force discovery. will it be a keystore corruption?
I lost the password for the Keystore file for Android
Problem starting my signed keystore in Eclipse
Android - Forgot your keystore password. Can I decrypt a keystore file?
Key storage problem for Android: "Keystore was changed or password was incorrect"