GeezerVison is showing github.com — lib,src: remove openssl feature conditionals · nodejs/node@a657984
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/_tls_wrap.js +4-11Lines changed: 4 additions & 11 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -512,8 +512,7 @@ TLSSocket.prototype._init = function(socket, wrap) { | 512 | 512 | // If custom SNICallback was given, or if | 513 | 513 | // there're SNI contexts to perform match against - | 514 | 514 | // set `.onsniselect` callback. | 515 | | - if (process.features.tls_sni && | 516 | | - options.isServer && | | 515 | + if (options.isServer && | 517 | 516 | options.SNICallback && | 518 | 517 | (options.SNICallback !== SNICallback || | 519 | 518 | (options.server && options.server._contexts.length))) { | @@ -522,7 +521,7 @@ TLSSocket.prototype._init = function(socket, wrap) { | 522 | 521 | ssl.enableCertCb(); | 523 | 522 | } | 524 | 523 |
| 525 | | - if (process.features.tls_alpn && options.ALPNProtocols) { | | 524 | + if (options.ALPNProtocols) { | 526 | 525 | // keep reference in secureContext not to be GC-ed | 527 | 526 | ssl._secureContext.alpnBuffer = options.ALPNProtocols; | 528 | 527 | ssl.setALPNProtocols(ssl._secureContext.alpnBuffer); | @@ -620,15 +619,9 @@ TLSSocket.prototype._releaseControl = function() { | 620 | 619 | }; | 621 | 620 |
| 622 | 621 | TLSSocket.prototype._finishInit = function() { | 623 | | - if (process.features.tls_alpn) { | 624 | | - this.alpnProtocol = this._handle.getALPNNegotiatedProtocol(); | 625 | | - } | 626 | | - | 627 | | - if (process.features.tls_sni) { | 628 | | - this.servername = this._handle.getServername(); | 629 | | - } | 630 | | - | 631 | 622 | debug('secure established'); | | 623 | + this.alpnProtocol = this._handle.getALPNNegotiatedProtocol(); | | 624 | + this.servername = this._handle.getServername(); | 632 | 625 | this._secureEstablished = true; | 633 | 626 | if (this._tlsOptions.handshakeTimeout > 0) | 634 | 627 | this.setTimeout(0, this._handleTimeout); | |
Collapse file Copy file name to clipboardExpand all lines: lib/https.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -49,7 +49,7 @@ function Server(opts, requestListener) { | 49 | 49 | } | 50 | 50 | opts = util._extend({}, opts); | 51 | 51 |
| 52 | | - if (process.features.tls_alpn && !opts.ALPNProtocols) { | | 52 | + if (!opts.ALPNProtocols) { | 53 | 53 | // http/1.0 is not defined as Protocol IDs in IANA | 54 | 54 | // http://www.iana.org/assignments/tls-extensiontype-values | 55 | 55 | // /tls-extensiontype-values.xhtml#alpn-protocol-ids | |
Collapse file Copy file name to clipboardExpand all lines: src/node.cc +7-21Lines changed: 7 additions & 21 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2383,30 +2383,16 @@ static Local<Object> GetFeatures(Environment* env) { | 2383 | 2383 | // TODO(bnoordhuis) ping libuv | 2384 | 2384 | obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), True(env->isolate())); | 2385 | 2385 |
| 2386 | | -#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation | 2387 | | - Local<Boolean> tls_alpn = True(env->isolate()); | | 2386 | +#ifdef HAVE_OPENSSL | | 2387 | + Local<Boolean> have_openssl = True(env->isolate()); | 2388 | 2388 | #else | 2389 | | - Local<Boolean> tls_alpn = False(env->isolate()); | | 2389 | + Local<Boolean> have_openssl = False(env->isolate()); | 2390 | 2390 | #endif | 2391 | | - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"), tls_alpn); | 2392 | 2391 |
| 2393 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 2394 | | - Local<Boolean> tls_sni = True(env->isolate()); | 2395 | | -#else | 2396 | | - Local<Boolean> tls_sni = False(env->isolate()); | 2397 | | -#endif | 2398 | | - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"), tls_sni); | 2399 | | - | 2400 | | -#if !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb) | 2401 | | - Local<Boolean> tls_ocsp = True(env->isolate()); | 2402 | | -#else | 2403 | | - Local<Boolean> tls_ocsp = False(env->isolate()); | 2404 | | -#endif // !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb) | 2405 | | - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"), tls_ocsp); | 2406 | | - | 2407 | | - obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls"), | 2408 | | - Boolean::New(env->isolate(), | 2409 | | - get_builtin_module("crypto") != nullptr)); | | 2392 | + obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_alpn"), have_openssl); | | 2393 | + obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_sni"), have_openssl); | | 2394 | + obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls_ocsp"), have_openssl); | | 2395 | + obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "tls"), have_openssl); | 2410 | 2396 |
| 2411 | 2397 | return scope.Escape(obj); | 2412 | 2398 | } | |
Collapse file Copy file name to clipboardExpand all lines: src/node_crypto.cc +1-26Lines changed: 1 addition & 26 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -133,24 +133,17 @@ template int SSLWrap<TLSWrap>::NewSessionCallback(SSL* s, | 133 | 133 | template void SSLWrap<TLSWrap>::OnClientHello( | 134 | 134 | void* arg, | 135 | 135 | const ClientHelloParser::ClientHello& hello); | 136 | | - | 137 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 138 | 136 | template int SSLWrap<TLSWrap>::TLSExtStatusCallback(SSL* s, void* arg); | 139 | | -#endif | 140 | | - | 141 | 137 | template void SSLWrap<TLSWrap>::DestroySSL(); | 142 | 138 | template int SSLWrap<TLSWrap>::SSLCertCallback(SSL* s, void* arg); | 143 | 139 | template void SSLWrap<TLSWrap>::WaitForCertCb(CertCb cb, void* arg); | 144 | | - | 145 | | -#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation | 146 | 140 | template int SSLWrap<TLSWrap>::SelectALPNCallback( | 147 | 141 | SSL* s, | 148 | 142 | const unsigned char** out, | 149 | 143 | unsigned char* outlen, | 150 | 144 | const unsigned char* in, | 151 | 145 | unsigned int inlen, | 152 | 146 | void* arg); | 153 | | -#endif // TLSEXT_TYPE_application_layer_protocol_negotiation | 154 | 147 |
| 155 | 148 |
| 156 | 149 | static int PasswordCallback(char* buf, int size, int rwflag, void* u) { | @@ -1387,11 +1380,9 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) { | 1387 | 1380 |
| 1388 | 1381 | template <class Base> | 1389 | 1382 | void SSLWrap<Base>::ConfigureSecureContext(SecureContext* sc) { | 1390 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 1391 | 1383 | // OCSP stapling | 1392 | 1384 | SSL_CTX_set_tlsext_status_cb(sc->ctx_.get(), TLSExtStatusCallback); | 1393 | 1385 | SSL_CTX_set_tlsext_status_arg(sc->ctx_.get(), nullptr); | 1394 | | -#endif // NODE__HAVE_TLSEXT_STATUS_CB | 1395 | 1386 | } | 1396 | 1387 |
| 1397 | 1388 |
| @@ -2019,7 +2010,6 @@ void SSLWrap<Base>::NewSessionDone(const FunctionCallbackInfo<Value>& args) { | 2019 | 2010 |
| 2020 | 2011 | template <class Base> | 2021 | 2012 | void SSLWrap<Base>::SetOCSPResponse(const FunctionCallbackInfo<Value>& args) { | 2022 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 2023 | 2013 | Base* w; | 2024 | 2014 | ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); | 2025 | 2015 | Environment* env = w->env(); | @@ -2030,18 +2020,15 @@ void SSLWrap<Base>::SetOCSPResponse(const FunctionCallbackInfo<Value>& args) { | 2030 | 2020 | THROW_AND_RETURN_IF_NOT_BUFFER(env, args[0], "OCSP response"); | 2031 | 2021 |
| 2032 | 2022 | w->ocsp_response_.Reset(args.GetIsolate(), args[0].As<Object>()); | 2033 | | -#endif // NODE__HAVE_TLSEXT_STATUS_CB | 2034 | 2023 | } | 2035 | 2024 |
| 2036 | 2025 |
| 2037 | 2026 | template <class Base> | 2038 | 2027 | void SSLWrap<Base>::RequestOCSP(const FunctionCallbackInfo<Value>& args) { | 2039 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 2040 | 2028 | Base* w; | 2041 | 2029 | ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); | 2042 | 2030 |
| 2043 | 2031 | SSL_set_tlsext_status_type(w->ssl_.get(), TLSEXT_STATUSTYPE_ocsp); | 2044 | | -#endif // NODE__HAVE_TLSEXT_STATUS_CB | 2045 | 2032 | } | 2046 | 2033 |
| 2047 | 2034 |
| @@ -2226,7 +2213,6 @@ void SSLWrap<Base>::GetProtocol(const FunctionCallbackInfo<Value>& args) { | 2226 | 2213 | } | 2227 | 2214 |
| 2228 | 2215 |
| 2229 | | -#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation | 2230 | 2216 | template <class Base> | 2231 | 2217 | int SSLWrap<Base>::SelectALPNCallback(SSL* s, | 2232 | 2218 | const unsigned char** out, | @@ -2256,13 +2242,11 @@ int SSLWrap<Base>::SelectALPNCallback(SSL* s, | 2256 | 2242 | return status == OPENSSL_NPN_NEGOTIATED ? SSL_TLSEXT_ERR_OK | 2257 | 2243 | : SSL_TLSEXT_ERR_NOACK; | 2258 | 2244 | } | 2259 | | -#endif // TLSEXT_TYPE_application_layer_protocol_negotiation | 2260 | 2245 |
| 2261 | 2246 |
| 2262 | 2247 | template <class Base> | 2263 | 2248 | void SSLWrap<Base>::GetALPNNegotiatedProto( | 2264 | 2249 | const FunctionCallbackInfo<Value>& args) { | 2265 | | -#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation | 2266 | 2250 | Base* w; | 2267 | 2251 | ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); | 2268 | 2252 |
| @@ -2276,13 +2260,11 @@ void SSLWrap<Base>::GetALPNNegotiatedProto( | 2276 | 2260 |
| 2277 | 2261 | args.GetReturnValue().Set( | 2278 | 2262 | OneByteString(args.GetIsolate(), alpn_proto, alpn_proto_len)); | 2279 | | -#endif // TLSEXT_TYPE_application_layer_protocol_negotiation | 2280 | 2263 | } | 2281 | 2264 |
| 2282 | 2265 |
| 2283 | 2266 | template <class Base> | 2284 | 2267 | void SSLWrap<Base>::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) { | 2285 | | -#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation | 2286 | 2268 | Base* w; | 2287 | 2269 | ASSIGN_OR_RETURN_UNWRAP(&w, args.Holder()); | 2288 | 2270 | Environment* env = w->env(); | @@ -2306,11 +2288,9 @@ void SSLWrap<Base>::SetALPNProtocols(const FunctionCallbackInfo<Value>& args) { | 2306 | 2288 | SelectALPNCallback, | 2307 | 2289 | nullptr); | 2308 | 2290 | } | 2309 | | -#endif // TLSEXT_TYPE_application_layer_protocol_negotiation | 2310 | 2291 | } | 2311 | 2292 |
| 2312 | 2293 |
| 2313 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 2314 | 2294 | template <class Base> | 2315 | 2295 | int SSLWrap<Base>::TLSExtStatusCallback(SSL* s, void* arg) { | 2316 | 2296 | Base* w = static_cast<Base*>(SSL_get_app_data(s)); | @@ -2354,7 +2334,6 @@ int SSLWrap<Base>::TLSExtStatusCallback(SSL* s, void* arg) { | 2354 | 2334 | return SSL_TLSEXT_ERR_OK; | 2355 | 2335 | } | 2356 | 2336 | } | 2357 | | -#endif // NODE__HAVE_TLSEXT_STATUS_CB | 2358 | 2337 |
| 2359 | 2338 |
| 2360 | 2339 | template <class Base> | @@ -2396,11 +2375,7 @@ int SSLWrap<Base>::SSLCertCallback(SSL* s, void* arg) { | 2396 | 2375 | info->Set(context, env->servername_string(), str).FromJust(); | 2397 | 2376 | } | 2398 | 2377 |
| 2399 | | - bool ocsp = false; | 2400 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 2401 | | - ocsp = SSL_get_tlsext_status_type(s) == TLSEXT_STATUSTYPE_ocsp; | 2402 | | -#endif | 2403 | | - | | 2378 | + const bool ocsp = (SSL_get_tlsext_status_type(s) == TLSEXT_STATUSTYPE_ocsp); | 2404 | 2379 | info->Set(context, env->ocsp_request_string(), | 2405 | 2380 | Boolean::New(env->isolate(), ocsp)).FromJust(); | 2406 | 2381 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/node_crypto.h -9Lines changed: 0 additions & 9 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 53 | 53 | #include <openssl/rand.h> | 54 | 54 | #include <openssl/pkcs12.h> | 55 | 55 |
| 56 | | -#if !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb) | 57 | | -# define NODE__HAVE_TLSEXT_STATUS_CB | 58 | | -#endif // !defined(OPENSSL_NO_TLSEXT) && defined(SSL_CTX_set_tlsext_status_cb) | 59 | | - | 60 | 56 | namespace node { | 61 | 57 | namespace crypto { | 62 | 58 |
| @@ -331,13 +327,8 @@ class SSLWrap { | 331 | 327 |
| 332 | 328 | ClientHelloParser hello_parser_; | 333 | 329 |
| 334 | | -#ifdef NODE__HAVE_TLSEXT_STATUS_CB | 335 | 330 | Persistent<v8::Object> ocsp_response_; | 336 | | -#endif // NODE__HAVE_TLSEXT_STATUS_CB | 337 | | - | 338 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 339 | 331 | Persistent<v8::Value> sni_context_; | 340 | | -#endif | 341 | 332 |
| 342 | 333 | friend class SecureContext; | 343 | 334 | }; | |
Collapse file Copy file name to clipboardExpand all lines: src/tls_wrap.cc -8Lines changed: 0 additions & 8 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -131,12 +131,10 @@ void TLSWrap::InitSSL() { | 131 | 131 | SSL_set_app_data(ssl_.get(), this); | 132 | 132 | SSL_set_info_callback(ssl_.get(), SSLInfoCallback); | 133 | 133 |
| 134 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 135 | 134 | if (is_server()) { | 136 | 135 | SSL_CTX_set_tlsext_servername_callback(sc_->ctx_.get(), | 137 | 136 | SelectSNIContextCallback); | 138 | 137 | } | 139 | | -#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 140 | 138 |
| 141 | 139 | ConfigureSecureContext(sc_); | 142 | 140 |
| @@ -779,7 +777,6 @@ void TLSWrap::OnClientHelloParseEnd(void* arg) { | 779 | 777 | } | 780 | 778 |
| 781 | 779 |
| 782 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 783 | 780 | void TLSWrap::GetServername(const FunctionCallbackInfo<Value>& args) { | 784 | 781 | Environment* env = Environment::GetCurrent(args); | 785 | 782 |
| @@ -811,10 +808,8 @@ void TLSWrap::SetServername(const FunctionCallbackInfo<Value>& args) { | 811 | 808 |
| 812 | 809 | CHECK_NOT_NULL(wrap->ssl_); | 813 | 810 |
| 814 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 815 | 811 | node::Utf8Value servername(env->isolate(), args[0].As<String>()); | 816 | 812 | SSL_set_tlsext_host_name(wrap->ssl_.get(), *servername); | 817 | | -#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 818 | 813 | } | 819 | 814 |
| 820 | 815 |
| @@ -853,7 +848,6 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) { | 853 | 848 | p->SetSNIContext(sc); | 854 | 849 | return SSL_TLSEXT_ERR_OK; | 855 | 850 | } | 856 | | -#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 857 | 851 |
| 858 | 852 |
| 859 | 853 | void TLSWrap::GetWriteQueueSize(const FunctionCallbackInfo<Value>& info) { | @@ -904,10 +898,8 @@ void TLSWrap::Initialize(Local<Object> target, | 904 | 898 | StreamBase::AddMethods<TLSWrap>(env, t, StreamBase::kFlagHasWritev); | 905 | 899 | SSLWrap<TLSWrap>::AddMethods(env, t); | 906 | 900 |
| 907 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 908 | 901 | env->SetProtoMethod(t, "getServername", GetServername); | 909 | 902 | env->SetProtoMethod(t, "setServername", SetServername); | 910 | | -#endif // SSL_CRT_SET_TLSEXT_SERVERNAME_CB | 911 | 903 |
| 912 | 904 | env->set_tls_wrap_constructor_function(t->GetFunction()); | 913 | 905 |
| |
Collapse file Copy file name to clipboardExpand all lines: src/tls_wrap.h -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -138,12 +138,9 @@ class TLSWrap : public AsyncWrap, | 138 | 138 | static void EnableCertCb( | 139 | 139 | const v8::FunctionCallbackInfo<v8::Value>& args); | 140 | 140 | static void DestroySSL(const v8::FunctionCallbackInfo<v8::Value>& args); | 141 | | - | 142 | | -#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 143 | 141 | static void GetServername(const v8::FunctionCallbackInfo<v8::Value>& args); | 144 | 142 | static void SetServername(const v8::FunctionCallbackInfo<v8::Value>& args); | 145 | 143 | static int SelectSNIContextCallback(SSL* s, int* ad, void* arg); | 146 | | -#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB | 147 | 144 |
| 148 | 145 | crypto::SecureContext* sc_; | 149 | 146 | BIO* enc_in_; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-tls-alpn-server-client.js -5Lines changed: 0 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,11 +4,6 @@ const common = require('../common'); | 4 | 4 | if (!common.hasCrypto) | 5 | 5 | common.skip('missing crypto'); | 6 | 6 |
| 7 | | -if (!process.features.tls_alpn) { | 8 | | - common.skip( | 9 | | - 'Skipping because node compiled without ALPN feature of OpenSSL.'); | 10 | | -} | 11 | | - | 12 | 7 | const assert = require('assert'); | 13 | 8 | const tls = require('tls'); | 14 | 9 | const fixtures = require('../common/fixtures'); | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-tls-empty-sni-context.js -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -4,9 +4,6 @@ const common = require('../common'); | 4 | 4 | if (!common.hasCrypto) | 5 | 5 | common.skip('missing crypto'); | 6 | 6 |
| 7 | | -if (!process.features.tls_sni) | 8 | | - common.skip('node compiled without OpenSSL or with old OpenSSL version.'); | 9 | | - | 10 | 7 | const assert = require('assert'); | 11 | 8 | const tls = require('tls'); | 12 | 9 |
| |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-tls-ocsp-callback.js -3Lines changed: 0 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 22 | 22 | 'use strict'; | 23 | 23 | const common = require('../common'); | 24 | 24 |
| 25 | | -if (!process.features.tls_ocsp) | 26 | | - common.skip('node compiled without OpenSSL or with old OpenSSL version.'); | 27 | | - | 28 | 25 | if (!common.opensslCli) | 29 | 26 | common.skip('node compiled without OpenSSL CLI.'); | 30 | 27 |
| |
|