I am getting following error while generating certificates on my local machine.
C:\Users\abc>keytool -genkey -alias tomcat -keyalg RSA
Enter keystore password:
keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect
I think there is some problems in jdk version.I ran the same command on my collegues machine and it is working fine.
Please share your inputs.
I solved it by using the default password for cacerts keystore : 'changeit'
This answer will be helpful for new Mac User (Works for Linux, Window 7 64 bit too).
Empty Password worked in my mac . (paste the below line in terminal)
keytool -list -v -keystore ~/.android/debug.keystore
when it prompt for
Enter keystore password:
just press enter button (Dont type anything).It should work .
Please make sure its for default debug.keystore file , not for your project based keystore file (Password might change for this).
Works well for MacOS Sierra 10.10+ too.
I heard, it works for linux environment as well. i haven't tested that in linux yet.
From your description I assume you are on windows machine and your home is abc
So Now : Cause
When you run this command
keytool -genkey -alias tomcat -keyalg RSA
because you are not specifying an explicit keystore it will try to generate (and in your case as you are getting exception so to update) keystore C:\users\abc>.keystore and of course you need to provide old password for .keystore while I believe you are providing your version (a new one).
Solution
Either delete .keystore from C:\users\abc> location and try the command
or try following command which will create a new xyzkeystore:
keytool -genkey -keystore xyzkeystore -alias tomcat -keyalg RSA
Note: -genkey is old now rather use -genkeypair althought both work equally.
According to the documentation:
The default password for the debug keystore is android.
I have solve this issue by using default password "changeit".
Using changeit for the password is important too.
This command finally worked for me(with jetty):
keytool -genkey -keyalg RSA -alias selfsigned -keystore keystore.jks -storepass changeit -validity 360 -keysize 2048
In tomcat 8.5 pay attention to write the correct name of attributes. This is my code on server.xml:
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/keystore" certificateKeystorePassword="mypassword" type="RSA"/>
</SSLHostConfig>
</Connector>
You can visit https://tomcat.apache.org/tomcat-8.5-doc/config/http.html to see all attributes
If you are working on signing your Flutter App by following this guide Build and release an Android app and run in to this error. I hope this answer helps you.
In my case I changed the path to store my key.jks. This happened to me because I there was an existing file in that path.
keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
This command stores the key.jks file in your home directory. To store it elsewhere, change the argument you pass to the -keystore parameter.
In my case,
keytool -genkey -v -keystore /Users/Y/Desktop/X/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias keyYour
i.e Y - Username and X - folder name
Then you will be prompted to Enter keystore password: and Re-enter new password:. Here you can use whatever password you want.
However, keep the keystore file private; don’t check it into public source control!
Empty password worked for me on my Mac
keytool -list -v -keystore ~/.android/debug.keystore
hit Enter then It's show you
Enter keystore password:
here just hit Enter for empty password
Works on Windows
open command prompt (press Windows Key + R then type "cmd" without quotations in the appearing dialogue box and then press Enter Key).
then type the code sniff below :
cd C:\Program Files\Java\jdk1.7.0_25\bin
then type following command
keytool -list -keystore "C:/Documents and Settings/Your Name/.android/debug.keystore"
Then it will ask for Keystore password now. The default password is
"android" type and enter or just hit enter "DONT TYPE ANY PASSWORD".
Summarizing the advices from this page, I finished up with the following:
keytool -genkeypair -keystore ~/.android/release.keystore -alias <my_alias> -storepass <my_cert_pass> -keyalg RSA
Then I got a set of questions regarding name, organization, location and password for my alias.
Check your home folder ~/.gradle/gradle.properties. Sometimes if you have gradle.properties in home directory it takes details from the there. Either you can change that or delete the files. Then it will take required details from your local folder.
I fixed this issue by deleting the output file and running the command again. It turns out it does NOT overwrite the previous file. I had this issue when renewing a let's encrypt cert with tomcat
keytool error: java.io.IOException: Keystore was tampered with, or password was incorrect
I solved my problem when I changed keystore path C:\MyWorks\mykeystore to C:\MyWorks\mykeystore.keystore.
In my case I was needed to have root access.
[root#localhost Certificate]# openssl pkcs12 -export -in
/opt/Certificate/115c99f4c5aa98f5.crt -inkey /opt/Certificate/ravi.in.key -certfile
/opt/Certificate/gd_bundle-g2-g1.crt -out RaviNew.p12
Enter Export Password: <Password>
Verifying - Enter Export Password: <Password>
Note :- Above Export Pasworrd write down anywhere because it is must to create JKS file ( It is depend on your choice what password you want to make )
keytool -importkeystore -srckeystore DigiEduNew.p12 -srcstoretype pkcs12 -destkeystore finaldigiEdu.jks -deststoretype JKS
Importing keystore DigiEduNew.p12 to finaldigiEdu.jks...
Enter destination keystore password: <Any Password >
Re-enter new password: <Any Password >
Enter source keystore password: <.P12 Password >
Entry for alias 1 successfully imported.
Import command completed: 1 entries successfully imported, 0 entries failed or
cancelled
Warning:
The JKS keystore uses a proprietary format. It is recommended to migrate to PKCS12
which is an industry standard format using "keytool -importkeystore -srckeystore
finaldigiEdu.jks -destkeystore finaldigiEdu.jks -deststoretype pkcs12".
For me I solved it by changing passwords from Arabic letter to English letter, but first I went to the folder and deleted the generated key then it works.
In my case with Xamarin Forms 4.7 and Visual Studio 2019 16.7.0 Preview 3.1, the problem was version mismatch of lately updated Android Build tools (apksigner) and JDK. Updated JDK to latest and pointed the new JDK path on Tools->Options->Xamarin->Android Settings, and it works.
Just upgraded to Android Studio 4.2 from 4.0. Apparently, Android Studio silently CHANGED my keystore password, which has been sitting there unchanged and working perfectly without incident for well over a year.
Just had to re-renter both passwords.
Sigh
If you already have a .store file, you have to use the same password as you did to generate it. So in my case the solution was:
rm *.store
rm *.cer
That may sound odd to you but I'm just trying to learn about keytool and am source controlling my tutorial files and rerunning them later!
you have two options:
cmd doesn't show the password on the screen while typing
so just type the correct passwd -and be careful- then press enter.
Or
just use:
keytool -list -keystore 'keystoreName' -storepass 'type your keystore passwd'
and for Keys' full info, add -v:
keytool -v -list -keystore 'keystoreName' -storepass 'type your keystore passwd'
This answer is helpful for those who manage multiple keystores across different projects.
I had the same error and I noticed I was using a file keystore.jks with the password of another keystore.jks which throws this exception since the password doesn't match.
With openjdk I had the same problem.
After I updated openjdk to "11.0.17" the problem was gone.
I'm currently busy building a ionic app. I am busy with facebook login and for me to register my app on the facebook developers dashboard i need to give info on the app.
One of them are that i need to generate a hash key. to do that i need to run the following command from within my java/bin
keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android
then i get this error when i do that
keytool error: java.lang.Exception: Keystore file does not exist:
C:\Users\Reyno.android\debug.keystore
this basically means the file isnt there right.
So my question is how can i generate a new one without installing android studio. I know it wil generate a new one if i install android studio.
ref: Where is debug.keystore in Android Studio
Thanks in advance
I found a solution to this question after a bit of futher investigation. It's quite simple.
(1)Open your cmd as administrator
(2)navigate to your keytool directory. Mine was located at "C:\Program Files\Java\jdk-"
13.0.1\bin\keytool"
(3)enter the following command
keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -
keysize 2048 -validity 10000
(4)answer the questions they ask, i'll list them below
Enter keystore password
Reenter keystore password
What is your first and last name?
What is the name of your organizational unit?
What is the name of your organization?
What is the name of your city?
What is the name of your state or province?
What is the two-letter country code for this unit?
They wil then just ask you to confirm if the details are correct, you can just type "Y" for yes. If you use "N" for no they wil ask you to complete the questions again.
(5)Go to your java jdk directory, in my case it was C:\Program Files\Java\jdk-13.0.1\bin\
Then search for a file called "my-release-key.keystore"
Please copy it and save it in a safe place you wil need to use it everytime you
publish or update your app.
Hope this helps someone
I am trying to get my key and it says to paste the following command
keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
I do not understand how this works, am I supposed to change some of that text? When I paste it as is it asks me for a password, what password is it asking for?
Thanks
It seems you are going to publish your first Android app. I recommend you to read this official guide before you do it.
If you are too lazy to read all the stuff, at least read this article about your specific issue.
Good luck :)
you are generating key .When you do this. you must give password and other information (name etc.) .you must store this values. and Dont lost your key.if you delete or lost. your app cannot be updated.
While the other answers given are correct, here is a more React Native oriented answer:
I assume you are following the Generating Signed APK steps in the docs (if not, you should be). The command it tells you to run should be customized by changing 2 of the parameters to be app-specific:
Change my-release-key.keystore (e.g. todo-release-key.keystore)
Change my-key-alias (e.g. todo-key)
When you run the command it will ask you for a password for the keystore and key it creates (the same way you get asked for a password when creating a new SSH key). It will also ask you for the Distinguished Name for the certificate. Here is a good answer on what you should enter here: https://stackoverflow.com/a/3284135/1949302
From there, just continue following the steps in the documentation, replacing the keystore and alias values to the ones you used when running the command.
Follow the below steps for windows os:
1 Open cmd as administrator
2 In cmd go to C:\Program Files\Java\jdk1.8.0_131\bin> // check your file name
cd C:\Program Files\Java\jdk1.8.0_131\bin>
3 Enter the following command in cmd
keytool -genkey -v -keystore F:/my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
Then give Answers in cmd and then my-release-key.keystore will be created in F: drive
I am developing a PhoneGap application through Eclipse on the Android platform. My code is ready and run perfectly.
Now, I already created a signed APK file in release mode. So, when I uploaded this keystore file on "build.phonegap.com", and clicked on Submit key, I got an error like this:
Error: extension did not match expected (keystore)"
I don't know what is going wrong in this. Is there a proper solution?
A command-line solution:
keytool -genkey -v -keystore yourappname.keystore -alias appnamealias -keyalg RSA -keysize 2048 -validity 10000
According to: This Post
When you are creating your keystore file in Eclipse make sure to manually set the file extension to ".keystore" - instead of the default file name with no extension.
What tools do we need to develop an Android keystore file?
The Android keystore file can be created in the Java Development Kit (JDK), and to download the installation file, click on this link: Install JDK.
How do we create the Android keystore file?
Standard procedure: First you need to open the command prompt as administrator
To go from a directory to its parent directory, write cd.. (push the Enter button). Keep doing it until you reach c:>.
When you are at c:/, write cd Program files (push the Enter button).
cd Java (push the Enter button).
cd jdk1.7.0_03 (push the Enter button).
cd bin (push the Enter button).
**keytool -genkey -v -keystore Your_personal_file_title.keystore -alias Your_personal_alias -keyalg RSA -keysize 2048 -validity 10000** (push the Enter button).
Remember to edit the two text file Your_personal_file_title and Your_personal_alias.
And enter your profile information.
Afterwards it will create your Android keystore file in your C:\Program files\Java\jdk1.7.0_03\bin directory, with the name you gave it…
You now have your keystore file and can activate it in whatever application you generate your Android apps in (for example, build.phonegap.com).
Please remember to use CMD as administrator.
You need to create your own .keystore file. To do this:
Open CMD
Type:
cd C:\java path\java\jdk7\bin
keytool -genkey -v -keystore yourappname.keystore -alias appnamealias -keyalg RSA -keysize 2048 -validity 10000
After that you will have a new release keystore.
I've used phonegap Build to create my .apk file and i'm trying to sign it.
I understand that I can do this with the following command:
$ keytool -genkey -v -keystore my-release-key.keystore -alias alias_name -keyalg RSA -validity 10000
But when I run this in terminal I get 'command not found' ?
I'm running this on a mac so from what I've read I have the required JDK installed ( I have xcode ) I guess it might be that the PATH is not set correctly to keytool, but I'm unable to find any simple info on resetting this.
Any help would be hugely appreciated. I must be missing something very simple as it can not be this difficult to sign the app ?!?!
This was a nightmare for me, such a seemingly simple task took far too long.
to locate Keytool on a mac
first type this into command prompt:
/usr/libexec/java_home -v 1.7
it will spit out something like:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home
keytool is located in the same directory as javac. ie:
/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin
From bin directory you can use the keytool.
I usually use the APK tools in Eclipse to sign keys but I generated the fingerprint in past and didn't record it. I need keytool to tell me that value...
Hopefully that helps someone else
Just a note i had to add './' in front within the keytool location.
Keytool Location
/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/keytool
Command run
./keytool -genkey -v -keystore ~/key.jks -keyalg RSA -keysize 2048 -validity 10000 -alias key
Hope that helps someone.
Make sure you have cd'd into the android-sdk/platform-tools directory (where the keytool will [most likely] reside). The command won't be found if you aren't in the keytool-containing directory.
keytool comes with the Java Development Kit (JDK). So look for the directory that contains javac, java and you will find keytool present over there. You can run it directly from that directory or set the PATH.
I had this same error when running on Mac.
Removing the '$' worked for me, and was then prompted to enter the details to create the keystore.
I then had trouble finding the keystore, as I thought it would be within .android under my user account, but it was actually saved straight to my user account [cd users/YourUserName]
Hope that helps anyone with the same issue
New location for keytool if you have Android Studio installed is
/Applications/Android\ Studio.app/Contents/jre/Contents/Home/bin/