Reputation: 1808
I need to get a Google map key for my application and, for this, I need the MD5 signature of my certificate. As seen on the Internet, I use "keytool" to get it :
keytool -list -alias mykey -keystore mykeystore
The problem is that the answer is a SHA1 signature instead of an MD5 signature.
I use JDK 1.7.
What am I doing wrong?
Thanks in advance for the time you will spend trying to help me.
Upvotes: 5
Views: 7668
Reputation: 22958
Hello in the year 2021.
The keytool of JDK 8 and newer does not print MD5 anymore, even if you try the standard suggestion to add the "-v" option to the "keygen -list" command.
I guess MD5 is no more considered secure enough and has been removed.
At the same time there are still places like Amazon "Security Profile Management" for LWA etc. requiring you to submit the MD5 signature of your certificate.
Here is a command which will deliver it (use the password "android" for the Android Studio keystore):
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | \
openssl dgst -md5
And if you want to have colon character inbetween, then add the following "sed" command:
keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore | \
openssl dgst -md5 | \
sed 's/[a-fA-F0-9][a-fA-F0-9]/&:/g; s/:$//'
The above command works on Linux, macOS and even Windows (in git bash):
Upvotes: 8
Reputation: 1225
keytool -exportcert -alias alias -keypass keypass -keystore ./test.keystore -storepass 123456 | md5sum
Upvotes: 1
Reputation: 1026
There is another Post about this same thing How can I get the MD5 fingerprint from Java's keytool, not only SHA-1?
I guess JDK 1.7 defaults to SHA1. To fix this the following has worked:
C:\Program Files\Java\jdk1.7.0\bin>keytool -v -list -alias
androiddebugkey -keystore debug.keystore -storepass android -keypass android
I tried this, and it worked for me. It gives you MD%, SHA1, SHA256 and Signature Algorithm Name. In that order.
Upvotes: 3
Reputation: 128428
Have you tried the keytool command as:
$ keytool -list -keystore ~/.android/debug.keystore
More on getting Map API Key is Here: http://code.google.com/android/maps-api-signup.html
As you are using JDK 1.7, there is a new command line argument to its keytool, namely -keyalg.
I know you can specify -keyalg RSA, so maybe -keyalg MD5 will give you the right key.
Upvotes: 0