java 如何从p12证书获取SHA1指纹?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15201409/
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
How to get SHA1 fingerprints from p12 certificate?
提问by Astraport
In order to get the keys of my Android project, Google requires SHA1 fingerprint. Offered this command: keytool-list-v-keystore mystore.keystore
为了获取我的 Android 项目的密钥,Google 需要 SHA1 指纹。提供了这个命令:keytool-list-v-keystore mystore.keystore
I went through different options, but always in an error Illegal option: Files keytool:-list [OPTION] ...
我经历了不同的选项,但总是出现错误 Illegal option: Files keytool:-list [OPTION] ...
For example my command:
例如我的命令:
C:\Program Files (x86)\Java\jre7\bin>keytool -storepass mypass -list -v -keystore C:\Program Files (x86)\Java\jre7\bin\android.p12
If i set p12 file in root (c:) then i get another error - Invalid keystore format.
如果我在 root (c:) 中设置 p12 文件,那么我会收到另一个错误 - 无效的密钥库格式。
采纳答案by Pawe? Wyrwiński
For p12 format (PKCS12) use option -storetype PKCS12
.
对于 p12 格式 (PKCS12),请使用选项-storetype PKCS12
。
For example:
例如:
keytool -list -v -keystore mykeystore.p12 -storetype PKCS12 -storepass 123456
For keystore/certificate inspection & manipulation i recommend GUI tool Portecle(formerly: KeyToolGUI). Hereis convenient windows installer.
对于密钥库/证书检查和操作,我推荐 GUI 工具Portecle(以前:KeyToolGUI)。这是方便的Windows安装程序。
回答by Ludvig A. Norin
This can also be done with OpenSSL:
这也可以通过 OpenSSL 完成:
openssl pkcs12 -in <my pkcs12 file>.p12 -nodes -passin pass:<passphrase, or blank> |openssl x509 -noout -fingerprint
回答by SergioLucas
If you are using Android Studio. You can get fastly the SHA1 certificate fingerprint(debug,release... all Build Types!!) through Gradle Tasks:
如果您使用的是Android Studio。您可以通过 Gradle 任务快速获取SHA1 证书指纹(调试、发布...所有构建类型!!):
signingReport
签约报告
SHA1 is shown in Messages Logs
SHA1 显示在消息日志中
Android Plugin(configured in the gradle app) creates a debugmode for default. File route to keystore: HOME/.android/debug.keystore
Android插件(在应用程序的gradle配置)创建了一个调试模式为默认。到密钥库的文件路径: HOME/.android/debug.keystore
I recommend attach debug.keystore to build.gradle. To do this put a file debug.keystore to a app folder.
我建议将 debug.keystore 附加到 build.gradle。为此,将文件 debug.keystore 放入应用程序文件夹。
Extra: If you want creates for release, put a file release.keystore to a app folder. (This example uses the same debug.keystore)
额外:如果您想为发布创建,请将文件 release.keystore 放入应用程序文件夹。(此示例使用相同的 debug.keystore)