I'm trying to validate the authenticity of the android billing receipt that I receive when a purchase is made.. The verification is server sided but I'm thinking if sometimes the server might be down, I might check the signatures from the App itself..
here's how I am verifying the purchase on server..
<?php
// get data param
$data = $_GET['response'];
// get signature param
$signature = $_GET['signature'];
// get key
$key_64 = "MY Base64 KEY FROM DEVELOPER CONSOLE";
$key = "-----BEGIN PUBLIC KEY-----\n".
chunk_split($key_64, 64,"\n").
'-----END PUBLIC KEY-----';
//using PHP to create an RSA key
$key = openssl_get_publickey($key);
// state whether signature is okay or not
$ok = openssl_verify($data, base64_decode($signature), $key, OPENSSL_ALGO_SHA1);
if ($ok == 1) {
echo "verified";
} elseif ($ok == 0) {
echo "unverified";
} else {
die ("fault, error checking signature");
}
// free the key from memory
openssl_free_key($key);
?>
So how to do the same on Android?