Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8d66fc4

Browse files
committedSep 30, 2023
tls: ciphers allow bang syntax
Fixes: #49699
1 parent 6c9625d commit 8d66fc4

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
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

+1
Original file line numberDiff line numberDiff line change
@@ -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)
Please sign in to comment.