Skip to content

Commit f26cf09

Browse files
mhdawsontargos
authored andcommitted
test: fix test-tls-client-mindhsize for OpenSSL32
Refs: #53382 - OpenSSL32 has a minimum dh key size by 2048 by default. - Create larter 3072 dh key needed for testing and adjust tests to use it for builds with OpenSSL32 Signed-off-by: Michael Dawson <midawson@redhat.com> PR-URL: #54739 Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c6f9afe commit f26cf09

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

test/fixtures/keys/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ all: \
2424
dh512.pem \
2525
dh1024.pem \
2626
dh2048.pem \
27+
dh3072.pem \
2728
dherror.pem \
2829
dh_private.pem \
2930
dh_public.pem \
@@ -596,6 +597,9 @@ dh1024.pem:
596597
dh2048.pem:
597598
openssl dhparam -out dh2048.pem 2048
598599

600+
dh3072.pem:
601+
openssl dhparam -out dh3072.pem 3072
602+
599603
dherror.pem: dh1024.pem
600604
sed 's/^[^-].*/AAAAAAAAAA/g' dh1024.pem > dherror.pem
601605

test/fixtures/keys/dh3072.pem

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBiAKCAYEAmV6aZ8ADnmRQoF9aGlV1AmajCkoc2eEltua1KpGFrxM0cr99gcS9
3+
/zxTDo8ixwPoHBOOBD+9MN6KbSJ+61xvu9yQ2qt8HfNcUI7QZxdVQ4ZHCQM3Jw8h
4+
BPHFgjpx8w/pteZ3+L42felUxbd8/qfDv+gKsfuxrm6Ht7zzKLfbX9oNdJwpxX7N
5+
yGP3nNadYDM/ZmvmEY8xh2dwLHSMaAP1gxuWiitdYXX60Yg6EFgIotznqbdW075D
6+
KccGTTseFx9gNbxYkW33qX/p5IAf3wRFmptiRWCol88NHTDqtQRs0nhVQ1R28tiL
7+
rQhSJLHLSa4esF+whfC64oXECr2AtarcKWG+LX1dEWI4SXqurnBPiBoyqfVWHS4b
8+
PVgR90LlBJoXqblhsVrd+CkJI7ULDJmSA/cpgCqXH6vSvhb40yr5rpU4vZz+zhHY
9+
CTXVpH95JD35PiZOfQYhfDA4LGvfICPLIH7E8YL5v2F6Xxsf8trI5KiAs1S3TN8b
10+
lsLV6og5VoPXAgEC
11+
-----END DH PARAMETERS-----

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ function test(size, err, next) {
3535
});
3636

3737
server.listen(0, function() {
38-
// Client set minimum DH parameter size to 2048 bits so that
39-
// it fails when it make a connection to the tls server where
40-
// dhparams is 1024 bits
38+
// Client set minimum DH parameter size to 2048 or 3072 bits
39+
// so that it fails when it makes a connection to the tls
40+
// server where is too small
41+
const minDHSize = common.hasOpenSSL(3, 2) ? 3072 : 2048;
4142
const client = tls.connect({
42-
minDHSize: 2048,
43+
minDHSize: minDHSize,
4344
port: this.address().port,
4445
rejectUnauthorized: false,
4546
maxVersion: 'TLSv1.2',
@@ -60,16 +61,27 @@ function test(size, err, next) {
6061
// A client connection fails with an error when a client has an
6162
// 2048 bits minDHSize option and a server has 1024 bits dhparam
6263
function testDHE1024() {
63-
test(1024, true, testDHE2048);
64+
test(1024, true, testDHE2048(false, null));
65+
}
66+
67+
// Test a client connection when a client has an
68+
// 2048 bits minDHSize option
69+
function testDHE2048(expect_to_fail, next) {
70+
test(2048, expect_to_fail, next);
6471
}
6572

6673
// A client connection successes when a client has an
67-
// 2048 bits minDHSize option and a server has 2048 bits dhparam
68-
function testDHE2048() {
69-
test(2048, false, null);
74+
// 3072 bits minDHSize option and a server has 3072 bits dhparam
75+
function testDHE3072() {
76+
test(3072, false, null);
7077
}
7178

72-
testDHE1024();
79+
if (common.hasOpenSSL(3, 2)) {
80+
// Minimum size for OpenSSL 3.2 is 2048 by default
81+
testDHE2048(true, testDHE3072);
82+
} else {
83+
testDHE1024();
84+
}
7385

7486
assert.throws(() => test(512, true, common.mustNotCall()),
7587
/DH parameter is less than 1024 bits/);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy