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
This commit is contained in:
Léon Melis 2023-05-24 17:48:43 +02:00 committed by terrafrost
parent 2097656b4a
commit 841267aafa

View File

@ -164,7 +164,7 @@ class X509
* *
* @var array * @var array
*/ */
private $CAs; private $CAs = [];
/** /**
* The currently loaded certificate * The currently loaded certificate
@ -2030,9 +2030,6 @@ class X509
if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) {
return false; return false;
} }
if (empty($this->CAs)) {
return $chain;
}
while (true) { while (true) {
$currentCert = $chain[count($chain) - 1]; $currentCert = $chain[count($chain) - 1];
for ($i = 0; $i < count($this->CAs); $i++) { for ($i = 0; $i < count($this->CAs); $i++) {