◐ Shell
clean mode source ↗

test: use an always invalid cipher and cover OpenSSL 4.0 behaviours · nodejs/node@698d828

Original file line numberDiff line numberDiff line change

@@ -7,12 +7,13 @@ if (!common.hasCrypto)

77

const assert = require('assert');

88

const tls = require('tls');

99

const fixtures = require('../common/fixtures');

10+

const { hasOpenSSL } = require('../common/crypto');

1011
1112

{

1213

const options = {

1314

key: fixtures.readKey('agent2-key.pem'),

1415

cert: fixtures.readKey('agent2-cert.pem'),

15-

ciphers: 'aes256-sha'

16+

ciphers: 'DES-CBC-SHA'

1617

};

1718

assert.throws(() => tls.createServer(options, common.mustNotCall()),

1819

/no[_ ]cipher[_ ]match/i);

@@ -23,3 +24,19 @@ const fixtures = require('../common/fixtures');

2324

assert.throws(() => tls.createServer(options, common.mustNotCall()),

2425

/no[_ ]cipher[_ ]match/i);

2526

}

27+
28+

// Cipher name matching is case-sensitive prior to OpenSSL 4.0, and

29+

// case-insensitive starting with OpenSSL 4.0.

30+

{

31+

const options = {

32+

key: fixtures.readKey('agent2-key.pem'),

33+

cert: fixtures.readKey('agent2-cert.pem'),

34+

ciphers: 'aes256-sha',

35+

};

36+

if (hasOpenSSL(4, 0)) {

37+

tls.createServer(options).close();

38+

} else {

39+

assert.throws(() => tls.createServer(options, common.mustNotCall()),

40+

/no[_ ]cipher[_ ]match/i);

41+

}

42+

}