2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2015-02-19 14:14:36 +01:00
|
|
|
var common = require('../common');
|
|
|
|
var assert = require('assert');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
|
|
|
console.log('1..0 # Skipped: missing crypto');
|
2015-07-07 20:55:55 +05:30
|
|
|
return;
|
2015-03-04 12:11:21 +11:00
|
|
|
}
|
2015-02-19 14:14:36 +01:00
|
|
|
var tls = require('tls');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
|
|
|
var net = require('net');
|
2015-02-19 14:14:36 +01:00
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem')
|
|
|
|
};
|
|
|
|
|
|
|
|
var server = tls.createServer(options, function(c) {
|
|
|
|
setTimeout(function() {
|
|
|
|
c.write('hello');
|
|
|
|
setTimeout(function() {
|
|
|
|
c.destroy();
|
|
|
|
server.close();
|
2015-03-18 20:15:06 -07:00
|
|
|
}, 150);
|
|
|
|
}, 150);
|
2015-02-19 14:14:36 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
server.listen(common.PORT, function() {
|
|
|
|
var socket = net.connect(common.PORT, function() {
|
2015-05-13 21:25:57 -05:00
|
|
|
var s = socket.setTimeout(common.platformTimeout(240), function() {
|
2015-04-07 20:41:07 +02:00
|
|
|
throw new Error('timeout');
|
|
|
|
});
|
2015-05-13 21:25:57 -05:00
|
|
|
assert.ok(s instanceof net.Socket);
|
2015-02-19 14:14:36 +01:00
|
|
|
|
|
|
|
var tsocket = tls.connect({
|
|
|
|
socket: socket,
|
|
|
|
rejectUnauthorized: false
|
|
|
|
});
|
|
|
|
tsocket.resume();
|
|
|
|
});
|
|
|
|
});
|