summaryrefslogtreecommitdiff
path: root/test/simple/test-tls-new-session-hang.js
blob: 6fdf89817ab6d06bba37320c874bbe941bfaa70a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var common = require('../common');

if (!process.features.tls_ocsp) {
  console.error('Skipping because node compiled without OpenSSL or ' +
                'with old OpenSSL version.');
  process.exit(0);
}

var assert = require('assert');
var tls = require('tls');
var constants = require('constants');
var fs = require('fs');
var join = require('path').join;

var keyFile = join(common.fixturesDir, 'keys', 'agent1-key.pem');
var certFile = join(common.fixturesDir, 'keys', 'agent1-cert.pem');
var caFile = join(common.fixturesDir, 'keys', 'ca1-cert.pem');
var key = fs.readFileSync(keyFile);
var cert = fs.readFileSync(certFile);

var server = tls.createServer({
  cert: cert,
  key: key
}, function (socket) {
  socket.destroySoon();
});

server.on('resumeSession', common.mustCall(function() {
  // Should not be actually called
}, 0));

server.listen(common.PORT, function() {
  var client = tls.connect({
    rejectUnauthorized: false,
    port: common.PORT,

    // Just to make sure that `newSession` is going to be called
    secureOptions: constants.SSL_OP_NO_TICKET
  }, function() {
    server.close();
  });
});