summaryrefslogtreecommitdiff
path: root/src/node_crypto.cc
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2018-11-20 15:30:34 -0800
committerDaniel Bevenius <daniel.bevenius@gmail.com>2018-12-03 07:38:59 +0100
commitb05b330025b9d69baa82812774be92b1be4a318c (patch)
treece4ef87bdfe790c6af54f81d545865bd4265b3e0 /src/node_crypto.cc
parent3513b0c3d9711e5eee47ef15b7913f0ce4483663 (diff)
downloadnode-new-b05b330025b9d69baa82812774be92b1be4a318c.tar.gz
tls: add code for ERR_TLS_INVALID_PROTOCOL_METHOD
Add an error code property to invalid `secureProtocol` method exceptions. PR-URL: https://github.com/nodejs/node/pull/24729 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_crypto.cc')
-rw-r--r--src/node_crypto.cc23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/node_crypto.cc b/src/node_crypto.cc
index f2223a324b..4e1a3f9405 100644
--- a/src/node_crypto.cc
+++ b/src/node_crypto.cc
@@ -63,6 +63,8 @@ v8::MaybeLocal<v8::Object> New(Environment* env, unsigned char* udata,
namespace crypto {
+using node::THROW_ERR_TLS_INVALID_PROTOCOL_METHOD;
+
using v8::Array;
using v8::Boolean;
using v8::ConstructorBehavior;
@@ -421,17 +423,23 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
// protocols are supported unless explicitly disabled (which we do below
// for SSLv2 and SSLv3.)
if (strcmp(*sslmethod, "SSLv2_method") == 0) {
- return env->ThrowError("SSLv2 methods disabled");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "SSLv2 methods disabled");
+ return;
} else if (strcmp(*sslmethod, "SSLv2_server_method") == 0) {
- return env->ThrowError("SSLv2 methods disabled");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "SSLv2 methods disabled");
+ return;
} else if (strcmp(*sslmethod, "SSLv2_client_method") == 0) {
- return env->ThrowError("SSLv2 methods disabled");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "SSLv2 methods disabled");
+ return;
} else if (strcmp(*sslmethod, "SSLv3_method") == 0) {
- return env->ThrowError("SSLv3 methods disabled");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "SSLv3 methods disabled");
+ return;
} else if (strcmp(*sslmethod, "SSLv3_server_method") == 0) {
- return env->ThrowError("SSLv3 methods disabled");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "SSLv3 methods disabled");
+ return;
} else if (strcmp(*sslmethod, "SSLv3_client_method") == 0) {
- return env->ThrowError("SSLv3 methods disabled");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "SSLv3 methods disabled");
+ return;
} else if (strcmp(*sslmethod, "SSLv23_method") == 0) {
// noop
} else if (strcmp(*sslmethod, "SSLv23_server_method") == 0) {
@@ -483,7 +491,8 @@ void SecureContext::Init(const FunctionCallbackInfo<Value>& args) {
max_version = TLS1_2_VERSION;
method = TLS_client_method();
} else {
- return env->ThrowError("Unknown method");
+ THROW_ERR_TLS_INVALID_PROTOCOL_METHOD(env, "Unknown method");
+ return;
}
}