keytool error: java.security.UnrecoverableKeyException: Cannot recover key android - android

I can't signed my apk with the existing keystore. Its giving me this error when signing:
com.android.ide.common.signing.KeytoolException: Failed to read key Cannot recover key
So, by following this link, I have tried to change the password but its giving me keytool error: java.security.UnrecoverableKeyException: Cannot recover key error when executing this command:
keytool -keypasswd -alias %MyKeyAlias% -new %newpassword% -keystore KeyStore.jks
I have already a version available in playstore using this keystore.

I finally solved it by reading the document:
https://www.rickyadams.com/wp/index.php/2017/11/15/keytool-java-keystore-ssl/
As I use a different storepass and keypass.
Verify the private key password by attempting to change it
> keytool -keypasswd -keystore KEYSTORE -alias ALIAS -storepass PASSWORD
This is the output you’ll see if a key password isn’t set, or if the key password is the same as the store password:
New key password for <ALIAS>:
This is the output you’ll see if a key password is set and you enter it incorrectly:
Enter key password for ALIAS:
keytool error: java.security.UnrecoverableKeyException: Cannot recover key
This is the output you’ll see if a key password is set and you enter it correctly:
Enter key password for <ALIAS>:
New key password for <ALIAS>:

Looks like missing private key.

Related

No key with alias 'foo' found in keystore keystore.jks

I have runkeytool -v -list -keystore keystore.jks and made sure that the alias is key0, but even though I specify key0 as the alias in my gradle file, I still get the error "No key with alias 'foo' found in keystore keystore.jks". I don't know where it is getting this "foo" alias from.
bro first check your password first, if your password is correct then you can get the key Alias, Just put your password in the first field and then click on the tinny filder located on the field of Alias in Right side, new Dialog Box will be appear which shows your Key Alias, Happy coading.

Generate signed apk android studio - Error with key

I am trying to generate signed apk with an exiting keystore
but i have following problem
Error:org.gradle.tooling.BuildException: Failed to read key MedicalAssistanceKey from store "D:\MedicalAsError:com.android.ide.common.signing.KeytoolException: Failed to read key MedicalAssistanceKey from store
"D:\MedicalAss_download\MyKey.jks": Cannot recover keys_download\MyKey.jks": Cannot recover key
Error:java.security.UnrecoverableKeyException: Cannot recover key
I am sure the password and key are correct
The keystore and key passwords have to be the same.
You could use commands to modify passwork as below:
keytool -storepasswd -new [insert new keystore password] -keystore [insert keystore file name]
keytool -keypasswd -alias [insert alias] -new [insert new key password] -keystore [insert keystore file name]
Or if you like GUI, download from http://keystore-explorer.org/
Note: keytool.exe exists in jdk/bin folder or jre/bin folder.
if you have special characters in your passwords use this tool to change it:
http://keystore-explorer.org/
special characters like Ç

Cannot recovery key in Android Studio

I want build and generate my android project, and i use my keystore file. but when build app show me this error :
Change the keystore for a diferent password to the key password.
Open a CMD prompt in key.jks location, then change a keystore password:
keytool -storepasswd -keystore keyName.jks
Enter keystore password: (Old Keystore)
New keystore password: (New Keystore)
Re-enter new keystore password: (Re-enter new Keystore)
Now change the key password for a diferent password:
keytool -keypasswd -keystore key.jks -alias key
Enter keystore password: (The new Keystore you recently changed)
New key password for <key>: (New diferent key password)
Re-enter new key password for <key>: (Re-enter new diferent key password)

Check android keystore keypass for correctness

I'm automating some things that involve the android keytool and jarsigner. The tool takes a keystore, the password for the keystore, the alias name, and the password for the alias / key, and I'm trying to find a way to explicitly check to see if the supplied password for the alias / key is correct.
Any ideas? Also, I need to check it without a jar file to sign - getting that file in my context is lengthy, so I want to abort sooner rather than later.
You can also check if the password is correct without attempting to change the password. I did it by listing the properties of the keystore with this command:
keytool -list -keystore <keystorefile> -storepass <passwordtocheck>
You can do it a couple of ways:
A. With keytool
If you run the command keytool -keypasswd -keystore <keystore> -alias <alias> -storepass <storepass> -keypass <keypass> -new <keypass> then you will get the error Keystore was tampered with, or password was incorrect if the keystore password is wrong, or the error Cannot recover key if the alias password is wrong. Unfortunately the return code is 1 in both cases, so you will need to do parsing of the program's output if you want to be smart about the type of error.
B. With a small Java program
Something along these lines:
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
try (FileInputStream fis = new FileInputStream(keystore)) {
ks.load(fis, ksPw.toCharArray());
}
ks.getEntry(alias, new KeyStore.PasswordProtection(aliasPw.toCharArray()));
will fail at line 4 with a java.io.IOException if the key store password is wrong, or with a java.security.UnrecoverableKeyException at line 7 if the alias password is wrong.

Lost keystore alias but have file and password used for alias

recently I added a new alias to my keystore to sign my app.
Now I lost the new generated file with the alias, but remember the password and the alias name and have an older copy the file. Is there a way to recreate the alias using this things?
You can list the contents of your keystore with the command:
keytool -list -keystore <name of keystore file>
To do this, you will need to provide the keystore password (not the alias password). This will tell you the aliases in the file, which are self-contained, allowing you to sign. If you wish, you could also extract keys using other options / tools.
Open your key store (.jks) file with text editor. It will display binary form of data. The readable text in the first line is your key alias.
For example, your key alias in the following binary data is the key alias.
þíþí your key alias UYY_ 0‚þ0
+* ‚êa÷í–ØRö}ðžá䶈ùÎL\ô©2‘wå¥H¨V †¸®Àµ£ð×þ7—â;TÁÙcsª”ž˜4ÝÉ'AÀì,’„×S¼ðßÅ'€Õ¡ó‚˜ ö!y’Çåx|(woÁh4u-û†‚‡§Qȸ|ˆ³”ÜæûZŽ²a±O­´¢^À.ªbÅ“e†6 É秮j§˜y ößÿØ0Çd# /Ã?®¦ìé¼/§Zq””Ê•©„=~Ùì¢>º}DàO<Ö¹SbpÎŒ#Ø„°^Í^e»>¾ü«nM(
"Nbûh·2ðÁ0¯ç¿61êè“[.ÇzeYŽºXkuÄy*ôq¥FSs]:2“ì
http://tim12332013.blogspot.tw/2014/10/corona-sdk-android-keystore-lost-alias.html
look it may help you
keytool -list -v -keystore X:/XXXX /XXXX.keystore -storepass XXXX
This worked for me:
keytool -list -v -keystore "file address"
Copy your alias name and TaDa!!!
The default alias in latest android studio version is "key0". You can try this if you haven't changed your alias value.

Categories

Resources