Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/js/node/tls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,19 @@ function Server(options, secureConnectionListener): void {
if (typeof rejectUnauthorized !== "undefined") {
this._rejectUnauthorized = rejectUnauthorized;
} else this._rejectUnauthorized = rejectUnauthorizedDefault;

if (typeof options.ciphers !== "undefined") {
if (typeof options.ciphers !== "string") {
throw $ERR_INVALID_ARG_TYPE("options.ciphers", "string", options.ciphers);
}
const supported = getCiphers();
const requested = options.ciphers.split(":");
const foundMatch = requested.some(r => supported.some(s => s.toLowerCase() === r.toLowerCase()));
if (!foundMatch) {
throw new Error("no cipher match");
}
this.ciphers = options.ciphers;
}
}
};

Expand Down
25 changes: 25 additions & 0 deletions test/js/node/test/parallel/test-tls-set-ciphers-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';
const common = require('../common');

if (!common.hasCrypto)
common.skip('missing crypto');

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

{
const options = {
key: fixtures.readKey('agent2-key.pem'),
cert: fixtures.readKey('agent2-cert.pem'),
ciphers: 'aes256-sha'
};
assert.throws(() => tls.createServer(options, common.mustNotCall()),
/no[_ ]cipher[_ ]match/i);
options.ciphers = 'FOOBARBAZ';
assert.throws(() => tls.createServer(options, common.mustNotCall()),
/no[_ ]cipher[_ ]match/i);
options.ciphers = 'TLS_not_a_cipher';
assert.throws(() => tls.createServer(options, common.mustNotCall()),
/no[_ ]cipher[_ ]match/i);
}