openssl_pkey_free is deprecated

This commit is contained in:
the-djmaze 2025-04-04 23:52:27 +02:00
parent d3b120bbe7
commit dea7f4d1d8

View file

@ -139,7 +139,6 @@ abstract class JWT
throw new \ValueError('Invalid key, reason: ' . \openssl_error_string());
}
}
try {
$details = \openssl_pkey_get_details($key);
if (!isset($details['key']) || OPENSSL_KEYTYPE_RSA !== $details['type']) {
throw new \ValueError('Key is not compatible with RSA signatures');
@ -148,11 +147,6 @@ abstract class JWT
if (!\openssl_sign($msg, $signature, $key, 'SHA'.\substr($alg,2))) {
throw new \DomainException('OpenSSL unable to sign data: ' . \openssl_error_string());
}
} finally {
if ($free_key) {
\openssl_pkey_free($key);
}
}
return $signature;
case 'HS256':
@ -193,7 +187,6 @@ abstract class JWT
throw new \ValueError('Invalid key, reason: ' . openssl_error_string());
}
}
try {
$details = \openssl_pkey_get_details($key);
if (!isset($details['key']) || OPENSSL_KEYTYPE_RSA !== $details['type']) {
throw new \ValueError('Key is not compatible with RSA signatures');
@ -202,11 +195,6 @@ abstract class JWT
if (-1 == $success) {
throw new \DomainException('OpenSSL unable to verify data: ' . \openssl_error_string());
}
} finally {
if ($free_key) {
\openssl_pkey_free($key);
}
}
return $success;
case 'HS256':