Skip to content

Commit 8c29420

Browse files
davidbenevanlucas
authored andcommitted
test: fix test-https-agent-session-eviction for 1.1
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 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Rod Vagg <rod@vagg.org>
1 parent 3d438f8 commit 8c29420

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/node_constants.cc

+4
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,10 @@ void DefineSignalConstants(Local<Object> target) {
759759
}
760760

761761
void DefineOpenSSLConstants(Local<Object> target) {
762+
#ifdef OPENSSL_VERSION_NUMBER
763+
NODE_DEFINE_CONSTANT(target, OPENSSL_VERSION_NUMBER);
764+
#endif
765+
762766
#ifdef SSL_OP_ALL
763767
NODE_DEFINE_CONSTANT(target, SSL_OP_ALL);
764768
#endif

test/parallel/test-https-agent-session-eviction.js

+20-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ if (!common.hasCrypto)
88

99
const assert = require('assert');
1010
const https = require('https');
11-
const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET;
11+
const { OPENSSL_VERSION_NUMBER, SSL_OP_NO_TICKET } =
12+
require('crypto').constants;
1213

1314
const options = {
1415
key: readKey('agent1-key.pem'),
@@ -58,14 +59,25 @@ function second(server, session) {
5859
res.resume();
5960
});
6061

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

65-
req.on('close', function() {
66-
third(server);
67-
});
68-
}));
76+
req.on('close', function() {
77+
third(server);
78+
});
79+
}));
80+
}
6981
req.end();
7082
}
7183

0 commit comments

Comments
 (0)