From 841267aafa5092a1c9ca3de8a5f347f61777e300 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on=20Melis?= Date: Wed, 24 May 2023 17:48:43 +0200 Subject: [PATCH] X509::getChain() should always return array of X509 objects Due to an early exit optimization, X509::getChain() could return currentCert as an array, instead of X509 --- phpseclib/File/X509.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 7aa278f2..a99252eb 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -164,7 +164,7 @@ class X509 * * @var array */ - private $CAs; + private $CAs = []; /** * The currently loaded certificate @@ -2030,9 +2030,6 @@ class X509 if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { return false; } - if (empty($this->CAs)) { - return $chain; - } while (true) { $currentCert = $chain[count($chain) - 1]; for ($i = 0; $i < count($this->CAs); $i++) {