mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 05:00:21 +00:00

This commit enables node to dynamically link against OpenSSL 3.0. The motivation for opening this PR even though OpenSSL 3.0 has not been released yet is to allow a nightly CI job to be created. This will allow us stay on top of changes required for OpenSSL 3.0, and also to make sure that changes to node crypto do not cause issues when linking to OpenSSL 3.0. PR-URL: https://github.com/nodejs/node/pull/37669 Refs: https://github.com/nodejs/node/issues/29817 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com>
71 lines
1.6 KiB
JavaScript
71 lines
1.6 KiB
JavaScript
// Flags: --tls-min-v1.0
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const { readKey } = require('../common/fixtures');
|
|
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const https = require('https');
|
|
const { SSL_OP_NO_TICKET } = require('crypto').constants;
|
|
|
|
const options = {
|
|
key: readKey('agent1-key.pem'),
|
|
cert: readKey('agent1-cert.pem'),
|
|
secureOptions: SSL_OP_NO_TICKET,
|
|
ciphers: 'RSA@SECLEVEL=0'
|
|
};
|
|
|
|
// Create TLS1.2 server
|
|
https.createServer(options, function(req, res) {
|
|
res.end('ohai');
|
|
}).listen(0, function() {
|
|
first(this);
|
|
});
|
|
|
|
// Do request and let agent cache the session
|
|
function first(server) {
|
|
const port = server.address().port;
|
|
const req = https.request({
|
|
port: port,
|
|
rejectUnauthorized: false
|
|
}, function(res) {
|
|
res.resume();
|
|
|
|
server.close(function() {
|
|
faultyServer(port);
|
|
});
|
|
});
|
|
req.end();
|
|
}
|
|
|
|
// Create TLS1 server
|
|
function faultyServer(port) {
|
|
options.secureProtocol = 'TLSv1_method';
|
|
https.createServer(options, function(req, res) {
|
|
res.end('hello faulty');
|
|
}).listen(port, function() {
|
|
second(this);
|
|
});
|
|
}
|
|
|
|
// Attempt to request using cached session
|
|
function second(server, session) {
|
|
const req = https.request({
|
|
port: server.address().port,
|
|
rejectUnauthorized: false
|
|
}, function(res) {
|
|
res.resume();
|
|
});
|
|
|
|
// 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();
|
|
}));
|
|
|
|
req.end();
|
|
}
|