0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-30 23:43:09 +01:00
nodejs/test/parallel/test-tls-timeout-server-2.js

33 lines
735 B
JavaScript
Raw Normal View History

'use strict';
var common = require('../common');
var assert = require('assert');
if (!common.hasCrypto) {
console.log('1..0 # Skipped: missing crypto');
process.exit();
}
var tls = require('tls');
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(cleartext) {
var s = cleartext.setTimeout(50, function() {
cleartext.destroy();
server.close();
});
assert.ok(s instanceof tls.TLSSocket);
});
server.listen(common.PORT, function() {
tls.connect({
host: '127.0.0.1',
port: common.PORT,
rejectUnauthorized: false
});
});