Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php8 fixes for 3.4 branch #592

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/Signer/OpenSSL.php
Original file line number Diff line number Diff line change
@@ -26,7 +26,10 @@ public function createHash($payload, Key $key)

return $signature;
} finally {
openssl_free_key($privateKey);
if (!version_compare(phpversion(), '8.0', '>=')) {
// Deprecated and no longer necessary as of PHP >= 8.0
openssl_free_key($privateKey);
}
}
}

@@ -54,7 +57,11 @@ public function doVerify($expected, $payload, Key $key)
{
$publicKey = $this->getPublicKey($key->getContent());
$result = openssl_verify($payload, $expected, $publicKey, $this->getAlgorithm());
openssl_free_key($publicKey);

if (!version_compare(phpversion(), '8.0', '>=')) {
// Deprecated and no longer necessary as of PHP >= 8.0
openssl_free_key($publicKey);
}

return $result === 1;
}
@@ -75,13 +82,13 @@ private function getPublicKey($pem)
/**
* Raises an exception when the key type is not the expected type
*
* @param resource|bool $key
* @param resource|OpenSSLAsymmetricKey|bool $key
*
* @throws InvalidArgumentException
*/
private function validateKey($key)
{
if (! is_resource($key)) {
if (is_bool($key)) {
throw InvalidKeyProvided::cannotBeParsed(openssl_error_string());
}