• 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');
9const util = require('util');
10const fixtures = require('../common/fixtures');
11
12const sent = 'hello world';
13const serverOptions = {
14  isServer: true,
15  key: fixtures.readKey('agent1-key.pem'),
16  cert: fixtures.readKey('agent1-cert.pem')
17};
18
19let ssl = null;
20
21process.on('exit', function() {
22  assert.ok(ssl !== null);
23  // If the internal pointer to stream_ isn't cleared properly then this
24  // will abort.
25  util.inspect(ssl);
26});
27
28const server = tls.createServer(serverOptions, function(s) {
29  s.on('data', function() { });
30  s.on('end', function() {
31    server.close();
32    s.destroy();
33  });
34}).listen(0, function() {
35  const c = new tls.TLSSocket();
36  ssl = c.ssl;
37  c.connect(this.address().port, function() {
38    c.end(sent);
39  });
40});
41