diff options
author | Yazhong Liu <yorkiefixer@gmail.com> | 2014-06-22 23:34:47 +0800 |
---|---|---|
committer | Fedor Indutny <fedor@indutny.com> | 2014-06-24 09:55:26 +0400 |
commit | fcbffa71d030e48a10e29e35d973e40d0418fda0 (patch) | |
tree | 1726c4a578938a6269eca29e0390bcebfaa18d72 /lib/tls.js | |
parent | be8114e5c5afa461a47f617dad86f8de7b27b6cf (diff) | |
download | nodejs-fcbffa71d030e48a10e29e35d973e40d0418fda0.tar.gz nodejs-fcbffa71d030e48a10e29e35d973e40d0418fda0.tar.bz2 nodejs-fcbffa71d030e48a10e29e35d973e40d0418fda0.zip |
tls: using %StringSplit to split `cert.subjectaltname`
Signed-off-by: Fedor Indutny <fedor@indutny.com>
Diffstat (limited to 'lib/tls.js')
-rw-r--r-- | lib/tls.js | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/tls.js b/lib/tls.js index 197e968e0..934563235 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -122,12 +122,15 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) { // Walk through altnames and generate lists of those names if (cert.subjectaltname) { cert.subjectaltname.split(/, /g).forEach(function(altname) { - if (/^DNS:/.test(altname)) { - dnsNames.push(altname.slice(4)); - } else if (/^IP Address:/.test(altname)) { - ips.push(altname.slice(11)); - } else if (/^URI:/.test(altname)) { - var uri = url.parse(altname.slice(4)); + var option = altname.match(/^(DNS|IP Address|URI):(.*)$/); + if (!option) + return; + if (option[1] === 'DNS') { + dnsNames.push(option[2]); + } else if (option[1] === 'IP Address') { + ips.push(option[2]); + } else if (option[1] === 'URI') { + var uri = url.parse(option[2]); if (uri) uriNames.push(uri.hostname); } }); |