2015-05-19 11:00:06 +00:00
|
|
|
'use strict';
|
2010-12-11 10:45:38 +00:00
|
|
|
var common = require('../common');
|
2015-03-04 01:11:21 +00:00
|
|
|
|
|
|
|
if (!common.hasCrypto) {
|
|
|
|
console.log('1..0 # Skipped: missing crypto');
|
2015-07-07 15:25:55 +00:00
|
|
|
return;
|
2015-03-04 01:11:21 +00:00
|
|
|
}
|
2010-12-11 10:45:38 +00:00
|
|
|
var tls = require('tls');
|
2015-03-04 01:11:21 +00:00
|
|
|
|
2010-12-11 10:45:38 +00:00
|
|
|
var fs = require('fs');
|
|
|
|
var net = require('net');
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'),
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem')
|
|
|
|
};
|
|
|
|
|
2012-08-29 20:53:00 +00:00
|
|
|
var server = tls.createServer(options, function(s) {
|
2011-10-04 22:08:18 +00:00
|
|
|
s.write('welcome!\n');
|
2010-12-11 10:45:38 +00:00
|
|
|
s.pipe(s);
|
|
|
|
});
|
|
|
|
|
2011-10-04 22:08:18 +00:00
|
|
|
server.listen(common.PORT, function() {
|
2010-12-11 10:45:38 +00:00
|
|
|
var c = net.createConnection(common.PORT);
|
|
|
|
|
2011-10-04 22:08:18 +00:00
|
|
|
c.on('connect', function() {
|
|
|
|
c.write('blah\nblah\nblah\n');
|
2010-12-11 10:45:38 +00:00
|
|
|
});
|
|
|
|
|
2011-10-04 22:08:18 +00:00
|
|
|
c.on('end', function() {
|
2010-12-11 10:45:38 +00:00
|
|
|
server.close();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|