0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/parallel/test-tls-junk-closes-server.js

31 lines
690 B
JavaScript
Raw Normal View History

'use strict';
const common = require('../common');
if (!common.hasCrypto) {
common.skip('missing crypto');
return;
}
const tls = require('tls');
const fs = require('fs');
const net = require('net');
2010-12-11 11:45:38 +01:00
const options = {
2010-12-11 11:45:38 +01:00
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
};
const server = tls.createServer(options, common.fail);
2010-12-11 11:45:38 +01:00
server.listen(0, common.mustCall(function() {
const c = net.createConnection(this.address().port);
2010-12-11 11:45:38 +01:00
c.on('connect', common.mustCall(function() {
c.write('blah\nblah\nblah\n');
}));
2010-12-11 11:45:38 +01:00
c.on('end', common.mustCall(function() {
2010-12-11 11:45:38 +01:00
server.close();
}));
}));