diff --git a/lib/internal/Magento/Framework/Jwt/JwkFactory.php b/lib/internal/Magento/Framework/Jwt/JwkFactory.php index ab28789d797de..918fc2cb79bc6 100644 --- a/lib/internal/Magento/Framework/Jwt/JwkFactory.php +++ b/lib/internal/Magento/Framework/Jwt/JwkFactory.php @@ -785,7 +785,7 @@ private function createPrivateRsa(string $key, ?string $pass, string $use, strin { $resource = openssl_get_privatekey($key, (string)$pass); $keyData = openssl_pkey_get_details($resource)['rsa']; - $this->freeResource($resource); + $keysMap = [ 'n' => 'n', 'e' => 'e', @@ -821,7 +821,7 @@ private function createPublicRsa(string $key, string $use, string $algorithm, ?s { $resource = openssl_get_publickey($key); $keyData = openssl_pkey_get_details($resource)['rsa']; - $this->freeResource($resource); + $keysMap = [ 'n' => 'n', 'e' => 'e' @@ -857,7 +857,7 @@ private function createPrivateEc( ): Jwk { $resource = openssl_get_privatekey($key, (string)$pass); $keyData = openssl_pkey_get_details($resource)['ec']; - $this->freeResource($resource); + if (!array_key_exists($keyData['curve_oid'], self::EC_CURVE_MAP)) { throw new \RuntimeException('Unsupported EC curve'); } @@ -895,7 +895,7 @@ private function createPublicEc( ): Jwk { $resource = openssl_get_publickey($key); $keyData = openssl_pkey_get_details($resource)['ec']; - $this->freeResource($resource); + if (!array_key_exists($keyData['curve_oid'], self::EC_CURVE_MAP)) { throw new \RuntimeException('Unsupported EC curve'); } @@ -950,15 +950,4 @@ private static function base64Decode(string $encoded): string return $value; } - /** - * @param mixed $resource - * - * @return void - */ - private function freeResource($resource): void - { - if (\is_resource($resource) && (version_compare(PHP_VERSION, '8.0') < 0)) { - openssl_free_key($resource); - } - } }