• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4if (!common.hasCrypto)
5  common.skip('missing crypto');
6
7const assert = require('assert');
8const tls = require('tls');
9
10const options = {
11  SNICallback: (name, callback) => {
12    callback(null, tls.createSecureContext());
13  }
14};
15
16const server = tls.createServer(options, (c) => {
17  assert.fail('Should not be called');
18}).on('tlsClientError', common.mustCall((err, c) => {
19  assert(/SSL_use_certificate:passed a null parameter/i.test(err.message));
20  server.close();
21})).listen(0, common.mustCall(() => {
22  const c = tls.connect({
23    port: server.address().port,
24    rejectUnauthorized: false,
25    servername: 'any.name'
26  }, common.mustNotCall());
27
28  c.on('error', common.mustCall((err) => {
29    assert(/Client network socket disconnected/.test(err.message));
30  }));
31}));
32