2015-05-19 13:00:06 +02:00
|
|
|
'use strict';
|
2012-12-03 18:29:01 +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
|
|
|
}
|
2012-12-03 18:29:01 +01:00
|
|
|
var https = require('https');
|
2015-03-04 12:11:21 +11:00
|
|
|
|
2012-12-03 18:29:01 +01:00
|
|
|
var net = require('net');
|
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
|
|
var clientErrors = 0;
|
|
|
|
|
|
|
|
|
|
process.on('exit', function() {
|
|
|
|
|
assert.equal(clientErrors, 1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var options = {
|
|
|
|
|
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'),
|
|
|
|
|
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'),
|
|
|
|
|
handshakeTimeout: 50
|
|
|
|
|
};
|
|
|
|
|
|
2015-10-20 11:40:54 -07:00
|
|
|
var server = https.createServer(options, common.fail);
|
2012-12-03 18:29:01 +01:00
|
|
|
|
|
|
|
|
server.on('clientError', function(err, conn) {
|
|
|
|
|
// Don't hesitate to update the asserts if the internal structure of
|
|
|
|
|
// the cleartext object ever changes. We're checking that the https.Server
|
|
|
|
|
// has closed the client connection.
|
|
|
|
|
assert.equal(conn._secureEstablished, false);
|
|
|
|
|
server.close();
|
|
|
|
|
clientErrors++;
|
2016-01-06 17:00:27 -05:00
|
|
|
conn.destroy();
|
2012-12-03 18:29:01 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
server.listen(common.PORT, function() {
|
|
|
|
|
net.connect({ host: '127.0.0.1', port: common.PORT });
|
|
|
|
|
});
|