简体   繁体   English

如何从公共私钥对中检索facebook的签名哈希?

[英]How to retrieve a signature hash for facebook from a public private key pair?

I'm using a version of signapk for one of my projects. 我正在为我的一个项目使用signapk版本。 I sign my apk with a public, private key pair (.pk8 & .pem). 我用公共私钥对(.pk8和.pem)签署我的apk。

My application uses the facebook single sign on mechanism and I need a hash of the signing certificate registered with facebook to ensure that the correct app is starting the single sign on process. 我的应用程序使用facebook单点登录机制,我需要在Facebook注册的签名证书的哈希值,以确保正确的应用程序启动单点登录过程。 Facebook gives the following example code for generating this hash: Facebook提供了以下用于生成此哈希的示例代码:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore 
| openssl sha1 -binary
| openssl base64

I'm a little bit confused on how to generate the appropriate hash from my public key, private key pair that I use for signing. 我对如何从我用于签名的公钥,私钥对生成适当的哈希感到困惑。

This method works for you APK signed with your PK8 + PEM key pair. 此方法适用于您使用PK8 + PEM密钥对签名的APK。 Or with any other (correctly) signed APK 或者与任何其他(正确)签名的APK

  1. Certificate could be known from *.apk file 证书可以从* .apk文件中获知

    1. Unzip apk file and extract META-INF\\CERT.RSA file 解压缩apk文件并解压缩META-INF \\ CERT.RSA文件
    2. execute: 执行:

        keytool -printcert -file CERT.RSA 

      Check sha1 bytes 检查sha1字节

  2. the bytes at sha1 fingerprint signature are needed to write to sha1.bin (you can use an hexadecimal editor) 写入sha1.bin需要sha1指纹签名的字节(可以使用十六进制编辑器)

  3. just execute: 只执行:

     openssl base64 -in sha1.bin -out base64.txt 

so, base64.txt contains the APK's FB KeyHash 所以,base64.txt包含APK的FB KeyHash

Facebook hash is actually the base64 encoding of SHA1. Facebook哈希实际上是SHA1的base64编码。

So you have to generate sha1 from your certificate file that ends with .pem extension!.. 因此,您必须从证书文件生成以.pem扩展名结尾的sha1!

Command to get SHA1 from a .pem file:- openssl x509 -fingerprint -in certificate.pem -noout 从.pem文件获取SHA1的命令: - openssl x509 -fingerprint -in certificate.pem -noout

this command will return SHA1 of your .pem file, replace certicicate.pem with the name of your .pem file!... 此命令将返回.pem文件的SHA1,将certicicate.pem替换为.pem文件的名称!...

After succesfully getting the SHA1 Now your task is to encode the SHA1 into base64 and there are alot of ways to do that, i recommend this website: 成功获得SHA1之后现在您的任务是将SHA1编码为base64,并且有很多方法可以做到这一点,我推荐这个网站:

http://tomeko.net/online_tools/hex_to_base64.php?lang=en http://tomeko.net/online_tools/hex_to_base64.php?lang=en

go to this site write your SHA1 and in the last textbox you will received the encoded base64 that is the HASH for your facebook developer app!.. 去这个网站写你的SHA1,在最后一个文本框中,你将收到编码的base64,这是你的Facebook开发者应用程序的HASH!

下载打开的SS1和您的PC上安装。检查这个我问这个问题已经有一些答案的问题 ..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM