mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 21:19:50 +01:00
86b4f3729a
When an invalid TLS method name error is thrown, include the invalid name in the error message. PR-URL: https://github.com/nodejs/node/pull/27390 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: James M Snell <jasnell@gmail.com>
59 lines
2.1 KiB
JavaScript
59 lines
2.1 KiB
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
const tls = require('tls');
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'blargh' });
|
|
}, {
|
|
code: 'ERR_TLS_INVALID_PROTOCOL_METHOD',
|
|
message: 'Unknown method: blargh',
|
|
});
|
|
|
|
const errMessageSSLv2 = /SSLv2 methods disabled/;
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'SSLv2_method' });
|
|
}, errMessageSSLv2);
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'SSLv2_client_method' });
|
|
}, errMessageSSLv2);
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'SSLv2_server_method' });
|
|
}, errMessageSSLv2);
|
|
|
|
const errMessageSSLv3 = /SSLv3 methods disabled/;
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'SSLv3_method' });
|
|
}, errMessageSSLv3);
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'SSLv3_client_method' });
|
|
}, errMessageSSLv3);
|
|
|
|
assert.throws(function() {
|
|
tls.createSecureContext({ secureProtocol: 'SSLv3_server_method' });
|
|
}, errMessageSSLv3);
|
|
|
|
// Note that SSLv2 and SSLv3 are disallowed but SSLv2_method and friends are
|
|
// still accepted. They are OpenSSL's way of saying that all known protocols
|
|
// are supported unless explicitly disabled (which we do for SSLv2 and SSLv3.)
|
|
tls.createSecureContext({ secureProtocol: 'SSLv23_method' });
|
|
tls.createSecureContext({ secureProtocol: 'SSLv23_client_method' });
|
|
tls.createSecureContext({ secureProtocol: 'SSLv23_server_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_client_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_server_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_1_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_1_client_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_1_server_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_2_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_2_client_method' });
|
|
tls.createSecureContext({ secureProtocol: 'TLSv1_2_server_method' });
|