且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与SHA256withRSA而不是SHA1withRSA生成签名

更新时间:2022-12-16 20:39:56

对于其他人遇到这样的问题:我有一个很难得到谷歌地图API第2版使用JDK 1.7的工作 - 我一直得到授权失败消息。问题是,事实上,签名算法名。

我想出如何生成合适的调试密钥库,使用SHA1。下面是我使用的命令:

 的keytool -genkey -v -keyalg RSA -sigalg SHA1withRSA -keystore%USERPROFILE%\\。机器人\\ debug.keystore-storepass android的-alias androiddebugkey -keypass android的-dnameCN = Android的调试,O =机器人,C = US

生成后,您可以通过使用命令看看吧:

 的keytool -list -v -keystore%USERPROFILE%\\。机器人\\ debug.keystore-alias androiddebugkey -storepass的android -keypass android的

签名算法现在应该改为SHA1withRSA。复制SHA1指纹,并粘贴在谷歌控制台for Android应用程序键,你应该是好去。

请注意:请确保您删除debug.keystore如果创建使用上面的第一个-genkey命令创建一个新的人之前已经存在。如果密钥库已经存在,它会给你的密钥库的错误已经给定-alias androiddebugkey

存在

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.

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