2016-09-27 08:20:10 +02:00
|
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
|
2017-07-01 01:29:09 +02:00
|
|
|
if (!common.hasCrypto)
|
2016-09-27 08:20:10 +02:00
|
|
|
common.skip('missing crypto');
|
2017-07-01 01:29:09 +02:00
|
|
|
|
2016-09-27 08:20:10 +02:00
|
|
|
const tls = require('tls');
|
|
|
|
const net = require('net');
|
|
|
|
const assert = require('assert');
|
|
|
|
|
|
|
|
const bonkers = Buffer.alloc(1024, 42);
|
|
|
|
|
|
|
|
|
|
|
|
const server = tls.createServer({})
|
|
|
|
.listen(0, function() {
|
|
|
|
const c = net.connect({ port: this.address().port }, function() {
|
|
|
|
c.write(bonkers);
|
|
|
|
});
|
|
|
|
|
2016-10-27 05:56:08 +02:00
|
|
|
}).on('tlsClientError', common.mustCall(function(e) {
|
2016-09-27 08:20:10 +02:00
|
|
|
assert.ok(e instanceof Error,
|
|
|
|
'Instance of Error should be passed to error handler');
|
2017-06-18 15:22:32 +02:00
|
|
|
assert.ok(
|
|
|
|
/SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol/.test(e.message),
|
|
|
|
'Expecting SSL unknown protocol');
|
2016-09-27 08:20:10 +02:00
|
|
|
|
2016-10-27 05:56:08 +02:00
|
|
|
server.close();
|
|
|
|
}));
|