如何在 Android 上获取 OAuth 2.0 的签名证书指纹 (SHA1)?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12214467/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 10:02:29  来源:igfitidea点击:

How to obtain Signing certificate fingerprint (SHA1) for OAuth 2.0 on Android?

androidoauth-2.0

提问by Alex

I'm trying to register my android app following the steps in https://developers.google.com/console/help/#installed_applicationswhich leads me to follow http://developer.android.com/tools/publishing/app-signing.html.

我正在尝试按照https://developers.google.com/console/help/#installed_applications中的步骤注册我的 android 应用程序, 这导致我关注 http://developer.android.com/tools/publishing/app-签名.html

However, I'm not sure how to get the signing certificate fingerprint (SHA1).

但是,我不确定如何获取签名证书指纹(SHA1)。

I first used the Eclipse ADT plugin to export and create the keystore/key. Then, I tried doing keytool -list keystore mykeystore.keystoreand it gives me a MD5 Certificate fingerprint. Do I need to redo the signing (meaning I can't use the eclipse export wizard)?

我首先使用 Eclipse ADT 插件来导出和创建密钥库/密钥。然后,我尝试这样做keytool -list keystore mykeystore.keystore,它给了我一个 MD5 证书指纹。我是否需要重做签名(意味着我不能使用 eclipse 导出向导)?

Can I use a debug certificate first?

我可以先使用调试证书吗?

回答by Frederick Nyawaya

Start an export process to create an apk for your app and use your production key. The very last page displays both your SHA1 and MD5 certificate fingerprints enter image description here

启动导出过程,为您的应用创建 apk 并使用您的生产密钥。最后一页显示您的 SHA1 和 MD5 证书指纹在此处输入图片说明

回答by Nick

I know this question has been answered but this is how I found my signature for the default keystore. In Eclipse, if you go to Windows -> Preferences -> Android -> Build

我知道这个问题已经得到解答,但这就是我找到默认密钥库签名的方式。在 Eclipse 中,如果你去 Windows -> Preferences -> Android -> Build

enter image description here

在此处输入图片说明

回答by Ravi

I think this will work perfectly. I used the same:

我认为这将完美地工作。我用了同样的:

For Android Studio:

对于安卓工作室:

  1. Click on Build> Generate Signed APK.
  2. You will get a message box, just click OK.
  3. Now there will be another window just copy Key Store Path.
  4. Now open a command prompt and go to C:\Program Files\Java\jdk1.6.0_39\bin>(or any installed jdk version).
  5. Type keytool -list -v -keystoreand then paste your Key Store Path(Eg. C:\Program Files\Java\jdk1.6.0_39\bin>keytool -list -v -keystore "E:\My Projects \Android\android studio\signed apks\Hello World\HelloWorld.jks").
  6. Now it will Ask Key Store Password, provide yours and press Enterto get your SHA1 and MD5 Certificate keys.
  1. 单击Build> Generate Signed APK
  2. 您将收到一个消息框,只需单击“确定”即可。
  3. 现在将出现另一个窗口,只需复制Key Store Path 即可
  4. 现在打开命令提示符并转到C:\Program Files\Java\jdk1.6.0_39\bin>(或任何已安装的 jdk 版本)。
  5. 键入keytool -list -v -keystore然后粘贴您的密钥存储路径(例如 C:\Program Files\Java\jdk1.6.0_39\bin>keytool -list -v -keystore "E:\My Projects\Android\android工作室\签名的 apks\Hello World\HelloWorld.jks”)。
  6. 现在它将询问密钥存储密码,提供您的密码并按下Enter以获取您的 SHA1 和 MD5 证书密钥。

回答by Randy Sugianto 'Yuku'

If you are using Mac or even Linux, just copy and paste this onto the Terminalapplication and you will get the SHA1 key immediately. No need to change anything.

如果您使用的是 Mac 甚至 Linux,只需将其复制并粘贴到终端应用程序上,您将立即获得 SHA1 密钥。不需要改变任何东西。

 keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

Example output:

示例输出:

Alias name: androiddebugkey
Creation date: 17 Feb 12
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: 4f3dfc69
Valid from: Fri Feb 17 15:06:17 SGT 2012 until: Sun Feb 09 15:06:17 SGT 2042
Certificate fingerprints:
     MD5:  11:10:11:11:11:11:11:11:11:11:11:11:11:11:11:11
     SHA1: 11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:11:01:11
     Signature algorithm name: SHA1withRSA
     Version: 3

回答by Dan Jurgen

use this in the command line

在命令行中使用它

c:\Program Files\Java\jdk1.6.25\bin>keytool -list -v -keystore c:\you_key_here.key

回答by gurkan

Open terminal (in Unix, in MAC), (cmdin Windows) and cdto this (your java) path:

打开终端(在Unix 中,在MAC 中),(cmdWindows 中)和cd这个(你的 java)路径:

C:\Program Files\Java\jdk1.6.0_43\bin>

Run this command:

运行此命令:

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

Just change the path to debug.keystoreand you will get both MD5 and SHA-1 fingerprints.

只需将路径更改为debug.keystore,您将同时获得 MD5 和 SHA-1 指纹。

回答by Manmohan Soni

keytool -list -v -keystore "keyStoreName"

Run this command from the directory where the keystore of your app exists.

从应用程序密钥库所在的目录运行此命令。

回答by Harunduet

In Android Studio, follow these steps:

在 Android Studio 中,请按照下列步骤操作:

  1. Click Gradle properties menu at right side of your android studio IDE.
  2. Expand Task tree.
  3. Click on signingReport You can see your SHA1 at the bottom console
  1. 单击 android studio IDE 右侧的 Gradle 属性菜单。
  2. 展开任务树。
  3. 点击signingReport你可以在底部控制台看到你的SHA1

enter image description here

在此处输入图片说明

回答by Akshay

See if you want to use Google Mapat that time you need MD5fingerprint for generating api kayfor using google map in your android application.

看看你Google Map当时是否想使用你需要MD5指纹来生成api kay在你的android应用程序中使用谷歌地图。

Keytool command generated MD5fingerprint if you use JDK 1.6and it generates SHA1fingerprint if you use JDK 1.7.

Keytool 命令生成MD5指纹,如果你使用JDK 1.6,它会生成SHA1指纹,如果你使用JDK 1.7.

So the thing is that if you want to sign your application for publishing then read this.

所以问题是,如果您想签署您的应用程序以进行发布,请阅读.

And if you want to use google-mapread this.

如果你想使用google-map阅读这个.

回答by Vinod Joshi

If any one using the Android studio...

如果有人使用 Android 工作室...

click: Build > Generate Signed in APK Create a new key: this will generated ".jks" files

单击:Build > Generate Signed in APK 创建一个新密钥:这将生成“.jks”文件

Use following command to read the data(SHA1 and other info):

使用以下命令读取数据(SHA1 和其他信息):

$ keytool -list -v -keystore filename.jks

$ keytool -list -v -keystore 文件名.jks