Skip to content

Commit 03fefb2

Browse files
AdamMajertargos
authored andcommitted
crypto: don't disable TLS 1.3 without suites
In the manual page, there is a statement that ciphersuites contain explicit default settings - all TLS 1.3 ciphersuites enabled. In node, we assume that an empty setting mean no ciphersuites and we disable TLS 1.3. A correct approach to disabling TLS 1.3 is to disable TLS 1.3 and by not override the default ciphersuits with an empty string. So, only override OpenSSL's TLS 1.3 ciphersuites with an explicit list of ciphers. If none are acceptable, the correct approach is to disable TLS 1.3 instead elsewhere. Fixes: #43419 PR-URL: #43427 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 8d2389a commit 03fefb2

15 files changed

+54
-23
lines changed

benchmark/tls/secure-pair.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function main({ dur, size, securing }) {
2525
isServer: true,
2626
requestCert: true,
2727
rejectUnauthorized: true,
28+
maxVersion: 'TLSv1.2',
2829
};
2930

3031
const server = net.createServer(onRedirectConnection);
@@ -38,6 +39,7 @@ function main({ dur, size, securing }) {
3839
cert: options.cert,
3940
isServer: false,
4041
rejectUnauthorized: false,
42+
maxVersion: options.maxVersion,
4143
};
4244
const network = securing === 'clear' ? net : tls;
4345
const conn = network.connect(clientOptions, () => {

benchmark/tls/throughput-c2s.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ function main({ dur, type, size }) {
3333
key: fixtures.readKey('rsa_private.pem'),
3434
cert: fixtures.readKey('rsa_cert.crt'),
3535
ca: fixtures.readKey('rsa_ca.crt'),
36-
ciphers: 'AES256-GCM-SHA384'
36+
ciphers: 'AES256-GCM-SHA384',
37+
maxVersion: 'TLSv1.2',
3738
};
3839

3940
const server = tls.createServer(options, onConnection);

benchmark/tls/throughput-s2c.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ function main({ dur, type, sendchunklen, recvbuflen, recvbufgenfn }) {
4040
key: fixtures.readKey('rsa_private.pem'),
4141
cert: fixtures.readKey('rsa_cert.crt'),
4242
ca: fixtures.readKey('rsa_ca.crt'),
43-
ciphers: 'AES256-GCM-SHA384'
43+
ciphers: 'AES256-GCM-SHA384',
44+
maxVersion: 'TLSv1.2',
4445
};
4546

4647
let socketOpts;

benchmark/tls/tls-connect.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function main(conf) {
2121
key: fixtures.readKey('rsa_private.pem'),
2222
cert: fixtures.readKey('rsa_cert.crt'),
2323
ca: fixtures.readKey('rsa_ca.crt'),
24-
ciphers: 'AES256-GCM-SHA384'
24+
ciphers: 'AES256-GCM-SHA384',
25+
maxVersion: 'TLSv1.2',
2526
};
2627

2728
const server = tls.createServer(options, onConnection);

lib/internal/tls/secure-context.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,10 @@ function configSecureContext(context, options = kEmptyObject, name = 'options')
225225
cipherSuites,
226226
} = processCiphers(ciphers, `${name}.ciphers`);
227227

228-
context.setCipherSuites(cipherSuites);
228+
if (cipherSuites !== '')
229+
context.setCipherSuites(cipherSuites);
229230
context.setCiphers(cipherList);
230231

231-
if (cipherSuites === '' &&
232-
context.getMaxProto() > TLS1_2_VERSION &&
233-
context.getMinProto() < TLS1_3_VERSION) {
234-
context.setMaxProto(TLS1_2_VERSION);
235-
}
236-
237232
if (cipherList === '' &&
238233
context.getMinProto() < TLS1_3_VERSION &&
239234
context.getMaxProto() > TLS1_2_VERSION) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function test(size, type, name, cipher) {
2323
const options = {
2424
key: key,
2525
cert: cert,
26-
ciphers: cipher
26+
ciphers: cipher,
27+
maxVersion: 'TLSv1.2',
2728
};
2829

2930
if (name) options.ecdhCurve = name;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ function test(size, err, next) {
4141
const client = tls.connect({
4242
minDHSize: 2048,
4343
port: this.address().port,
44-
rejectUnauthorized: false
44+
rejectUnauthorized: false,
45+
maxVersion: 'TLSv1.2',
4546
}, function() {
4647
nsuccess++;
4748
server.close();

test/parallel/test-tls-dhe.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ function test(keylen, expectedCipher, cb) {
5353
key: key,
5454
cert: cert,
5555
ciphers: ciphers,
56-
dhparam: loadDHParam(keylen)
56+
dhparam: loadDHParam(keylen),
57+
maxVersion: 'TLSv1.2',
5758
};
5859

5960
const server = tls.createServer(options, function(conn) {

test/parallel/test-tls-ecdh-auto.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const options = {
2323
key: loadPEM('agent2-key'),
2424
cert: loadPEM('agent2-cert'),
2525
ciphers: '-ALL:ECDHE-RSA-AES128-SHA256',
26-
ecdhCurve: 'auto'
26+
ecdhCurve: 'auto',
27+
maxVersion: 'TLSv1.2',
2728
};
2829

2930
const reply = 'I AM THE WALRUS'; // Something recognizable

test/parallel/test-tls-ecdh-multiple.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const options = {
2323
key: loadPEM('agent2-key'),
2424
cert: loadPEM('agent2-cert'),
2525
ciphers: '-ALL:ECDHE-RSA-AES128-SHA256',
26-
ecdhCurve: 'secp256k1:prime256v1:secp521r1'
26+
ecdhCurve: 'secp256k1:prime256v1:secp521r1',
27+
maxVersion: 'TLSv1.2',
2728
};
2829

2930
const reply = 'I AM THE WALRUS'; // Something recognizable

0 commit comments

Comments
 (0)