android - Keystore SHA1 不同于来自 APK 的 cert.rsa SHA1

标签 android ssl air keystore android-keystore

我有一个首先使用 Adob​​e Air 创建的 Android 应用程序(及其生产 keystore )。很久以前,公司转而使用常规的 Android SDK 来开发该应用程序,但由于该应用程序已经投入生产,我们使用的 keystore 仍然是同一个(当时由 Adob​​e Air 创建)。

我使用 keytool 为 Google Places API 提取了 SHA1,我得到了一些类似的信息:

Alias name: <alias_name>
Creation date: Jan 11, 2015
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=<company_name>, OU=, O=, C=US
Issuer: CN=<company_name>, OU=, O=, C=US
Serial number: <lotsofnumbers>
Valid from: Mon Mar 28 14:08:17 IST 2011 until: Sat Mar 29 14:08:17 IDT 2036
Certificate fingerprints:
     MD5:  ..:8D:F7
     SHA1: ..:E6:69
     SHA256: ..:38:9A
     Signature algorithm name: SHA1withRSA
     Version: 3

Extensions: 

#1: ObjectId: 2.5.29.37 Criticality=false
ExtendedKeyUsages [
  codeSigning
]

此 SHA1(由 E6:69 完成)从未在 Google Places API 中工作,所以我检查了 apk 包含的 CERT.RSA 是什么,除了证书指纹外,它看起来几乎相同:

Valid from: Mon Mar 28 14:08:17 IST 2011 until: Sat Mar 29 14:08:17 IDT 2036
Certificate fingerprints:
     MD5:  ..:E1:30
     SHA1: ..:72:74
     SHA256: ..:9D:6D
     Signature algorithm name: SHA1withRSA
     Version: 3

Extensions: 

#1: ObjectId: 2.5.29.37 Criticality=false
ExtendedKeyUsages [
  codeSigning
]

此 SHA1(在 72:74 之前完成)运行完美,我终于设法在生产中使用 Google Places API。但是我不明白为什么这两个证书指纹不同。

我 1000% 确定这是同一个 keystore ,这怎么可能?

当我查看 android 调试 key 时,信息的结构相同,但扩展名不同:

Alias name: androiddebugkey
Creation date: Oct 26, 2014
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: 3bddeb55
Valid from: Sun Oct 26 21:03:56 IST 2014 until: Tue Oct 18 22:03:56 IDT 2044
Certificate fingerprints:
     MD5:  ..:01:17
     SHA1: ..:00:77
     SHA256: ..:32:93
     Signature algorithm name: SHA256withRSA
     Version: 3

Extensions: 

#1: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: <weird hexa number and characters>
0010: <weird hexa number and characters>
]
]

总结一下我的问题:

  1. SHA1 不匹配怎么可能?
  2. 会不会是扩展的不同?
  3. 我怎样才能使用 keytool(或其他工具)来显示正确的 SHA1?
  4. 我能否摆脱此代码签名扩展以返回到“普通 android keystore ”?

最佳答案

How is this possible the SHA1 do not match?

SHA-1 证书指纹由您的 Keystore 定义,可能您使用另一个 Keystore 签署了您的应用程序,或者您的 Keystore 被修改或重新创建,我自己在调试 Keystore 时遇到过这种情况。

How can I use keytool (or other tool) to show me the right SHA1 then?

请记住,当您创建 keystore (包含唯一的 SHA-1 证书)来为生产应用签名时,您必须将此 keystore 保存在安全的地方,并且必须使用它为您的 Google 应用签名Play商店

如果您的 SHA-1(由 E6:69 完成)从未在 Google Places API 中工作,则 SHA-1 证书指纹可能未在 https://console.developers.google.com/ 中注册.

例如,对于 Google Places API,我需要使用调试 keystore 的 SHA-1 证书注册我的应用程序(通常位于 C:\Users\[USER]\.android\debug.keystore) 以及我的生产 keystore 的 SHA-1 证书。

转到您的 Google Developer Console https://console.developers.google.com/apis 您可以在那里定义多个与您的应用程序包名称相关的 SHA-1,例如,您可以为调试 keystore 定义一个,为生产 keystore 定义另一个。 enter image description here

我敢打赌您使用不同的 keystore 进行签名,因为它们具有不同的创建日期:

Creation date: Jan 11, 2015
Creation date: Oct 26, 2014

关于android - Keystore SHA1 不同于来自 APK 的 cert.rsa SHA1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37138752/

相关文章:

android - 即使手机被锁定,如何每 x 分钟发送一次通知

android gradle//无检查GradleCompatible

c# - IIS下如何填充系统证书?

ios - iOS 版 Air "Device Error: Please check if there is enough space on the device."

android - 喷气背包导航 : how to navigate from child of one nested graph to child from another nested graph?

java - 为什么 SpriteBatch 不绘制任何东西 (LibGdx)?

ssl - 如何在 HTTPS 连接上显示非 SSL 图像?

ssl - 将 .crt 文件转换为 .cer 和 .key

flash - AS3麦克风的电平会随着时间的推移而下降-内置噪声补偿?

actionscript-3 - AIR 和 sqLite : if table exists conditional