'PHP openssl_verify function is always returning 0

I am verifying request from the public key that i got from my provider. I am using openssl_verify function for verification. below is the sample code that i am using...

$data  = 'JSON_ENCODED_STRING';
$signature = base64_decode("SIGNATURE");
$fp  = fopen(FILE_PATH, 'r');
$pkeyid = fread($fp, 1000000);
fclose($fp);
$pkeyid = openssl_pkey_get_public($pkeyid);
$ok = openssl_verify($data, $signature, $pkeyid, OPENSSL_ALGO_SHA256);

This is always returning 0. Whether file path is correct. Please help..



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source