Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using keytool to get the MD5 signature of a certificate

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.

like image 800
Zelig Avatar asked Oct 31 '11 13:10

Zelig


1 Answers

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):

MinGW screenshot

like image 118
Alexander Farber Avatar answered Oct 05 '22 06:10

Alexander Farber