Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP server side IAB verification openssl_verify always returns 0
    primarykey
    data
    text
    <p>I'm using the following function (server side php) to verify a IAB v3 transaction:</p> <p>I'm passing from the android app:</p> <pre><code>@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { String signed_data=data.getStringExtra(IabHelper.RESPONSE_INAPP_PURCHASE_DATA); String signature=data.getStringExtra(IabHelper.RESPONSE_INAPP_SIGNATURE); </code></pre> <p>I have a feeling it may have something to do with the signature I'm passing. I'm using the following Android method to encode it, because without encoding I get an error:</p> <pre><code>public String URLsafe(String text){ try { return URLEncoder.encode(text, "utf-8"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace();; } return null; } </code></pre> <p>I'm passing the url </p> <pre><code>http://www.example.com/handlepayment.php?signature=....&amp;data=.... public String getXmlFromUrl(String url) { String xml = null; try { // defaultHttpClient DefaultHttpClient httpClient = new MyHttpClient_ALKS(myContext.getApplicationContext()); HttpPost httpPost = new HttpPost(url); HttpResponse httpResponse = httpClient.execute(httpPost); HttpEntity httpEntity = httpResponse.getEntity(); xml = EntityUtils.toString(httpEntity); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (ClientProtocolException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return xml; } </code></pre> <p>to the server:</p> <pre><code>function verify_play($signed_data, $signature) { global $public_key_base64; $pkey = "-----BEGIN PUBLIC KEY-----\n". chunk_split($public_key_base64, 64,"\n"). '-----END PUBLIC KEY-----'; //using PHP to create an RSA key $pkey = openssl_get_publickey($pkey); //$signature should be in binary format, but it comes as BASE64. //So, I'll convert it. $signature = base64_decode($signature); //using PHP's native support to verify the signature $result = openssl_verify( $signed_data, $signature, $pkey, OPENSSL_ALGO_SHA1); if (0 === $result) { return false; } else if (1 !== $result) { return false; } else { return true; } } ; </code></pre> <p>It always seem to return false ($result=0), anybody any idea why? How can I pass the signature un-encoded, or which encoding should I use?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload