gpt4 book ai didi

php - 使用 PHP openssl 进行应用内购买签名验证

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:14:38 24 4
gpt4 key购买 nike

尝试遵循应用内的一些安全指南在这里购买: http://developer.android.com/guide/market/billing/billing_best_practices.html我正在尝试在服务器上而不是在服务器上进行签名验证应用程序本身。理想情况下,我想使用 php openssl 库和看起来像下面这样的代码应该可以工作:

$public_key_str = file_get_contents("./pubKey/out");
$public_key_str = trim($public_key_str);
$key = openssl_get_publickey($public_key_str);
if(!$key)
{
echo 'Can\'t get public key';
}
$signature = base64_decode( $signature );
$ok = openssl_verify($data, $signature, $key);
var_dump($ok);

我知道我的签名和公钥都是正确的,但是 $ok 是 0!我尝试使用的签名是应用程序购买包中的字符串。猜猜我的 key 是正确的,问题出在签名上。当我尝试使用 openssl enc -base64 -d -in signature -A > signature.bin 从 base64 解码它时,我得到与 base64_decode() 相同的字符串。有什么想法吗?

UPD:我也不太明白我应该将 openssl_verify() 作为 $data 传递什么?我的数据如下所示:

$data = '{"nonce":5550262978898439313,"orders":[{"notificationId":"android.test.purchased","orderId":"transactionId.android.test.purchased","packageName":"com.ads.testbilling","productId":"android.test.purchased","purchaseTime":1308224646237,"purchaseState":0}]}';

最佳答案

看看 OAuth.php 我想你可以在 googlecode.com 上找到它它使用 openssl_verify() 我认为他们使用的 $data 是一个 URL

http://oauth.googlecode.com/svn/code/php/OAuth.php

关于php - 使用 PHP openssl 进行应用内购买签名验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6371614/

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