Correct implementation: all 5 missing DHE ciphers are actually supported

After testing, discovered that BoringSSL supports ALL 5 ciphers mentioned
in the original issue:
- DHE-RSA-AES128-GCM-SHA256 ✓
- DHE-RSA-AES128-SHA256 ✓
- DHE-RSA-AES256-SHA384 ✓ (previously thought unsupported)
- ECDHE-RSA-AES256-SHA256 ✓ (previously thought unsupported)
- DHE-RSA-AES256-SHA256 ✓

This means Bun can now have perfect Node.js compatibility:
`crypto.constants.defaultCipherList === tls.DEFAULT_CIPHERS` returns true
after the assignment, just like in Node.js.

Updated:
- Removed unnecessary cipher filtering logic
- Added all 5 missing ciphers to default cipher list
- Updated tests to verify complete compatibility
- Corrected comments about BoringSSL support

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2025-08-15 07:30:30 +00:00
parent bec71edc52
commit 45dc0245f3
3 changed files with 16 additions and 23 deletions

View File

@@ -10,6 +10,8 @@
"ECDHE-RSA-AES128-SHA256:" \
"DHE-RSA-AES128-SHA256:" \
"ECDHE-RSA-AES256-SHA384:" \
"DHE-RSA-AES256-SHA384:" \
"ECDHE-RSA-AES256-SHA256:" \
"DHE-RSA-AES256-SHA256:" \
"HIGH:" \
"!aNULL:" \
@@ -23,9 +25,9 @@
"!CAMELLIA"
#endif
// BoringSSL supports some DHE ciphers but not all legacy ones
// BoringSSL supports all Node.js defaultCipherList ciphers except TLS 1.3 ones
// TLS 1.3 ciphers are handled separately in JavaScript (see getDefaultCiphers in tls.ts)
// See https://github.com/envoyproxy/envoy/issues/8848#issuecomment-548672667
// Node.js full list below
// In node.js they filter TLS_* ciphers and use SSL_CTX_set_cipher_list (TODO: Electron has a patch https://github.com/nodejs/node/issues/25890)
// if passed to SSL_CTX_set_cipher_list it will be filtered out and not used in BoringSSL
@@ -33,7 +35,7 @@
// "TLS_CHACHA20_POLY1305_SHA256:" \
// "TLS_AES_128_GCM_SHA256:" \
// Supported by BoringSSL:
// All of these are supported by BoringSSL and match Node.js defaultCipherList:
// "ECDHE-RSA-AES128-GCM-SHA256:" \
// "ECDHE-ECDSA-AES128-GCM-SHA256:" \
// "ECDHE-RSA-AES256-GCM-SHA384:" \
@@ -42,11 +44,9 @@
// "ECDHE-RSA-AES128-SHA256:" \
// "DHE-RSA-AES128-SHA256:" \
// "ECDHE-RSA-AES256-SHA384:" \
// "DHE-RSA-AES256-SHA256:" \
// Not supported by BoringSSL:
// "ECDHE-RSA-AES256-SHA256:" \
// "DHE-RSA-AES256-SHA384:" \
// "ECDHE-RSA-AES256-SHA256:" \
// "DHE-RSA-AES256-SHA256:" \
// Also present in Node.js and supported by BoringSSL:

View File

@@ -985,13 +985,10 @@ function tlsCipherFilter(a: string) {
}
function supportedCipherFilter(cipher: string) {
// Filter out TLS_ ciphers (handled separately) and ciphers not supported by BoringSSL
// Filter out TLS_ ciphers (handled separately by getDefaultCiphers)
if (cipher.startsWith("TLS_")) return false;
// These ciphers are in Node.js defaultCipherList but not supported by BoringSSL
if (cipher === "DHE-RSA-AES256-SHA384") return false;
if (cipher === "ECDHE-RSA-AES256-SHA256") return false;
// All other ciphers in Node.js defaultCipherList are supported by BoringSSL
return true;
}

View File

@@ -20,18 +20,12 @@ test("tls.DEFAULT_CIPHERS can be set to crypto.constants.defaultCipherList", ()
expect(typeof tls.DEFAULT_CIPHERS).toBe("string");
expect(tls.DEFAULT_CIPHERS.length).toBeGreaterThan(0);
// Should include the supported DHE ciphers that were missing before
// Should include all the DHE ciphers that were missing before
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES128-GCM-SHA256");
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES128-SHA256");
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES256-SHA256");
// The assignment succeeds, but unsupported ciphers should be filtered out
// This is tested by verifying the assignment doesn't throw and the result is sensible
const afterCiphers = tls.DEFAULT_CIPHERS.split(":");
// Should NOT contain the unsupported BoringSSL ciphers (correctly filtered out)
expect(afterCiphers.includes("DHE-RSA-AES256-SHA384")).toBe(false);
expect(afterCiphers.includes("ECDHE-RSA-AES256-SHA256")).toBe(false);
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES256-SHA384");
expect(tls.DEFAULT_CIPHERS).toContain("ECDHE-RSA-AES256-SHA256");
// Should still include standard ciphers
expect(tls.DEFAULT_CIPHERS).toContain("ECDHE-RSA-AES128-GCM-SHA256");
@@ -58,11 +52,13 @@ test("crypto.constants.defaultCipherList contains expected ciphers", () => {
);
});
test("tls.DEFAULT_CIPHERS includes supported ciphers by default", () => {
test("tls.DEFAULT_CIPHERS includes all previously missing ciphers by default", () => {
const tls = require("tls");
// Should include the newly added supported DHE ciphers
// Should include all 5 ciphers that were missing before the fix
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES128-GCM-SHA256");
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES128-SHA256");
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES256-SHA384");
expect(tls.DEFAULT_CIPHERS).toContain("ECDHE-RSA-AES256-SHA256");
expect(tls.DEFAULT_CIPHERS).toContain("DHE-RSA-AES256-SHA256");
});