1'use strict'; 2const common = require('../common'); 3 4if (!common.hasCrypto) 5 common.skip('missing crypto'); 6 7const tls = require('tls'); 8const net = require('net'); 9const assert = require('assert'); 10 11const bonkers = Buffer.alloc(1024, 42); 12 13 14const server = tls.createServer({}) 15 .listen(0, function() { 16 const c = net.connect({ port: this.address().port }, function() { 17 c.write(bonkers); 18 }); 19 20 }).on('tlsClientError', common.mustCall(function(e) { 21 assert.ok(e instanceof Error, 22 'Instance of Error should be passed to error handler'); 23 assert.ok( 24 /SSL routines:[^:]*:wrong version number/.test( 25 e.message), 26 'Expecting SSL unknown protocol'); 27 28 server.close(); 29 })); 30