Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tls: fix macro to check NPN feature #11655

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2913,7 +2913,7 @@ static Local<Object> GetFeatures(Environment* env) {
// TODO(bnoordhuis) ping libuv
obj->Set(FIXED_ONE_BYTE_STRING(env->isolate(), "ipv6"), True(env->isolate()));

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
Local<Boolean> tls_npn = True(env->isolate());
#else
Local<Boolean> tls_npn = False(env->isolate());
Expand Down
2 changes: 1 addition & 1 deletion src/node_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ void DefineOpenSSLConstants(Local<Object> target) {
NODE_DEFINE_CONSTANT(target, DH_NOT_SUITABLE_GENERATOR);
#endif

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
#define NPN_ENABLED 1
NODE_DEFINE_CONSTANT(target, NPN_ENABLED);
#endif
Expand Down
16 changes: 8 additions & 8 deletions src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ template void SSLWrap<TLSWrap>::OnClientHello(
void* arg,
const ClientHelloParser::ClientHello& hello);

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
template int SSLWrap<TLSWrap>::AdvertiseNextProtoCallback(
SSL* s,
const unsigned char** data,
Expand Down Expand Up @@ -1314,11 +1314,11 @@ void SSLWrap<Base>::AddMethods(Environment* env, Local<FunctionTemplate> t) {
env->SetProtoMethod(t, "setMaxSendFragment", SetMaxSendFragment);
#endif // SSL_set_max_send_fragment

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
env->SetProtoMethod(t, "getNegotiatedProtocol", GetNegotiatedProto);
#endif // OPENSSL_NPN_NEGOTIATED
#endif // OPENSSL_NO_NEXTPROTONEG

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
env->SetProtoMethod(t, "setNPNProtocols", SetNPNProtocols);
#endif

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

template <class Base>
void SSLWrap<Base>::InitNPN(SecureContext* sc) {
#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
// Server should advertise NPN protocols
SSL_CTX_set_next_protos_advertised_cb(sc->ctx_,
AdvertiseNextProtoCallback,
nullptr);
// Client should select protocol from list of advertised
// If server supports NPN
SSL_CTX_set_next_proto_select_cb(sc->ctx_, SelectNextProtoCallback, nullptr);
#endif // OPENSSL_NPN_NEGOTIATED
#endif // OPENSSL_NO_NEXTPROTONEG

#ifdef NODE__HAVE_TLSEXT_STATUS_CB
// OCSP stapling
Expand Down Expand Up @@ -2091,7 +2091,7 @@ void SSLWrap<Base>::GetProtocol(const FunctionCallbackInfo<Value>& args) {
}


#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
template <class Base>
int SSLWrap<Base>::AdvertiseNextProtoCallback(SSL* s,
const unsigned char** data,
Expand Down Expand Up @@ -2231,7 +2231,7 @@ void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
env->npn_buffer_private_symbol(),
args[0]).FromJust());
}
#endif // OPENSSL_NPN_NEGOTIATED
#endif // OPENSSL_NO_NEXTPROTONEG

#ifdef TLSEXT_TYPE_application_layer_protocol_negotiation
template <class Base>
Expand Down
6 changes: 3 additions & 3 deletions src/node_crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class SSLWrap {
const v8::FunctionCallbackInfo<v8::Value>& args);
#endif // SSL_set_max_send_fragment

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
static void GetNegotiatedProto(
const v8::FunctionCallbackInfo<v8::Value>& args);
static void SetNPNProtocols(const v8::FunctionCallbackInfo<v8::Value>& args);
Expand All @@ -263,7 +263,7 @@ class SSLWrap {
const unsigned char* in,
unsigned int inlen,
void* arg);
#endif // OPENSSL_NPN_NEGOTIATED
#endif // OPENSSL_NO_NEXTPROTONEG

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

#ifdef OPENSSL_NPN_NEGOTIATED
#ifndef OPENSSL_NO_NEXTPROTONEG
v8::Persistent<v8::Object> npnProtos_;
v8::Persistent<v8::Value> selectedNPNProto_;
#endif
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-tls-alpn-server-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ if (!common.hasCrypto) {
return;
}

if (!process.features.tls_alpn) {
console.error('Skipping because node compiled without OpenSSL or ' +
'with old OpenSSL version.');
process.exit(0);
if (!process.features.tls_alpn || !process.features.tls_npn) {
common.skip('Skipping because node compiled without NPN or ALPN' +
' feature of OpenSSL.');
return;
}

const assert = require('assert');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-tls-npn-server-client.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
const common = require('../common');
if (!process.features.tls_npn) {
common.skip('node compiled without OpenSSL or ' +
'with old OpenSSL version.');
common.skip('Skipping because node compiled without NPN feature of' +
' OpenSSL.');
return;
}

Expand Down