◐ Shell
clean mode source ↗

test: skip tls-deprecated secp256k1 on OpenSSL 4.0 · nodejs/node@375a993

Original file line numberDiff line numberDiff line change

@@ -8,7 +8,7 @@ if (!common.hasCrypto) {

88

common.skip('missing crypto');

99

}

1010
11-

const { opensslCli } = require('../common/crypto');

11+

const { opensslCli, hasOpenSSL } = require('../common/crypto');

1212

const crypto = require('crypto');

1313
1414

if (!opensslCli) {

@@ -24,11 +24,17 @@ function loadPEM(n) {

2424

return fixtures.readKey(`${n}.pem`);

2525

}

2626
27+

// OpenSSL 4.0 disables support for deprecated elliptic curves from RFC 8422

28+

// (including secp256k1) by default.

29+

const ecdhCurve = hasOpenSSL(4, 0) ?

30+

'prime256v1:secp521r1' :

31+

'secp256k1:prime256v1:secp521r1';

32+
2733

const options = {

2834

key: loadPEM('agent2-key'),

2935

cert: loadPEM('agent2-cert'),

3036

ciphers: '-ALL:ECDHE-RSA-AES128-SHA256',

31-

ecdhCurve: 'secp256k1:prime256v1:secp521r1',

37+

ecdhCurve,

3238

maxVersion: 'TLSv1.2',

3339

};

3440

@@ -60,6 +66,11 @@ const server = tls.createServer(options, (conn) => {

6066

unsupportedCurves.push('brainpoolP256r1');

6167

}

6268
69+

// Deprecated RFC 8422 curves are disabled by default in OpenSSL 4.0.

70+

if (hasOpenSSL(4, 0)) {

71+

unsupportedCurves.push('secp256k1');

72+

}

73+
6374

unsupportedCurves.forEach((ecdhCurve) => {

6475

assert.throws(() => tls.createServer({ ecdhCurve }),

6576

/Error: Failed to set ECDH curve/);