Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

generating signature with SHA256withRSA rather than SHA1withRSA

I been trying to generate the sha1 key for using google maps v2 on windows7. According to google docs after running below command:

keytool -list -v -keystore "C:\Users\your_user_name\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

the output should be similar to this(https://developers.google.com/maps/documentation/android/start#getting_the_google_maps_android_api_v2)

 Alias name: androiddebugkey
 Creation date: Jan 01, 2013
 Entry type: PrivateKeyEntry
 Certificate chain length: 1
 Certificate[1]:
 Owner: CN=Android Debug, O=Android, C=US
 Issuer: CN=Android Debug, O=Android, C=US
 Serial number: 4aa9b300
 Valid from: Mon Jan 01 08:04:04 UTC 2013 until: Mon Jan 01 18:04:04 PST 2033
 Certificate fingerprints:
      MD5:  AE:9F:95:D0:A6:86:89:BC:A8:70:BA:34:FF:6A:AC:F9
      SHA1: BB:0D:AC:74:D3:21:E1:43:07:71:9B:62:90:AF:A1:66:6E:44:5D:75
      Signature algorithm name: SHA1withRSA
      Version: 3 

My Output:

    Alias name: androiddebugkey
    Creation date: 12-Jun-2013
    Entry type: PrivateKeyEntry
    Certificate chain length: 1
    Certificate[1]:
    Owner: CN=Android Debug, O=Android, C=US
    Issuer: CN=Android Debug, O=Android, C=US
    Serial number: 57376504
    Valid from: Wed Jun 12 16:22:47 BST 2013 until: Fri Jun 05 16:22:47 BST 2043
    Certificate fingerprints:
             MD5:  xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
             SHA1: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
             Signature algorithm name: SHA256withRSA
             Version: 3    

   Extensions:

   #1: ObjectId: 2.5.29.14 Criticality=false
   SubjectKeyIdentifier [
   KeyIdentifier [
   0000: 5D 1C 48 72 D9 E2 F0 1A   12 CE 97 CC 1F DA DD F6  ].Hr............
   0010: C9 D0 1E 62                                        ...b
   ]
   ]

But in my case the the output is similar but except.

Signature algorithm name:SHA256withRSA

Can someone tell me how to key generated by SHA1withRSA. The reason to ask this question was when i am trying to use the google maps v2 in my android application. The following error is displayed. I am guessing SHA256withRSA could be a reason for this error.Its been a couple of days i am stuck with authorization failure.It would be really great if someone can help me.. Thanks..

Authorization failure.  Please see https://developers.google.com/maps/documentation/android/start for how to correctly set up the map.
like image 262
troy Avatar asked Oct 21 '22 07:10

troy


1 Answers

For others encountering this problem: I was having a hard time getting Google Maps API v.2 to work using JDK 1.7 -- I kept getting an Authorization Failure message. The problem was, in fact, the signature algorithm name.

I figured out how to generate the right debug keystore, using SHA1. Here's the command I used:

keytool -genkey -v -keyalg RSA -sigalg SHA1withRSA -keystore "%USERPROFILE%\.android\debug.keystore" -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"

After generating it, you can see it by using the command:

keytool -list -v -keystore "%USERPROFILE%\.android\debug.keystore" -alias androiddebugkey -storepass android -keypass android

The Signature algorithm should now read "SHA1withRSA". Copy the SHA1 fingerprint and paste it in the Google console "Key for Android apps", and you should be good to go.

Please note: Make sure you delete the debug.keystore if it already exists before creating a new one using the first -genkey command above. If the keystore already exists, it will give you an error of keystore already exists with the given -alias androiddebugkey

like image 138
Mike K Avatar answered Oct 24 '22 04:10

Mike K