From a577a09a4f891a16c8734626f5042b4b9fae2877 Mon Sep 17 00:00:00 2001 From: terrafrost Date: Wed, 9 Oct 2013 14:51:34 -0500 Subject: [PATCH] X509: make it so ip addresses and domain names can be used together --- phpseclib/File/X509.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/phpseclib/File/X509.php b/phpseclib/File/X509.php index 8cce482f..0b4e2913 100644 --- a/phpseclib/File/X509.php +++ b/phpseclib/File/X509.php @@ -3228,9 +3228,10 @@ class File_X509 { $this->setExtension('id-ce-subjectKeyIdentifier', $subject->currentKeyIdentifier); } + $altName = array(); + if (isset($subject->domains) && count($subject->domains) > 1) { - $this->setExtension('id-ce-subjectAltName', - array_map(array('File_X509', '_dnsName'), $subject->domains)); + $altName = array_map(array('File_X509', '_dnsName'), $subject->domains); } if (isset($subject->ipAddresses) && count($subject->ipAddresses)) { @@ -3244,10 +3245,14 @@ class File_X509 { } } if (count($ipAddresses)) { - $this->setExtension('id-ce-subjectAltName', $ipAddresses); + $altName = array_merge($altName, $ipAddresses); } } + if (!empty($altName)) { + $this->setExtension('id-ce-subjectAltName', $altName); + } + if ($this->caFlag) { $keyUsage = $this->getExtension('id-ce-keyUsage'); if (!$keyUsage) {