summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2018-01-11 03:33:49 +0800
committerJoyee Cheung <joyeec9h3@gmail.com>2018-01-17 02:20:36 +0800
commit1c29da8236f0017fa3a09eaeba3c48309d08375b (patch)
tree5d744a2e22776344b1b140ec2ae6a62e8b12ecba /src
parent9ffebeab48e2e0b61dc0817430f089b6a1482ea7 (diff)
downloadandroid-node-v8-1c29da8236f0017fa3a09eaeba3c48309d08375b.tar.gz
android-node-v8-1c29da8236f0017fa3a09eaeba3c48309d08375b.tar.bz2
android-node-v8-1c29da8236f0017fa3a09eaeba3c48309d08375b.zip
tls: migrate C++ errors to internal/errors.js
* Throw ERR_TLS_SNI_FROM_SERVER when setting server names on a server-side socket instead of returning silently * Assert on wrap_->started and wrap_->ssl instead of throwing errors since these errors indicate that the user either uses private APIs, or monkey-patches internals, or hits a bug. PR-URL: https://github.com/nodejs/node/pull/18125 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/tls_wrap.cc25
1 files changed, 6 insertions, 19 deletions
diff --git a/src/tls_wrap.cc b/src/tls_wrap.cc
index e505032345..18b3cf01f4 100644
--- a/src/tls_wrap.cc
+++ b/src/tls_wrap.cc
@@ -225,13 +225,11 @@ void TLSWrap::Receive(const FunctionCallbackInfo<Value>& args) {
void TLSWrap::Start(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args);
-
TLSWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
- if (wrap->started_)
- return env->ThrowError("Already started.");
+ CHECK(!wrap->started_);
+
wrap->started_ = true;
// Send ClientHello handshake
@@ -747,17 +745,13 @@ int TLSWrap::DoShutdown(ShutdownWrap* req_wrap) {
void TLSWrap::SetVerifyMode(const FunctionCallbackInfo<Value>& args) {
- Environment* env = Environment::GetCurrent(args);
-
TLSWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
CHECK_EQ(args.Length(), 2);
CHECK(args[0]->IsBoolean());
CHECK(args[1]->IsBoolean());
-
- if (wrap->ssl_ == nullptr)
- return env->ThrowTypeError("SetVerifyMode after destroySSL");
+ CHECK_NE(wrap->ssl_, nullptr);
int verify_mode;
if (wrap->is_server()) {
@@ -785,10 +779,7 @@ void TLSWrap::EnableSessionCallbacks(
const FunctionCallbackInfo<Value>& args) {
TLSWrap* wrap;
ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder());
- if (wrap->ssl_ == nullptr) {
- return wrap->env()->ThrowTypeError(
- "EnableSessionCallbacks after destroySSL");
- }
+ CHECK_NE(wrap->ssl_, nullptr);
wrap->enable_session_callbacks();
crypto::NodeBIO::FromBIO(wrap->enc_in_)->set_initial(kMaxHelloLength);
wrap->hello_parser_.Start(SSLWrap<TLSWrap>::OnClientHello,
@@ -852,12 +843,8 @@ void TLSWrap::SetServername(const FunctionCallbackInfo<Value>& args) {
CHECK_EQ(args.Length(), 1);
CHECK(args[0]->IsString());
-
- if (wrap->started_)
- return env->ThrowError("Already started.");
-
- if (!wrap->is_client())
- return;
+ CHECK(!wrap->started_);
+ CHECK(wrap->is_client());
CHECK_NE(wrap->ssl_, nullptr);