Skip to content

Commit e91c2a7

Browse files
OttoHollmannrichardlau
authored andcommitted
test: adapt tests for OpenSSL 3.1
PR-URL: nodejs#47859 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 45c1ea8 commit e91c2a7

6 files changed

+24
-4
lines changed

test/common/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ const hasCrypto = Boolean(process.versions.openssl) &&
5656
!process.env.NODE_SKIP_CRYPTO;
5757

5858
const hasOpenSSL3 = hasCrypto &&
59-
require('crypto').constants.OPENSSL_VERSION_NUMBER >= 805306368;
59+
require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30000000;
60+
61+
const hasOpenSSL31 = hasCrypto &&
62+
require('crypto').constants.OPENSSL_VERSION_NUMBER >= 0x30100000;
6063

6164
const hasQuic = hasCrypto && !!process.config.variables.openssl_quic;
6265

@@ -899,6 +902,7 @@ const common = {
899902
hasIntl,
900903
hasCrypto,
901904
hasOpenSSL3,
905+
hasOpenSSL31,
902906
hasQuic,
903907
hasMultiLocalhost,
904908
invalidArgTypeHelper,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ function faultyServer(port) {
5454
function second(server, session) {
5555
const req = https.request({
5656
port: server.address().port,
57+
ciphers: (common.hasOpenSSL31 ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT'),
5758
rejectUnauthorized: false
5859
}, function(res) {
5960
res.resume();

test/parallel/test-tls-alert.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const server = tls.Server({
4242
cert: loadPEM('agent2-cert')
4343
}, null).listen(0, common.mustCall(() => {
4444
const args = ['s_client', '-quiet', '-tls1_1',
45+
'-cipher', (common.hasOpenSSL31 ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT'),
4546
'-connect', `127.0.0.1:${server.address().port}`];
4647

4748
execFile(common.opensslCli, args, common.mustCall((err, _, stderr) => {

test/parallel/test-tls-getprotocol.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,18 @@ const tls = require('tls');
1111
const fixtures = require('../common/fixtures');
1212

1313
const clientConfigs = [
14-
{ secureProtocol: 'TLSv1_method', version: 'TLSv1' },
15-
{ secureProtocol: 'TLSv1_1_method', version: 'TLSv1.1' },
16-
{ secureProtocol: 'TLSv1_2_method', version: 'TLSv1.2' },
14+
{
15+
secureProtocol: 'TLSv1_method',
16+
version: 'TLSv1',
17+
ciphers: (common.hasOpenSSL31 ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT')
18+
}, {
19+
secureProtocol: 'TLSv1_1_method',
20+
version: 'TLSv1.1',
21+
ciphers: (common.hasOpenSSL31 ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT')
22+
}, {
23+
secureProtocol: 'TLSv1_2_method',
24+
version: 'TLSv1.2'
25+
},
1726
];
1827

1928
const serverConfig = {
@@ -30,6 +39,7 @@ const server = tls.createServer(serverConfig, common.mustCall(clientConfigs.leng
3039
tls.connect({
3140
host: common.localhostIPv4,
3241
port: server.address().port,
42+
ciphers: v.ciphers,
3343
rejectUnauthorized: false,
3444
secureProtocol: v.secureProtocol
3545
}, common.mustCall(function() {

test/parallel/test-tls-min-max-version.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ function test(cmin, cmax, cprot, smin, smax, sprot, proto, cerr, serr) {
2222
if (serr !== 'ERR_SSL_UNSUPPORTED_PROTOCOL')
2323
ciphers = 'ALL@SECLEVEL=0';
2424
}
25+
if (common.hasOpenSSL31 && cerr === 'ERR_SSL_TLSV1_ALERT_PROTOCOL_VERSION') {
26+
ciphers = 'DEFAULT@SECLEVEL=0';
27+
}
2528
// Report where test was called from. Strip leading garbage from
2629
// at Object.<anonymous> (file:line)
2730
// from the stack location, we only want the file:line part.

test/parallel/test-tls-session-cache.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ function doTest(testOptions, callback) {
100100
const args = [
101101
's_client',
102102
'-tls1',
103+
'-cipher', (common.hasOpenSSL31 ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT'),
103104
'-connect', `localhost:${this.address().port}`,
104105
'-servername', 'ohgod',
105106
'-key', fixtures.path('keys/rsa_private.pem'),

0 commit comments

Comments
 (0)