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: https://github.com/nodejs/node/pull/16130
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Rod Vagg <rod@vagg.org>
This commit is contained in:
David Benjamin authored and Rod Vagg committed 2017-11-11 20:42:50 +11:00
1 parent e433afa652
commit d9b9229d98
2 files changed
+24 -8

No files matched your search

+4
View File
@@ -759,6 +759,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
@@ -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'),
@@ -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();
}