Skip to content

Commit 52b5693

Browse files
atlowChemitargos
authored andcommitted
tls: ciphers allow bang syntax
Fixes: #49699 PR-URL: #49712 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent 88611d1 commit 52b5693

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/internal/tls/secure-context.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,21 @@ function processCiphers(ciphers, name) {
101101
ArrayPrototypeFilter(
102102
ciphers,
103103
(cipher) => {
104-
return cipher.length > 0 &&
105-
!StringPrototypeStartsWith(cipher, 'TLS_');
104+
if (cipher.length === 0) return false;
105+
if (StringPrototypeStartsWith(cipher, 'TLS_')) return false;
106+
if (StringPrototypeStartsWith(cipher, '!TLS_')) return false;
107+
return true;
106108
}), ':');
107109

108110
const cipherSuites =
109111
ArrayPrototypeJoin(
110112
ArrayPrototypeFilter(
111113
ciphers,
112114
(cipher) => {
113-
return cipher.length > 0 &&
114-
StringPrototypeStartsWith(cipher, 'TLS_');
115+
if (cipher.length === 0) return false;
116+
if (StringPrototypeStartsWith(cipher, 'TLS_')) return true;
117+
if (StringPrototypeStartsWith(cipher, '!TLS_')) return true;
118+
return false;
115119
}), ':');
116120

117121
// Specifying empty cipher suites for both TLS1.2 and TLS1.3 is invalid, its

test/parallel/test-tls-set-ciphers.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict';
22
const common = require('../common');
3-
if (!common.hasCrypto)
4-
common.skip('missing crypto');
3+
if (!common.hasOpenSSL3)
4+
common.skip('missing crypto, or OpenSSL version lower than 3');
55

66
const fixtures = require('../common/fixtures');
77
const { inspect } = require('util');
@@ -85,6 +85,7 @@ test('AES256-SHA', U, 'AES256-SHA');
8585

8686
test(U, 'TLS_AES_256_GCM_SHA384', 'TLS_AES_256_GCM_SHA384');
8787
test('TLS_AES_256_GCM_SHA384', U, 'TLS_AES_256_GCM_SHA384');
88+
test('TLS_AES_256_GCM_SHA384:!TLS_CHACHA20_POLY1305_SHA256', U, 'TLS_AES_256_GCM_SHA384');
8889

8990
// Do not have shared ciphers.
9091
test('TLS_AES_256_GCM_SHA384', 'TLS_CHACHA20_POLY1305_SHA256',

0 commit comments

Comments
 (0)