forked from svrjs/svrjs
Errors that occurred while adding SNI context to a server are now ignored.
This commit is contained in:
parent
9eb982dc92
commit
7dfdc7209e
1 changed files with 16 additions and 12 deletions
28
svr.js
28
svr.js
|
@ -2177,19 +2177,23 @@ if (!cluster.isPrimary) {
|
|||
}
|
||||
}
|
||||
if (secure) {
|
||||
sniCredentials.forEach(function (sniCredentialsSingle) {
|
||||
server.addContext(sniCredentialsSingle.name, {
|
||||
cert: sniCredentialsSingle.cert,
|
||||
key: sniCredentialsSingle.key
|
||||
try {
|
||||
sniCredentials.forEach(function (sniCredentialsSingle) {
|
||||
server.addContext(sniCredentialsSingle.name, {
|
||||
cert: sniCredentialsSingle.cert,
|
||||
key: sniCredentialsSingle.key
|
||||
});
|
||||
try {
|
||||
var snMatches = sniCredentialsSingle.name.match(/^([^:[]*|\[[^]]*\]?)((?::.*)?)$/);
|
||||
if (!snMatches[1][0].match(/^\.+$/)) snMatches[1][0] = snMatches[1][0].replace(/\.+$/, "");
|
||||
server._contexts[server._contexts.length - 1][0] = new RegExp("^" + snMatches[1].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.:]*") + ((snMatches[1][0] == "[" || snMatches[1].match(/^(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/)) ? "" : "\.?") + snMatches[2].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.]*") + "$", "i");
|
||||
} catch (ex) {
|
||||
// Can't replace regex, ignoring...
|
||||
}
|
||||
});
|
||||
try {
|
||||
var snMatches = sniCredentialsSingle.name.match(/^([^:[]*|\[[^]]*\]?)((?::.*)?)$/);
|
||||
if (!snMatches[1][0].match(/^\.+$/)) snMatches[1][0] = snMatches[1][0].replace(/\.+$/, "");
|
||||
server._contexts[server._contexts.length - 1][0] = new RegExp("^" + snMatches[1].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.:]*") + ((snMatches[1][0] == "[" || snMatches[1].match(/^(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\.(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$/)) ? "" : "\.?") + snMatches[2].replace(/([.^$+?\-\\[\]{}])/g, "\\$1").replace(/\*/g, "[^.]*") + "$", "i");
|
||||
} catch (ex) {
|
||||
// Can't replace regex, ignoring...
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
// SNI error
|
||||
}
|
||||
}
|
||||
server.on("request", reqhandler);
|
||||
server.on("checkExpectation", reqhandler);
|
||||
|
|
Reference in a new issue