From 3be62a9fdaa1cafbe8a990686317609a875bfa6f Mon Sep 17 00:00:00 2001 From: johnstevenson Date: Fri, 14 Aug 2020 17:45:41 +0100 Subject: [PATCH] Fix openssl_free_key deprecation notice in PHP 8 --- src/Composer/Command/SelfUpdateCommand.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Composer/Command/SelfUpdateCommand.php b/src/Composer/Command/SelfUpdateCommand.php index d4d13364e..348451e76 100644 --- a/src/Composer/Command/SelfUpdateCommand.php +++ b/src/Composer/Command/SelfUpdateCommand.php @@ -271,7 +271,12 @@ TAGSPUBKEY $signature = json_decode($signature, true); $signature = base64_decode($signature['sha384']); $verified = 1 === openssl_verify(file_get_contents($tempFilename), $signature, $pubkeyid, $algo); - openssl_free_key($pubkeyid); + + // PHP 8 automatically frees the key instance and deprecates the function + if (PHP_VERSION_ID < 80000) { + openssl_free_key($pubkeyid); + } + if (!$verified) { throw new \RuntimeException('The phar signature did not match the file you downloaded, this means your public keys are outdated or that the phar file is corrupt/has been modified'); }