SHA-1 Android Firebase 密钥工具

SHA-1 Android Firebase keytool

我正在尝试获取我的 SHA-1 证书,但我一直收到这个:

我认为您通过包含 -exportcert-list 混淆了两个单独的命令。我认为 -exportcert 是您想要的。根据man keytool:

-exportcert

    {-alias alias} {-file cert_file} {-storetype storetype} {-keystore keystore}

    [-storepass storepass] {-providerName provider_name}

    {-providerClass provider_class_name {-providerArg provider_arg}}

    {-rfc} {-v} {-protected} {-Jjavaoption}

    Reads from the keystore the certificate associated with alias and stores it in the
    cert_file file. When no file is specified, the certificate is output to stdout.

    The certificate is by default output in binary encoding. If the -rfc option is
    specified, then the output in the printable encoding format defined by the Internet
    RFC 1421 Certificate Encoding Standard.

    If alias refers to a trusted certificate, then that certificate is output.
    Otherwise, alias refers to a key entry with an associated certificate chain. In
    that case, the first certificate in the chain is returned. This certificate
    authenticates the public key of the entity addressed by alias.

    This command was named -export in earlier releases. The old name is still supported
    in this release. The new name, -exportcert, is preferred going forward.

虽然 -list 的文档紧随其后,但它是一个单独的命令,用于列出有关证书的信息,而不实际进行任何更改、导出任何内容等。

我刚刚为 Branch.io 和 Firebase 做了这个。这正是我的 MD5、SHA1 和 SHA256 的来源:

如果在 Windows 上,导航到您的密钥库所在的文件夹。按住 shift 然后右击。您应该会在选项列表中看到 "Open Command Prompt Here"。

当命令提示符打开时,键入以下内容,您将获得所需的一切:

keytool -list -v -keystore {yourkeystore}

然后它会询问密码。输入您的密码并按回车键。然后您将拥有所有需要的信息。

旁注

如果要保存信息以供将来使用,请右键单击并选择 select 全部。按回车键,然后粘贴到您最喜欢的文本编辑器中。将它与您的密钥库一起保存,以便您始终拥有参考,以防其他 sdk's/api' 需要它。希望对您有所帮助。

如果在 Windows

按住 Windows Home 键并点击 "X"。 Select "System" 然后 select "Advanced System Settings" 在左边。在弹出窗口中,单击环境变量。在“系统变量”部分下查找 "JAVA HOME" 如果不存在,请单击“新建”。输入 JAVA_HOME 作为变量名。输入以下变量值:

C:\Program Files\Java\jdk1.8.0_66

确保与您拥有的 JDK 版本相匹配

然后寻找"Path"变量并添加:

C:\Program Files\Java\jre7\bin

确保它们与您的 Java SDK 和运行时环境的位置相匹配。然后您将能够通过命令提示符从任何地方访问 keytool。