From 0cf235410dfa621668c34b5e70c6b7fb2dab2787 Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Fri, 20 Jul 2012 20:47:05 +0400 Subject: [PATCH] tls: localhost is valid against identity-check --- lib/tls.js | 4 ---- test/simple/test-tls-check-server-identity.js | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/tls.js b/lib/tls.js index be24283f460..4e427fefa88 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -85,10 +85,6 @@ function checkServerIdentity(host, cert) { // Add trailing dot (make hostnames uniform) if (!/\.$/.test(host)) host += '.'; - // Host names with less than one dots are considered too broad, - // and should not be allowed - if (!/^.+\..+$/.test(host)) return /$./; - // The same applies to hostname with more than one wildcard, // if hostname has wildcard when wildcards are not allowed, // or if there are less than two dots after wildcard (i.e. *.com or *d.com) diff --git a/test/simple/test-tls-check-server-identity.js b/test/simple/test-tls-check-server-identity.js index f79823b84cd..99835f8f5e3 100644 --- a/test/simple/test-tls-check-server-identity.js +++ b/test/simple/test-tls-check-server-identity.js @@ -180,6 +180,13 @@ var tests = [ }, result: false }, + { + host: 'localhost', cert: { + subjectaltname: 'DNS:a.com', + subject: { CN: 'localhost' } + }, + result: true + }, ]; tests.forEach(function(test, i) {