From 698d8287d138f54e7081857c8b28811092c8aafe Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 18 Apr 2026 13:12:14 +0200 Subject: [PATCH] test: use an always invalid cipher and cover OpenSSL 4.0 behaviours Signed-off-by: Filip Skokan PR-URL: https://github.com/nodejs/node/pull/62805 Reviewed-By: Luigi Pinca Reviewed-By: Antoine du Hamel --- test/parallel/test-tls-set-ciphers-error.js | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-tls-set-ciphers-error.js b/test/parallel/test-tls-set-ciphers-error.js index 0df5a9288de..3cfc8c391bf 100644 --- a/test/parallel/test-tls-set-ciphers-error.js +++ b/test/parallel/test-tls-set-ciphers-error.js @@ -7,12 +7,13 @@ if (!common.hasCrypto) const assert = require('assert'); const tls = require('tls'); const fixtures = require('../common/fixtures'); +const { hasOpenSSL } = require('../common/crypto'); { const options = { key: fixtures.readKey('agent2-key.pem'), cert: fixtures.readKey('agent2-cert.pem'), - ciphers: 'aes256-sha' + ciphers: 'DES-CBC-SHA' }; assert.throws(() => tls.createServer(options, common.mustNotCall()), /no[_ ]cipher[_ ]match/i); @@ -23,3 +24,19 @@ const fixtures = require('../common/fixtures'); assert.throws(() => tls.createServer(options, common.mustNotCall()), /no[_ ]cipher[_ ]match/i); } + +// Cipher name matching is case-sensitive prior to OpenSSL 4.0, and +// case-insensitive starting with OpenSSL 4.0. +{ + const options = { + key: fixtures.readKey('agent2-key.pem'), + cert: fixtures.readKey('agent2-cert.pem'), + ciphers: 'aes256-sha', + }; + if (hasOpenSSL(4, 0)) { + tls.createServer(options).close(); + } else { + assert.throws(() => tls.createServer(options, common.mustNotCall()), + /no[_ ]cipher[_ ]match/i); + } +}