Skip to content

Commit 9875885

Browse files
OttoHollmanntargos
authored andcommitted
test: adapt tests for OpenSSL 3.1
PR-URL: #47859 Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 3b00f3a commit 9875885

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
@@ -57,7 +57,10 @@ const hasCrypto = Boolean(process.versions.openssl) &&
5757
!process.env.NODE_SKIP_CRYPTO;
5858

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

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

@@ -911,6 +914,7 @@ const common = {
911914
hasIntl,
912915
hasCrypto,
913916
hasOpenSSL3,
917+
hasOpenSSL31,
914918
hasQuic,
915919
hasMultiLocalhost,
916920
invalidArgTypeHelper,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ function faultyServer(port) {
5656
function second(server, session) {
5757
const req = https.request({
5858
port: server.address().port,
59+
ciphers: (common.hasOpenSSL31 ? 'DEFAULT:@SECLEVEL=0' : 'DEFAULT'),
5960
rejectUnauthorized: false
6061
}, function(res) {
6162
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)