1
0
mirror of https://github.com/danog/phpseclib.git synced 2024-12-05 21:48:52 +01:00

X509: tweaks to mapOutExtensions

This commit is contained in:
terrafrost 2021-04-20 16:01:45 -05:00
parent c596078d7a
commit 7d3b0a2182

View File

@ -670,7 +670,7 @@ class X509
*/ */
private function mapOutExtensions(&$root, $path) private function mapOutExtensions(&$root, $path)
{ {
$extensions = &$this->subArray($root, $path, true); $extensions = &$this->subArray($root, $path, !empty($this->extensionValues));
foreach ($this->extensionValues as $id => $data) { foreach ($this->extensionValues as $id => $data) {
extract($data); extract($data);
@ -679,16 +679,15 @@ class X509
'extnValue' => $value, 'extnValue' => $value,
'critical' => $critical 'critical' => $critical
]; ];
if (!$replace) { if ($replace) {
$extensions[] = $newext; foreach ($extensions as $key => $value) {
continue; if ($value['extnId'] == $id) {
} $extensions[$key] = $newext;
foreach ($extensions as $key => $value) { continue 2;
if ($value['extnId'] == $id) { }
$extensions[$key] = $newext; }
break;
}
} }
$extensions[] = $newext;
} }
if (is_array($extensions)) { if (is_array($extensions)) {