From f4b03722fd286e3e25d2e5d942bb0669e9d6a35a Mon Sep 17 00:00:00 2001 From: Patrick Monnerat Date: Mon, 1 Oct 2012 12:35:43 +0200 Subject: [PATCH] X509: handle multiple-valued attributes in setDNProp(). Fix setDN(). --- phpseclib/File/X509.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 41e70ad4..d29c8ba9 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -1825,7 +1825,7 @@ class File_X509 { * Set a Distinguished Name property * * @param String $propName - * @param String $propValue + * @param Mixed $propValue * @access public * @return Boolean */ @@ -1839,12 +1839,13 @@ class File_X509 { return false; } - $this->dn['rdnSequence'][] = array( - array( - 'type' => $propName, - 'value'=> $propValue - ) - ); + foreach ((array) $propValue as $v) + $this->dn['rdnSequence'][] = array( + array( + 'type' => $propName, + 'value'=> $v + ) + ); return true; } @@ -1912,14 +1913,18 @@ class File_X509 { * Set a Distinguished Name * * @param Mixed $dn + * @param Boolean $merge optional * @access public * @return Boolean */ - function setDN($dn) + function setDN($dn, $merge = false) { + if (!$merge) + $this->dn = NULL; + if (is_array($dn)) { if (isset($dn['rdnSequence'])) { - $this->dn = $dn; + $this->dn = $dn; // No merge here. return true; }