★ wanayoo — archive 1999 https://github.com/joyent/node/pull/6636Nouvelle recherche | Portail wanayoo
Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

tls: fix handling of asterisk in SNI context #6636

Closed
wants to merge 1 commit into from

2 participants

Fedor Indutny Timothy J Fontaine
Fedor Indutny
Collaborator

Wildcard server names should not match subdomains.

Quote from RFC2818:

...Names may contain the wildcard
character * which is considered to match any single domain name
component or component fragment. E.g., .a.com matches foo.a.com but
not bar.foo.a.com. f
.com matches foo.com but not bar.com.

fix #6610

Fedor Indutny indutny tls: fix handling of asterisk in SNI context …
Wildcard server names should not match subdomains.

Quote from RFC2818:

   ...Names may contain the wildcard
   character * which is considered to match any single domain name
   component or component fragment. E.g., *.a.com matches foo.a.com but
   not bar.foo.a.com. f*.com matches foo.com but not bar.com.

fix #6610
06e037f
Fedor Indutny
Collaborator
Timothy J Fontaine

landed in f572b91

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 05, 2013
  1. Fedor Indutny

    tls: fix handling of asterisk in SNI context …

    indutny authored
    Wildcard server names should not match subdomains.
    
    Quote from RFC2818:
    
       ...Names may contain the wildcard
       character * which is considered to match any single domain name
       component or component fragment. E.g., *.a.com matches foo.a.com but
       not bar.foo.a.com. f*.com matches foo.com but not bar.com.
    
    fix #6610
This page is out of date. Refresh to see the latest.
Showing with 22 additions and 14 deletions.
  1. +1 −1  lib/_tls_wrap.js
  2. +21 −13 test/simple/test-tls-sni-server-client.js
2  lib/_tls_wrap.js
View
@@ -612,7 +612,7 @@ Server.prototype.addContext = function(servername, credentials) {
var re = new RegExp('^' +
servername.replace(/([\.^$+?\-\\[\]{}])/g, '\\$1')
- .replace(/\*/g, '.*') +
+ .replace(/\*/g, '[^\.]*') +
'$');
this._contexts.push([re, crypto.createCredentials(credentials).context]);
};
34 test/simple/test-tls-sni-server-client.js
View
@@ -66,14 +66,21 @@ var clientsOptions = [{
ca: [loadPEM('ca1-cert')],
servername: 'a.example.com',
rejectUnauthorized: false
-},{
+}, {
port: serverPort,
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert'),
ca: [loadPEM('ca2-cert')],
servername: 'b.test.com',
rejectUnauthorized: false
-},{
+}, {
+ port: serverPort,
+ key: loadPEM('agent2-key'),
+ cert: loadPEM('agent2-cert'),
+ ca: [loadPEM('ca2-cert')],
+ servername: 'a.b.test.com',
+ rejectUnauthorized: false
+}, {
port: serverPort,
key: loadPEM('agent3-key'),
cert: loadPEM('agent3-cert'),
@@ -95,28 +102,29 @@ server.addContext('*.test.com', SNIContexts['asterisk.test.com']);
server.listen(serverPort, startTest);
function startTest() {
- function connectClient(options, callback) {
+ var i = 0;
+ function start() {
+ // No options left
+ if (i === clientsOptions.length)
+ return server.close();
+
+ var options = clientsOptions[i++];
var client = tls.connect(options, function() {
clientResults.push(
client.authorizationError &&
/Hostname\/IP doesn't/.test(client.authorizationError));
client.destroy();
- callback();
+ // Continue
+ start();
});
};
- connectClient(clientsOptions[0], function() {
- connectClient(clientsOptions[1], function() {
- connectClient(clientsOptions[2], function() {
- server.close();
- });
- });
- });
+ start();
}
process.on('exit', function() {
assert.deepEqual(serverResults, ['a.example.com', 'b.test.com',
- 'c.wrong.com']);
- assert.deepEqual(clientResults, [true, true, false]);
+ 'a.b.test.com', 'c.wrong.com']);
+ assert.deepEqual(clientResults, [true, true, false, false]);
});
Something went wrong with that request. Please try again.