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

Commit

Permalink
tls: fix 'hostless' tls connection verification
Browse files Browse the repository at this point in the history
And fix last failing tests
  • Loading branch information
indutny committed Jul 20, 2012
1 parent 5950db1 commit 50122fe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/tls.js
Expand Up @@ -1208,7 +1208,7 @@ exports.connect = function(/* [port, host], options, cb */) {
var sslcontext = crypto.createCredentials(options);

convertNPNProtocols(options.NPNProtocols, this);
var hostname = options.servername || options.host,
var hostname = options.servername || options.host || 'localhost',
pair = new SecurePair(sslcontext, false, true,
options.rejectUnauthorized === true ? true : false,
{
Expand Down
7 changes: 5 additions & 2 deletions test/simple/test-tls-client-verify.js
Expand Up @@ -25,6 +25,7 @@ if (!process.versions.openssl) {
}


var hosterr = 'Hostname/IP doesn\'t match certificate\'s altnames';
var testCases =
[{ ca: ['ca1-cert'],
key: 'agent2-key',
Expand Down Expand Up @@ -101,10 +102,12 @@ function testServers(index, servers, clientOptions, cb) {

console.error('connecting...');
var client = tls.connect(clientOptions, function() {
var authorized = client.authorized ||
client.authorizationError === hosterr;

console.error('expected: ' + ok + ' authed: ' + client.authorized);
console.error('expected: ' + ok + ' authed: ' + authorized);

assert.equal(ok, client.authorized);
assert.equal(ok, authorized);
server.close();
});

Expand Down

0 comments on commit 50122fe

Please sign in to comment.