Skip to content

Commit b6d3d52

Browse files
mhdawsontargos
authored andcommitted
test: adjust check to use OpenSSL sec level
Some checks should use the sec level instead of the OpenSSL version, adjust test-tls-client-mindhsize.js Signed-off-by: Michael Dawson <[email protected]> PR-URL: #56819 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 974cec7 commit b6d3d52

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

test/parallel/test-tls-client-mindhsize.js

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1+
// Flags: --expose-internals
12
'use strict';
23
const common = require('../common');
34
if (!common.hasCrypto)
45
common.skip('missing crypto');
56

6-
const { hasOpenSSL } = require('../common/crypto');
7+
// OpenSSL has a set of security levels which affect what algorithms
8+
// are available by default. Different OpenSSL veresions have different
9+
// default security levels and we use this value to adjust what a test
10+
// expects based on the security level. You can read more in
11+
// https://docs.openssl.org/1.1.1/man3/SSL_CTX_set_security_level/#default-callback-behaviour
12+
const secLevel = require('internal/crypto/util').getOpenSSLSecLevel();
713
const assert = require('assert');
814
const tls = require('tls');
915
const fixtures = require('../common/fixtures');
@@ -38,8 +44,9 @@ function test(size, err, next) {
3844
server.listen(0, function() {
3945
// Client set minimum DH parameter size to 2048 or 3072 bits
4046
// so that it fails when it makes a connection to the tls
41-
// server where is too small
42-
const minDHSize = hasOpenSSL(3, 2) ? 3072 : 2048;
47+
// server where is too small. This depends on the openssl
48+
// security level
49+
const minDHSize = (secLevel > 1) ? 3072 : 2048;
4350
const client = tls.connect({
4451
minDHSize: minDHSize,
4552
port: this.address().port,
@@ -77,8 +84,8 @@ function testDHE3072() {
7784
test(3072, false, null);
7885
}
7986

80-
if (hasOpenSSL(3, 2)) {
81-
// Minimum size for OpenSSL 3.2 is 2048 by default
87+
if (secLevel > 1) {
88+
// Minimum size for OpenSSL security level 2 and above is 2048 by default
8289
testDHE2048(true, testDHE3072);
8390
} else {
8491
testDHE1024();

0 commit comments

Comments
 (0)