2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-04-21 18:24:13 -03:00
|
|
|
var common = require('../common');
|
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
|
|
|
console.log('1..0 # Skipped: missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-04-21 18:24:13 -03:00
|
|
|
}
|
|
|
|
var tls = require('tls');
|
|
|
|
|
|
|
|
var assert = require('assert');
|
|
|
|
var fs = require('fs');
|
|
|
|
var path = require('path');
|
|
|
|
|
|
|
|
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
|
|
|
|
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
|
|
|
|
|
2015-08-13 12:14:34 -04:00
|
|
|
// https://github.com/nodejs/node/issues/1489
|
2015-04-21 18:24:13 -03:00
|
|
|
// tls.connect(options) with no options.host should accept a cert with
|
|
|
|
// CN:'localhost'
|
|
|
|
tls.createServer({
|
|
|
|
key: key,
|
|
|
|
cert: cert
|
|
|
|
}).listen(common.PORT);
|
|
|
|
|
|
|
|
var socket = tls.connect({
|
2016-01-13 21:42:45 +01:00
|
|
|
port: common.PORT,
|
|
|
|
ca: cert,
|
|
|
|
// No host set here. 'localhost' is the default,
|
|
|
|
// but tls.checkServerIdentity() breaks before the fix with:
|
|
|
|
// Error: Hostname/IP doesn't match certificate's altnames:
|
|
|
|
// "Host: undefined. is not cert's CN: localhost"
|
2015-04-21 18:24:13 -03:00
|
|
|
}, function() {
|
2015-05-19 13:00:06 +02:00
|
|
|
assert(socket.authorized);
|
|
|
|
process.exit();
|
2015-04-21 18:24:13 -03:00
|
|
|
});
|