Skip to content

Commit

Permalink
test: fix test-https-agent-session-eviction for 1.1
Browse files Browse the repository at this point in the history
This test is testing the workaround for an OpenSSL 1.0.x bug, which was
fixed in 1.1.0. With the bug fixed, the test expectations need to change
slightly.

PR-URL: #16130
Backport-PR-URL: #18622
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
  • Loading branch information
davidben authored and gibfahn committed Feb 18, 2018
1 parent f883458 commit 92ec6f6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
4 changes: 4 additions & 0 deletions src/node_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,10 @@ void DefineSignalConstants(Local<Object> target) {
}

void DefineOpenSSLConstants(Local<Object> target) {
#ifdef OPENSSL_VERSION_NUMBER
NODE_DEFINE_CONSTANT(target, OPENSSL_VERSION_NUMBER);
#endif

#ifdef SSL_OP_ALL
NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
#endif
Expand Down
28 changes: 20 additions & 8 deletions test/parallel/test-https-agent-session-eviction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ if (!common.hasCrypto)

const assert = require('assert');
const https = require('https');
const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;
const { OPENSSL_VERSION_NUMBER, SSL_OP_NO_TICKET } =
require('crypto').constants;

const options = {
key: readKey('agent1-key.pem'),
Expand Down Expand Up @@ -58,14 +59,25 @@ function second(server, session) {
res.resume();
});

// Let it fail
req.on('error', common.mustCall(function(err) {
assert(/wrong version number/.test(err.message));
if (OPENSSL_VERSION_NUMBER >= 0x10100000) {
// Although we have a TLS 1.2 session to offer to the TLS 1.0 server,
// connection to the TLS 1.0 server should work.
req.on('response', common.mustCall(function(res) {
// The test is now complete for OpenSSL 1.1.0.
server.close();
}));
} else {
// OpenSSL 1.0.x mistakenly locked versions based on the session it was
// offering. This causes this sequent request to fail. Let it fail, but
// test that this is mitigated on the next try by invalidating the session.
req.on('error', common.mustCall(function(err) {
assert(/wrong version number/.test(err.message));

req.on('close', function() {
third(server);
});
}));
req.on('close', function() {
third(server);
});
}));
}
req.end();
}

Expand Down

0 comments on commit 92ec6f6

Please sign in to comment.