title: Android in-app billing signature verification in php server
body: <p>I am working on the IAB v3 in my android application.
  After every succes purchase, I want my app to send back the sign data and signature to my php server for verification by the public key generated by google developer console.
  I found the following code.</p>
  
  <pre><code>&lt;?php
  // $data and $signature are assumed to contain the data and the signature
  
  // fetch public key from certificate and ready it
  $fp = fopen("/src/openssl-0.9.6/demos/sign/cert.pem", "r");
  $cert = fread($fp, 8192);
  fclose($fp);
  $pubkeyid = openssl_get_publickey($cert);
  
  // state whether signature is okay or not
  $ok = openssl_verify($data, $signature, $pubkeyid);
  if ($ok == 1) {
      echo "good";
  } elseif ($ok == 0) {
      echo "bad";
  } else {
      echo "ugly, error checking signature";
  }
  // free the key from memory
  openssl_free_key($pubkeyid);
  ?&gt;
  </code></pre>
  
  <p>Now I have a problem. The public key given by google is in String Base64 Encoded. I do not know how to convert that string key to a ".pem" format.</p>
  
  <p>If I put my Base64 Encoded key to "$pubkeyid" on the above code. A warning will be given.</p>
  
  <p><code>Warning: openssl_verify() [function.openssl-verify]: supplied key param cannot be coerced into a public key in myxxx.php.</code></p>
  
  <p>How can I convert my String Base64 Encoded public key to the php accept format ?</p>
  
  <p>Do anyone have the above experience or solution? Please help. Many thanks.</p>