Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
tls: localhost is valid against identity-check
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Jul 20, 2012
1 parent 8ba189b commit 0cf2354
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 0 additions & 4 deletions lib/tls.js
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions test/simple/test-tls-check-server-identity.js
Expand Up @@ -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) {
Expand Down

0 comments on commit 0cf2354

Please sign in to comment.