Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68156cb

Browse filesBrowse files
mhdawsonrichardlau
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 d5b73e5 commit 68156cb
Copy full SHA for 68156cb

3 files changed

+36-9Lines changed: 36 additions & 9 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/fixtures/keys/Makefile‎

Copy file name to clipboardExpand all lines: test/fixtures/keys/Makefile
+4Lines 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
dsa_params.pem \
2930
dsa_private.pem \
@@ -594,6 +595,9 @@ dh1024.pem:
594595
dh2048.pem:
595596
openssl dhparam -out dh2048.pem 2048
596597

598+
dh3072.pem:
599+
openssl dhparam -out dh3072.pem 3072
600+
597601
dherror.pem: dh1024.pem
598602
sed 's/^[^-].*/AAAAAAAAAA/g' dh1024.pem > dherror.pem
599603

Collapse file

‎test/fixtures/keys/dh3072.pem‎

Copy file name to clipboard
+11Lines 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-----
Collapse file

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

Copy file name to clipboardExpand all lines: test/parallel/test-tls-client-mindhsize.js
+21-9Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.