Skip to content

Commit b1ddf11

Browse files
shigekiMylesBorins
authored andcommitted
tls: fix macro to check NPN feature
In order to check if NPN feature is enabled, use `#ifndef OPENSSL_NO_NEXTPROTONEG` rather than `#ifdef OPENSSL_NPN_NEGOTIATED` because the former is used in ssl.h. Fixes: #11650 PR-URL: #11655 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Fedor Indutny <fedor@indutny.com>
1 parent 3e6d992 commit b1ddf11

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/node.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2925,7 +2925,7 @@ static Local<Object> GetFeatures(Environment* env) {
29252925
// TODO(bnoordhuis) ping libuv
29262926
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), True(env->isolate()));
29272927

2928-
#ifdef OPENSSL_NPN_NEGOTIATED
2928+
#ifndef OPENSSL_NO_NEXTPROTONEG
29292929
Local<Boolean> tls_npn = True(env->isolate());
29302930
#else
29312931
Local<Boolean> tls_npn = False(env->isolate());

src/node_constants.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ void DefineOpenSSLConstants(Local<Object> target) {
940940
NODE_DEFINE_CONSTANT(target, DH_NOT_SUITABLE_GENERATOR);
941941
#endif
942942

943-
#ifdef OPENSSL_NPN_NEGOTIATED
943+
#ifndef OPENSSL_NO_NEXTPROTONEG
944944
#define NPN_ENABLED 1
945945
NODE_DEFINE_CONSTANT(target, NPN_ENABLED);
946946
#endif

src/node_crypto.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ template void SSLWrap<TLSWrap>::OnClientHello(
147147
void* arg,
148148
const ClientHelloParser::ClientHello& hello);
149149

150-
#ifdef OPENSSL_NPN_NEGOTIATED
150+
#ifndef OPENSSL_NO_NEXTPROTONEG
151151
template int SSLWrap<TLSWrap>::AdvertiseNextProtoCallback(
152152
SSL* s,
153153
const unsigned char** data,
@@ -1309,11 +1309,11 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) {
13091309
env->SetProtoMethod(t, "setMaxSendFragment", SetMaxSendFragment);
13101310
#endif // SSL_set_max_send_fragment
13111311

1312-
#ifdef OPENSSL_NPN_NEGOTIATED
1312+
#ifndef OPENSSL_NO_NEXTPROTONEG
13131313
env->SetProtoMethod(t, "getNegotiatedProtocol", GetNegotiatedProto);
1314-
#endif // OPENSSL_NPN_NEGOTIATED
1314+
#endif // OPENSSL_NO_NEXTPROTONEG
13151315

1316-
#ifdef OPENSSL_NPN_NEGOTIATED
1316+
#ifndef OPENSSL_NO_NEXTPROTONEG
13171317
env->SetProtoMethod(t, "setNPNProtocols", SetNPNProtocols);
13181318
#endif
13191319

@@ -1333,15 +1333,15 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) {
13331333

13341334
template <class Base>
13351335
void SSLWrap<Base>::InitNPN(SecureContext* sc) {
1336-
#ifdef OPENSSL_NPN_NEGOTIATED
1336+
#ifndef OPENSSL_NO_NEXTPROTONEG
13371337
// Server should advertise NPN protocols
13381338
SSL_CTX_set_next_protos_advertised_cb(sc->ctx_,
13391339
AdvertiseNextProtoCallback,
13401340
nullptr);
13411341
// Client should select protocol from list of advertised
13421342
// If server supports NPN
13431343
SSL_CTX_set_next_proto_select_cb(sc->ctx_, SelectNextProtoCallback, nullptr);
1344-
#endif // OPENSSL_NPN_NEGOTIATED
1344+
#endif // OPENSSL_NO_NEXTPROTONEG
13451345

13461346
#ifdef NODE__HAVE_TLSEXT_STATUS_CB
13471347
// OCSP stapling
@@ -2098,7 +2098,7 @@ void SSLWrap<Base>::GetProtocol(const FunctionCallbackInfo<Value>& args) {
20982098
}
20992099

21002100

2101-
#ifdef OPENSSL_NPN_NEGOTIATED
2101+
#ifndef OPENSSL_NO_NEXTPROTONEG
21022102
template <class Base>
21032103
int SSLWrap<Base>::AdvertiseNextProtoCallback(SSL* s,
21042104
const unsigned char** data,
@@ -2238,7 +2238,7 @@ void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
22382238
env->npn_buffer_private_symbol(),
22392239
args[0]).FromJust());
22402240
}
2241-
#endif // OPENSSL_NPN_NEGOTIATED
2241+
#endif // OPENSSL_NO_NEXTPROTONEG
22422242

22432243
#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
22442244
template <class Base>

src/node_crypto.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class SSLWrap {
249249
const v8::FunctionCallbackInfo<v8::Value>& args);
250250
#endif // SSL_set_max_send_fragment
251251

252-
#ifdef OPENSSL_NPN_NEGOTIATED
252+
#ifndef OPENSSL_NO_NEXTPROTONEG
253253
static void GetNegotiatedProto(
254254
const v8::FunctionCallbackInfo<v8::Value>& args);
255255
static void SetNPNProtocols(const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -263,7 +263,7 @@ class SSLWrap {
263263
const unsigned char* in,
264264
unsigned int inlen,
265265
void* arg);
266-
#endif // OPENSSL_NPN_NEGOTIATED
266+
#endif // OPENSSL_NO_NEXTPROTONEG
267267

268268
static void GetALPNNegotiatedProto(
269269
const v8::FunctionCallbackInfo<v8::Value>& args);
@@ -328,7 +328,7 @@ class Connection : public AsyncWrap, public SSLWrap<Connection> {
328328
static void Initialize(Environment* env, v8::Local<v8::Object> target);
329329
void NewSessionDoneCb();
330330

331-
#ifdef OPENSSL_NPN_NEGOTIATED
331+
#ifndef OPENSSL_NO_NEXTPROTONEG
332332
v8::Persistent<v8::Object> npnProtos_;
333333
v8::Persistent<v8::Value> selectedNPNProto_;
334334
#endif

0 commit comments

Comments
 (0)