gpt4 book ai didi

android - 证书固定 - 从证书 .crt 文件生成 SHA256 固定 key

转载 作者:太空宇宙 更新时间:2023-11-03 12:52:16 36 4
gpt4 key购买 nike

我有一个正在运行的 Android 应用程序,它使用 SHA256 Pin 实现证书固定。我用 https://www.ssllabs.com/ssltest获取该引脚的工具。

当前服务器证书即将到期,将向服务器申请新证书。我需要在将新证书应用到服务器之前为它生成 SHA256 Pin,以便我可以将它添加到应用程序并在更新中引入它。

我有新的证书 .crt 文件。知道如何从文件生成 SHA256 key 吗?我无法访问服务器,只能访问 .crt 文件。

根据 OkHttp 的 CertificatePinner 文档:

SHA-256 or SHA-1 hashes. Each pin is a hash of a certificate's SubjectPublic Key Info, base64-encoded and prefixed with either sha256/ orsha1/.

最佳答案

试试这个命令

openssl x509 -in my-certificate.crt -pubkey -noout | openssl pkey -pubin -outform der | openssl dgst -sha256 -binary | openssl enc -base64

然后使用

"sha256/"  + ${ouput hash from the command line above}.

您可以在 Public Key Pinning page 中找到更多命令在 Mozilla 开发者网络

关于android - 证书固定 - 从证书 .crt 文件生成 SHA256 固定 key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51174130/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com