mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-24 11:05:30 +00:00
X509: add replace parameter to setExtensionValue
This commit is contained in:
parent
0d9d1eedb1
commit
701881d3de
@ -670,16 +670,27 @@ class X509
|
||||
*/
|
||||
private function mapOutExtensions(&$root, $path)
|
||||
{
|
||||
foreach ($this->extensionValues as $id => $value) {
|
||||
$root['tbsCertificate']['extensions'][] = [
|
||||
'extnId' => $id,
|
||||
'extnValue' => $value[1],
|
||||
'critical' => $value[0],
|
||||
];
|
||||
}
|
||||
|
||||
$extensions = &$this->subArray($root, $path);
|
||||
|
||||
foreach ($this->extensionValues as $id => $data) {
|
||||
extract($data);
|
||||
$newext = [
|
||||
'extnId' => $id,
|
||||
'extnValue' => $value,
|
||||
'critical' => $critical
|
||||
];
|
||||
if (!$replace) {
|
||||
$extensions[] = $newext;
|
||||
continue;
|
||||
}
|
||||
foreach ($extensions as $key => $value) {
|
||||
if ($value['extnId'] == $id) {
|
||||
$extensions[$key] = $newext;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($extensions)) {
|
||||
$size = count($extensions);
|
||||
for ($i = 0; $i < $size; $i++) {
|
||||
@ -4081,9 +4092,10 @@ class X509
|
||||
* @param string $id
|
||||
* @param mixed $value
|
||||
* @param bool $critical
|
||||
* @param bool $replace
|
||||
*/
|
||||
public function setExtensionValue($id, $value, $critical = false)
|
||||
public function setExtensionValue($id, $value, $critical = false, $replace = false)
|
||||
{
|
||||
$this->extensionValues[$id] = [$critical, $value];
|
||||
$this->extensionValues[$id] = compact('critical', 'replace', 'value');
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user