I'm curious to know how I can decode and verify jws from apple inapp purchase notifications, I've found this lib: https://github.com/firebase/php-jwt which supports ES256 but I don't know clearly how to use the shared secret generated by Apple (if it is possible, I'm not sure about that). I've attempted this:
require_once dirname(__FILE__) . '/vendor/autoload.php';
use Firebase\JWT\JWT;
use Firebase\JWT\Key;
$key = '*****'//apple shared secret
$body = file_get_contents('php://input');
$decodedBody = json_decode($body,true);
$data = $decodedBody["signedPayload"];//string to be decoded
$decoded = JWT::decode($data, new Key($key, 'ES256'));
I've got these errors
Warning: openssl_verify(): supplied key param cannot be coerced into a public key in /Applications/XAMPP/xamppfiles/htdocs/jwttest/vendor/firebase/php-jwt/src/JWT.php on line 293
Fatal error: Uncaught DomainException: OpenSSL error: error:0909006C:PEM routines:get_name:no start line in /Applications/XAMPP/xamppfiles/htdocs/jwttest/vendor/firebase/php-jwt/src/JWT.php on line 301
DomainException: OpenSSL error: error:0909006C:PEM routines:get_name:no start line in /Applications/XAMPP/xamppfiles/htdocs/jwttest/vendor/firebase/php-jwt/src/JWT.php on line 301
Thanks in advance for your help