This commit is contained in:
Jun Pataleta
2022-01-20 21:52:50 +08:00
9 changed files with 50 additions and 16 deletions
+10 -4
View File
@@ -148,8 +148,11 @@ class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
// Release the key resource
openssl_free_key($privatekeyid);
}
return base64_encode($signature);
}
@@ -168,8 +171,11 @@ class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
// Release the key resource
openssl_free_key($publickeyid);
}
return $ok == 1;
}
+2 -1
View File
@@ -3,4 +3,5 @@ current code was taken from https://github.com/jfederico/ims-dev/tree/master/bas
several changes to the code (including bug fixes). As the library is no longer supported upgrades are not possible.
In future releases we should look into using a supported library.
2021-01-05 - Removed get_magic_quotes_gpc() use, was returning false since ages ago.
2022-01-05 - MDL-73502 - Removed get_magic_quotes_gpc() use, was returning false since ages ago.
2022-01-20 - MDL-73523 - Conditional openssl_free_key() use, deprecated by PHP 8.0
+3 -1
View File
@@ -40,7 +40,9 @@ Local changes (to reapply until upstream upgrades contain them):
* MDL-67034 php74 compliance fixes
* MDL-67115 php74 implode() compliance fixes. This is fixed in upstream library v2.2.4
(verify that https://github.com/googleapis/google-api-php-client/pull/1683 is applied)
* MDL-73523 php80 compliance. openssl_xxx_free() methods deprecated. I've been unable to
find any issue upstream and the current library versions are way different from the ones
we are using here.
Information
-----------
+4 -1
View File
@@ -74,7 +74,10 @@ class Google_Signer_P12 extends Google_Signer_Abstract
public function __destruct()
{
if ($this->privateKey) {
openssl_pkey_free($this->privateKey);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($this->privateKey);
}
}
}
+4 -1
View File
@@ -50,7 +50,10 @@ class Google_Verifier_Pem extends Google_Verifier_Abstract
public function __destruct()
{
if ($this->publicKey) {
openssl_x509_free($this->publicKey);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_x509_free($this->publicKey);
}
}
}
+8 -2
View File
@@ -422,7 +422,10 @@ function mnet_generate_keypair($dn = null, $days=28) {
// We export our self-signed certificate to a string.
openssl_x509_export($selfSignedCert, $keypair['certificate']);
openssl_x509_free($selfSignedCert);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_x509_free($selfSignedCert);
}
// Export your public/private key pair as a PEM encoded string. You
// can protect it with an optional passphrase if you wish.
@@ -431,7 +434,10 @@ function mnet_generate_keypair($dn = null, $days=28) {
} else {
$export = openssl_pkey_export($new_key, $keypair['keypair_PEM'] /* , $passphrase */);
}
openssl_pkey_free($new_key);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_pkey_free($new_key);
}
unset($new_key); // Free up the resource
return $keypair;
+11 -5
View File
@@ -262,8 +262,11 @@ class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
// Sign using the key
$ok = openssl_sign($base_string, $signature, $privatekeyid);
// Release the key resource
openssl_free_key($privatekeyid);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
// Release the key resource
openssl_free_key($privatekeyid);
}
return base64_encode($signature);
}
@@ -282,8 +285,11 @@ class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {
// Check the computed signature against the one passed in the query
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
// Release the key resource
openssl_free_key($publickeyid);
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
// Release the key resource
openssl_free_key($publickeyid);
}
return $ok == 1;
}
@@ -897,4 +903,4 @@ class OAuthUtil {
// Each name-value pair is separated by an '&' character (ASCII code 38)
return implode('&', $pairs);
}
}
}
+1
View File
@@ -12,3 +12,4 @@ Local changes applied:
upstream. Remove the local changes if so)
MDL-67031 php74 compliance. Change curly to square braces.
MDL-73523 php80 compliance. Deprecated openssl_free_key() use (https://github.com/tpyo/amazon-s3-php-class/issues/178)
+7 -1
View File
@@ -351,7 +351,13 @@ class S3
public static function freeSigningKey()
{
if (self::$__signingKeyResource !== false)
openssl_free_key(self::$__signingKeyResource);
{
// TODO: Remove this block once PHP 8.0 becomes required.
if (PHP_MAJOR_VERSION < 8) {
openssl_free_key(self::$__signingKeyResource);
}
self::$__signingKeyResource = null;
}
}