generating signature with SHA256withRSA rather than SHA1withRSA

做~自己de王妃 提交于 2019-12-05 08:47:31
Mike K

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

Are you using JDK 1.7? If yes, use these parameters for keytool:

-sigalg SHA1WithRSA -digestalg SHA1

With JDK 1.6 you can try swapping the position of -v and -list (I know, sounds weird) to get all possible algorithms (MD5, SHA1, SHA256)

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!