Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ if (!common.hasCrypto)
common.skip('missing crypto');

const tmpdir = require('../common/tmpdir');
tmpdir.refresh();

doTest();

Expand Down Expand Up @@ -56,7 +57,8 @@ function doTest() {
key: key,
cert: cert,
ca: [cert],
sessionTimeout: SESSION_TIMEOUT
sessionTimeout: SESSION_TIMEOUT,
maxVersion: 'TLSv1.2',
};

// We need to store a sample session ticket in the fixtures directory because
Expand All @@ -79,17 +81,17 @@ function doTest() {
's_client',
'-connect', `localhost:${common.PORT}`,
'-sess_in', sessionFileName,
'-sess_out', sessionFileName
'-sess_out', sessionFileName,
];
const client = spawn(common.opensslCli, flags, {
stdio: ['ignore', 'pipe', 'ignore']
});

let clientOutput = '';
client.stdout.on('data', function(data) {
client.stdout.on('data', (data) => {
clientOutput += data.toString();
});
client.on('exit', function(code) {
client.on('exit', (code) => {
let connectionType;
const grepConnectionType = (line) => {
const matches = line.match(/(New|Reused), /);
Expand All @@ -102,25 +104,26 @@ function doTest() {
if (!lines.some(grepConnectionType)) {
throw new Error('unexpected output from openssl client');
}
assert.strictEqual(code, 0);
cb(connectionType);
});
}

const server = tls.createServer(options, function(cleartext) {
cleartext.on('error', function(er) {
const server = tls.createServer(options, (cleartext) => {
cleartext.on('error', (er) => {
if (er.code !== 'ECONNRESET')
throw er;
});
cleartext.end();
});

server.listen(common.PORT, function() {
Client(function(connectionType) {
server.listen(common.PORT, () => {
Client((connectionType) => {
assert.strictEqual(connectionType, 'New');
Client(function(connectionType) {
Client((connectionType) => {
assert.strictEqual(connectionType, 'Reused');
setTimeout(function() {
Client(function(connectionType) {
setTimeout(() => {
Client((connectionType) => {
assert.strictEqual(connectionType, 'New');
server.close();
});
Expand Down