Browse Source

tls: using %StringSplit to split `cert.subjectaltname`

Signed-off-by: Fedor Indutny <fedor@indutny.com>
archived-io.js-v0.10
Yazhong Liu 11 years ago
committed by Fedor Indutny
parent
commit
fcbffa71d0
  1. 15
      lib/tls.js

15
lib/tls.js

@ -122,12 +122,15 @@ exports.checkServerIdentity = function checkServerIdentity(host, cert) {
// Walk through altnames and generate lists of those names // Walk through altnames and generate lists of those names
if (cert.subjectaltname) { if (cert.subjectaltname) {
cert.subjectaltname.split(/, /g).forEach(function(altname) { cert.subjectaltname.split(/, /g).forEach(function(altname) {
if (/^DNS:/.test(altname)) { var option = altname.match(/^(DNS|IP Address|URI):(.*)$/);
dnsNames.push(altname.slice(4)); if (!option)
} else if (/^IP Address:/.test(altname)) { return;
ips.push(altname.slice(11)); if (option[1] === 'DNS') {
} else if (/^URI:/.test(altname)) { dnsNames.push(option[2]);
var uri = url.parse(altname.slice(4)); } 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); if (uri) uriNames.push(uri.hostname);
} }
}); });

Loading…
Cancel
Save