Refs #1983.
var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'));
var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem'));
-var conn = tls.connect(common.PORT, {cert: cert, key: key}, function() {
+var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
assert.ok(false); // callback should never be executed
});
conn.on('error', function() {
server.listen(common.PORT, function() {
var session1 = null;
- var client1 = tls.connect(common.PORT, function() {
+ var client1 = tls.connect({port: common.PORT}, function() {
console.log('connect1');
assert.ok(!client1.isSessionReused(), 'Session *should not* be reused.');
session1 = client1.getSession();
client1.on('close', function() {
console.log('close1');
- var client2 = tls.connect(common.PORT, {'session': session1}, function() {
+ var client2 = tls.connect({'session': session1, port: common.PORT}, function() {
console.log('connect2');
assert.ok(client2.isSessionReused(), 'Session *should* be reused.');
});
var b = '';
console.error('connecting...');
- var client = tls.connect(common.PORT, clientOptions, function() {
+ var client = tls.connect(clientOptions, function() {
console.error('expected: ' + ok + ' authed: ' + client.authorized);
if (!tcase) return;
var clientOptions = {
+ port: common.PORT,
ca: tcase.ca.map(loadPEM),
key: loadPEM(tcase.key),
cert: loadPEM(tcase.cert)
});
server.listen(common.PORT, function() {
- var client1 = tls.connect(common.PORT, function() {
+ var client1 = tls.connect({port: common.PORT}, function() {
++clientConnected;
client1.end();
});
- var client2 = tls.connect(common.PORT);
+ var client2 = tls.connect({port: common.PORT});
client2.on('secureConnect', function() {
++clientConnected;
client2.end();
assert.ok(errorEmitted);
});
- var conn = tls.connect(common.PORT, {cert: cert, key: key}, function() {
+ var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() {
assert.ok(false); // callback should never be executed
});
NPNProtocols: ['a', 'b', 'c']
};
+var serverPort = common.PORT;
+
var clientsOptions = [{
+ port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['a', 'b', 'c']
},{
+ port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['c', 'b', 'e']
},{
+ port: serverPort,
key: serverOptions.key,
cert: serverOptions.cert,
crl: serverOptions.crl,
NPNProtocols: ['first-priority-unsupported', 'x', 'y']
}];
-var serverPort = common.PORT;
-
var serverResults = [],
clientsResults = [];
function startTest() {
function connectClient(options, callback) {
- var client = tls.connect(serverPort, 'localhost', options, function() {
+ var client = tls.connect(options, function() {
clientsResults.push(client.npnProtocol);
client.destroy();
var connectCount = 0;
server.listen(common.PORT, function() {
- var c = tls.connect(common.PORT, {
+ var c = tls.connect({
+ port: common.PORT,
key: key,
passphrase: 'passphrase',
cert: cert
});
assert.throws(function() {
- tls.connect(common.PORT, {
+ tls.connect({
+ port: common.PORT,
key: key,
passphrase: 'invalid',
cert: cert
});
server.listen(common.PORT, function() {
- var c = tls.connect(common.PORT, function() {
+ var c = tls.connect({port: common.PORT}, function() {
console.log('client connected');
c.socket.on('end', function() {
console.log('client socket ended');
server.listen(common.PORT, function() {
var resumed = false;
- var client = tls.connect(common.PORT, function() {
+ var client = tls.connect({port: common.PORT}, function() {
client.pause();
common.debug('paused');
send();
cleartext.end('World');
});
server.listen(common.PORT, function() {
- var socket = tls.connect(common.PORT, function() {
+ var socket = tls.connect({port: common.PORT}, function() {
var peerCert = socket.getPeerCertificate();
common.debug(util.inspect(peerCert));
assert.equal(peerCert.subject.subjectAltName,
assert.equal(server.address().address, '127.0.0.1');
assert.equal(server.address().port, common.PORT);
- var c = tls.connect(common.PORT, '127.0.0.1', function() {
+ var c = tls.connect({port: common.PORT, host: '127.0.0.1'}, function() {
assert.equal(c.address().address, c.socket.address().address);
assert.equal(c.address().port, c.socket.address().port);
});
server.listen(common.PORT, function() {
- var socket = tls.connect(common.PORT);
+ var socket = tls.connect({port: common.PORT});
});
process.on('exit', function() {
server.listen(common.PORT, function() {
- var client = tls.connect(common.PORT);
+ var client = tls.connect({port: common.PORT});
var buffer = '';
}
};
+var serverPort = common.PORT;
var clientsOptions = [{
+ port: serverPort,
key: loadPEM('agent1-key'),
cert: loadPEM('agent1-cert'),
ca: [loadPEM('ca1-cert')],
servername: 'a.example.com'
},{
+ port: serverPort,
key: loadPEM('agent2-key'),
cert: loadPEM('agent2-cert'),
ca: [loadPEM('ca2-cert')],
servername: 'b.test.com'
},{
+ port: serverPort,
key: loadPEM('agent3-key'),
cert: loadPEM('agent3-cert'),
ca: [loadPEM('ca1-cert')],
servername: 'c.wrong.com'
}];
-var serverPort = common.PORT;
-
var serverResults = [],
clientResults = [];
function startTest() {
function connectClient(options, callback) {
- var client = tls.connect(serverPort, 'localhost', options, function() {
+ var client = tls.connect(options, function() {
clientResults.push(client.authorized);
client.destroy();