| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 62ad1d0 commit 5029f41
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,6 +131,7 @@ namespace node { | |||
| 131 | 131 | V(netmask_string, "netmask") \ | |
| 132 | 132 | V(nice_string, "nice") \ | |
| 133 | 133 | V(nlink_string, "nlink") \ | |
| 134 | + V(npn_buffer_string, "npnBuffer") \ | ||
| 134 | 135 | V(nsname_string, "nsname") \ | |
| 135 | 136 | V(ocsp_request_string, "OCSPRequest") \ | |
| 136 | 137 | V(offset_string, "offset") \ | |
@@ -181,6 +182,7 @@ namespace node { | |||
| 181 | 182 | V(serial_string, "serial") \ | |
| 182 | 183 | V(scavenge_string, "scavenge") \ | |
| 183 | 184 | V(scopeid_string, "scopeid") \ | |
| 185 | + V(selected_npn_buffer_string, "selectedNpnBuffer") \ | ||
| 184 | 186 | V(sent_shutdown_string, "sentShutdown") \ | |
| 185 | 187 | V(serial_number_string, "serialNumber") \ | |
| 186 | 188 | V(service_string, "service") \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1917,14 +1917,17 @@ int SSLWrap<Base>::AdvertiseNextProtoCallback(SSL* s, | |||
| 1917 | 1917 | HandleScope handle_scope(env->isolate()); | |
| 1918 | 1918 | Context::Scope context_scope(env->context()); | |
| 1919 | 1919 | ||
| 1920 | - if (w->npn_protos_.IsEmpty()) { | ||
| 1920 | + Local<Value> npn_buffer = | ||
| 1921 | + w->object()->GetHiddenValue(env->npn_buffer_string()); | ||
| 1922 | + | ||
| 1923 | + if (npn_buffer.IsEmpty()) { | ||
| 1921 | 1924 | // No initialization - no NPN protocols | |
| 1922 | 1925 | *data = reinterpret_cast<const unsigned char*>(""); | |
| 1923 | 1926 | *len = 0; | |
| 1924 | 1927 | } else { | |
| 1925 | - Local<Object> obj = PersistentToLocal(env->isolate(), w->npn_protos_); | ||
| 1926 | - *data = reinterpret_cast<const unsigned char*>(Buffer::Data(obj)); | ||
| 1927 | - *len = Buffer::Length(obj); | ||
| 1928 | + CHECK(Buffer::HasInstance(npn_buffer)); | ||
| 1929 | + *data = reinterpret_cast<const unsigned char*>(Buffer::Data(npn_buffer)); | ||
| 1930 | + *len = Buffer::Length(npn_buffer); | ||
| 1928 | 1931 | } | |
| 1929 | 1932 | ||
| 1930 | 1933 | return SSL_TLSEXT_ERR_OK; | |
@@ -1943,25 +1946,27 @@ int SSLWrap<Base>::SelectNextProtoCallback(SSL* s, | |||
| 1943 | 1946 | HandleScope handle_scope(env->isolate()); | |
| 1944 | 1947 | Context::Scope context_scope(env->context()); | |
| 1945 | 1948 | ||
| 1946 | - // Release old protocol handler if present | ||
| 1947 | - w->selected_npn_proto_.Reset(); | ||
| 1949 | + Local<Value> npn_buffer = | ||
| 1950 | + w->object()->GetHiddenValue(env->npn_buffer_string()); | ||
| 1948 | 1951 | ||
| 1949 | - if (w->npn_protos_.IsEmpty()) { | ||
| 1952 | + if (npn_buffer.IsEmpty()) { | ||
| 1950 | 1953 | // We should at least select one protocol | |
| 1951 | 1954 | // If server is using NPN | |
| 1952 | 1955 | *out = reinterpret_cast<unsigned char*>(const_cast<char*>("http/1.1")); | |
| 1953 | 1956 | *outlen = 8; | |
| 1954 | 1957 | ||
| 1955 | 1958 | // set status: unsupported | |
| 1956 | - w->selected_npn_proto_.Reset(env->isolate(), False(env->isolate())); | ||
| 1959 | + bool r = w->object()->SetHiddenValue(env->selected_npn_buffer_string(), | ||
| 1960 | + False(env->isolate())); | ||
| 1961 | + CHECK(r); | ||
| 1957 | 1962 | ||
| 1958 | 1963 | return SSL_TLSEXT_ERR_OK; | |
| 1959 | 1964 | } | |
| 1960 | 1965 | ||
| 1961 | - Local<Object> obj = PersistentToLocal(env->isolate(), w->npn_protos_); | ||
| 1966 | + CHECK(Buffer::HasInstance(npn_buffer)); | ||
| 1962 | 1967 | const unsigned char* npn_protos = | |
| 1963 | - reinterpret_cast<const unsigned char*>(Buffer::Data(obj)); | ||
| 1964 | - size_t len = Buffer::Length(obj); | ||
| 1968 | + reinterpret_cast<const unsigned char*>(Buffer::Data(npn_buffer)); | ||
| 1969 | + size_t len = Buffer::Length(npn_buffer); | ||
| 1965 | 1970 | ||
| 1966 | 1971 | int status = SSL_select_next_proto(out, outlen, in, inlen, npn_protos, len); | |
| 1967 | 1972 | Local<Value> result; | |
@@ -1979,8 +1984,9 @@ int SSLWrap<Base>::SelectNextProtoCallback(SSL* s, | |||
| 1979 | 1984 | break; | |
| 1980 | 1985 | } | |
| 1981 | 1986 | ||
| 1982 | - if (!result.IsEmpty()) | ||
| 1983 | - w->selected_npn_proto_.Reset(env->isolate(), result); | ||
| 1987 | + bool r = w->object()->SetHiddenValue(env->selected_npn_buffer_string(), | ||
| 1988 | + result); | ||
| 1989 | + CHECK(r); | ||
| 1984 | 1990 | ||
| 1985 | 1991 | return SSL_TLSEXT_ERR_OK; | |
| 1986 | 1992 | } | |
@@ -1992,9 +1998,12 @@ void SSLWrap<Base>::GetNegotiatedProto( | |||
| 1992 | 1998 | Base* w = Unwrap<Base>(args.Holder()); | |
| 1993 | 1999 | ||
| 1994 | 2000 | if (w->is_client()) { | |
| 1995 | - if (w->selected_npn_proto_.IsEmpty() == false) { | ||
| 1996 | - args.GetReturnValue().Set(w->selected_npn_proto_); | ||
| 1997 | - } | ||
| 2001 | + Local<Value> selected_npn_buffer = | ||
| 2002 | + w->object()->GetHiddenValue(w->env()->selected_npn_buffer_string()); | ||
| 2003 | + | ||
| 2004 | + if (selected_npn_buffer.IsEmpty() == false) | ||
| 2005 | + args.GetReturnValue().Set(selected_npn_buffer); | ||
| 2006 | + | ||
| 1998 | 2007 | return; | |
| 1999 | 2008 | } | |
| 2000 | 2009 | ||
@@ -2014,11 +2023,14 @@ void SSLWrap<Base>::GetNegotiatedProto( | |||
| 2014 | 2023 | template <class Base> | |
| 2015 | 2024 | void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) { | |
| 2016 | 2025 | Base* w = Unwrap<Base>(args.Holder()); | |
| 2026 | + Environment* env = w->env(); | ||
| 2017 | 2027 | ||
| 2018 | 2028 | if (args.Length() < 1 || !Buffer::HasInstance(args[0])) | |
| 2019 | - return w->env()->ThrowTypeError("Must give a Buffer as first argument"); | ||
| 2029 | + return env->ThrowTypeError("Must give a Buffer as first argument"); | ||
| 2020 | 2030 | ||
| 2021 | - w->npn_protos_.Reset(args.GetIsolate(), args[0].As<Object>()); | ||
| 2031 | + Local<Value> npn_buffer = Local<Value>::New(env->isolate(), args[0]); | ||
| 2032 | + bool r = w->object()->SetHiddenValue(env->npn_buffer_string(), npn_buffer); | ||
| 2033 | + CHECK(r); | ||
| 2022 | 2034 | } | |
| 2023 | 2035 | #endif // OPENSSL_NPN_NEGOTIATED | |
| 2024 | 2036 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -178,10 +178,6 @@ class SSLWrap { | |||
| 178 | 178 | next_sess_ = nullptr; | |
| 179 | 179 | } | |
| 180 | 180 | ||
| 181 | - #ifdef OPENSSL_NPN_NEGOTIATED | ||
| 182 | - npn_protos_.Reset(); | ||
| 183 | - selected_npn_proto_.Reset(); | ||
| 184 | - #endif | ||
| 185 | 181 | #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | |
| 186 | 182 | sni_context_.Reset(); | |
| 187 | 183 | #endif | |
@@ -298,11 +294,6 @@ class SSLWrap { | |||
| 298 | 294 | v8::Persistent<v8::Object> ocsp_response_; | |
| 299 | 295 | #endif // NODE__HAVE_TLSEXT_STATUS_CB | |
| 300 | 296 | ||
| 301 | - #ifdef OPENSSL_NPN_NEGOTIATED | ||
| 302 | - v8::Persistent<v8::Object> npn_protos_; | ||
| 303 | - v8::Persistent<v8::Value> selected_npn_proto_; | ||
| 304 | - #endif // OPENSSL_NPN_NEGOTIATED | ||
| 305 | - | ||
| 306 | 297 | #ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | |
| 307 | 298 | v8::Persistent<v8::Value> sni_context_; | |
| 308 | 299 | #endif | |
| Back | FazBrowse Home | New Git URL |
0 commit comments