首页 文章

密钥库SHA1与APK的cert.rsa SHA1不同

提问于
浏览
5

我有一个首先用Adobe Air创建的Android应用程序(及其 生产环境 密钥库) . 很久以前,该公司转而使用常规Android SDK开发应用程序,但由于该应用程序已投入 生产环境 ,我们使用的密钥库仍然是相同的(由Adobe 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%肯定它是同一个密钥库,所以这怎么可能?

当我查看android调试密钥时,信息的结构方式相同,但扩展名是不同的:

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>
]
]

总结一下我的问题:

  • SHA1怎么可能不匹配?

  • 可能是扩展区别吗?

  • 如何使用keytool(或其他工具)向我显示正确的SHA1呢?

  • 我可以摆脱这个代码签名扩展回到"normal android keystore"吗?

4 回答

  • 4

    SHA1如何可能不匹配?

    The SHA-1 certificate fingerprint is defined by your Keystore, probably you signed your app with another Keystore or your Keystore was modified or was created again, i have experienced this by myself, with my debug Keystore.

    我如何使用keytool(或其他工具)向我展示正确的SHA1呢?

    Remember when you create a Keystore (that contains an unique SHA-1 Certificate) to sign apps for production, you must keep this Keystore in a safe place, and it must be used to sign you apps for the Google Playstore

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

    例如,对于Google Places API,我需要使用我的调试密钥库的SHA-1证书(通常位于 C:\Users\[USER]\.android\debug.keystore )和我的 生产环境 密钥库的SHA-1证书注册我的应用 .

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

    我敢打赌你签了不同的密钥商店因为他们有不同的创作日期:

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

    使用android studio,您可以通过以下方式获取SHA1密钥

    然后在工作室右侧的Goto Gradle选项卡

    Click projectname-> :app-> Tasks-> android-> signingReport(double click)

    这将在RUN控制台上打印SHA1和MD5键

  • 0

    将有2个密钥库 . 调试和发布 . 您正在使用调试密钥 .

    如果你正在使用发布 . 检查调试和释放xmls中的apikey是否正确 . 因为通常你不会看到谷歌xml的发布 .

    因此,您创建了正确的Api密钥,但未将其放入发行版xml文件中 .

  • 2

    检查几件事

    • 您有正确的签名密钥(查看日期)

    • 确保您的密码正确(必须正确发布版本apk)

    • 检查您的密钥别名是否正确 . 我花了几个小时才发现我有两个 .

相关问题