mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-09-11 23:54:15 +08:00
openssl_pkey_free is deprecated
This commit is contained in:
parent
d3b120bbe7
commit
dea7f4d1d8
1 changed files with 14 additions and 26 deletions
|
@ -139,19 +139,13 @@ abstract class JWT
|
||||||
throw new \ValueError('Invalid key, reason: ' . \openssl_error_string());
|
throw new \ValueError('Invalid key, reason: ' . \openssl_error_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
$details = \openssl_pkey_get_details($key);
|
||||||
$details = \openssl_pkey_get_details($key);
|
if (!isset($details['key']) || OPENSSL_KEYTYPE_RSA !== $details['type']) {
|
||||||
if (!isset($details['key']) || OPENSSL_KEYTYPE_RSA !== $details['type']) {
|
throw new \ValueError('Key is not compatible with RSA signatures');
|
||||||
throw new \ValueError('Key is not compatible with RSA signatures');
|
}
|
||||||
}
|
$signature = '';
|
||||||
$signature = '';
|
if (!\openssl_sign($msg, $signature, $key, 'SHA'.\substr($alg,2))) {
|
||||||
if (!\openssl_sign($msg, $signature, $key, 'SHA'.\substr($alg,2))) {
|
throw new \DomainException('OpenSSL unable to sign data: ' . \openssl_error_string());
|
||||||
throw new \DomainException('OpenSSL unable to sign data: ' . \openssl_error_string());
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if ($free_key) {
|
|
||||||
\openssl_pkey_free($key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $signature;
|
return $signature;
|
||||||
|
|
||||||
|
@ -193,19 +187,13 @@ abstract class JWT
|
||||||
throw new \ValueError('Invalid key, reason: ' . openssl_error_string());
|
throw new \ValueError('Invalid key, reason: ' . openssl_error_string());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
$details = \openssl_pkey_get_details($key);
|
||||||
$details = \openssl_pkey_get_details($key);
|
if (!isset($details['key']) || OPENSSL_KEYTYPE_RSA !== $details['type']) {
|
||||||
if (!isset($details['key']) || OPENSSL_KEYTYPE_RSA !== $details['type']) {
|
throw new \ValueError('Key is not compatible with RSA signatures');
|
||||||
throw new \ValueError('Key is not compatible with RSA signatures');
|
}
|
||||||
}
|
$success = \openssl_verify($msg, $signature, $key, 'SHA'.\substr($alg,2));
|
||||||
$success = \openssl_verify($msg, $signature, $key, 'SHA'.\substr($alg,2));
|
if (-1 == $success) {
|
||||||
if (-1 == $success) {
|
throw new \DomainException('OpenSSL unable to verify data: ' . \openssl_error_string());
|
||||||
throw new \DomainException('OpenSSL unable to verify data: ' . \openssl_error_string());
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if ($free_key) {
|
|
||||||
\openssl_pkey_free($key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $success;
|
return $success;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue