I am having trouble verifying an RS256 signature in PHP from a JWT.
I have
$to_verify = substr(Cookie::get('CF_Authorization'), 0, strrpos(Cookie::get('CF_Authorization'), "."));
$signature = base64_decode(explode('.', Cookie::get('CF_Authorization'))[2]);
return openssl_verify($to_verify, $signature, $cert, 'RSA-SHA256'));
Part of my problem is I don't know what is the most correct algorithm to use the header says "alg": "RS256". So is that:
- OPENSSL_ALGO_SHA256
- "SHA256"
- "sha256"
- "RSA-SHA256"
- "sha256WithRSAEncryption"
- Something else?
I've tried all of those from the php docs that sounds like they could be right, but not matter what I try it always returns 0 (not verified) but according to jwt.io the jwt, signature, and public key I am testing with is valid.
I'm not sure what I am doing wrong.