@@ -120,8 +120,7 @@ X509_STORE* root_cert_store;
120120template class SSLWrap <TLSCallbacks>;
121121template void SSLWrap<TLSCallbacks>::AddMethods(Environment* env,
122122 Handle<FunctionTemplate> t);
123- template void SSLWrap<TLSCallbacks>::InitNPN(SecureContext* sc,
124- TLSCallbacks* base);
123+ template void SSLWrap<TLSCallbacks>::InitNPN(SecureContext* sc);
125124template SSL_SESSION* SSLWrap<TLSCallbacks>::GetSessionCallback(
126125 SSL* s,
127126 unsigned char * key,
@@ -1013,26 +1012,21 @@ void SSLWrap<Base>::AddMethods(Environment* env, Handle<FunctionTemplate> t) {
10131012
10141013
10151014template <class Base >
1016- void SSLWrap<Base>::InitNPN(SecureContext* sc, Base* base) {
1017- if (base->is_server ()) {
1015+ void SSLWrap<Base>::InitNPN(SecureContext* sc) {
10181016#ifdef OPENSSL_NPN_NEGOTIATED
1019- // Server should advertise NPN protocols
1020- SSL_CTX_set_next_protos_advertised_cb (sc->ctx_ ,
1021- AdvertiseNextProtoCallback,
1022- base);
1017+ // Server should advertise NPN protocols
1018+ SSL_CTX_set_next_protos_advertised_cb (sc->ctx_ ,
1019+ AdvertiseNextProtoCallback,
1020+ NULL );
1021+ // Client should select protocol from list of advertised
1022+ // If server supports NPN
1023+ SSL_CTX_set_next_proto_select_cb (sc->ctx_ , SelectNextProtoCallback, NULL );
10231024#endif // OPENSSL_NPN_NEGOTIATED
1024- } else {
1025- #ifdef OPENSSL_NPN_NEGOTIATED
1026- // Client should select protocol from list of advertised
1027- // If server supports NPN
1028- SSL_CTX_set_next_proto_select_cb (sc->ctx_ , SelectNextProtoCallback, base);
1029- #endif // OPENSSL_NPN_NEGOTIATED
1030- }
10311025
10321026#ifdef NODE__HAVE_TLSEXT_STATUS_CB
10331027 // OCSP stapling
10341028 SSL_CTX_set_tlsext_status_cb (sc->ctx_ , TLSExtStatusCallback);
1035- SSL_CTX_set_tlsext_status_arg (sc->ctx_ , base );
1029+ SSL_CTX_set_tlsext_status_arg (sc->ctx_ , NULL );
10361030#endif // NODE__HAVE_TLSEXT_STATUS_CB
10371031}
10381032
@@ -1688,7 +1682,7 @@ int SSLWrap<Base>::AdvertiseNextProtoCallback(SSL* s,
16881682 const unsigned char ** data,
16891683 unsigned int * len,
16901684 void * arg) {
1691- Base* w = static_cast <Base*>(arg );
1685+ Base* w = static_cast <Base*>(SSL_get_app_data (s) );
16921686 Environment* env = w->env ();
16931687 HandleScope handle_scope (env->isolate ());
16941688 Context::Scope context_scope (env->context ());
@@ -1714,7 +1708,7 @@ int SSLWrap<Base>::SelectNextProtoCallback(SSL* s,
17141708 const unsigned char * in,
17151709 unsigned int inlen,
17161710 void * arg) {
1717- Base* w = static_cast <Base*>(arg );
1711+ Base* w = static_cast <Base*>(SSL_get_app_data (s) );
17181712 Environment* env = w->env ();
17191713 HandleScope handle_scope (env->isolate ());
17201714 Context::Scope context_scope (env->context ());
@@ -1806,7 +1800,7 @@ void SSLWrap<Base>::SetNPNProtocols(const FunctionCallbackInfo<Value>& args) {
18061800#ifdef NODE__HAVE_TLSEXT_STATUS_CB
18071801template <class Base >
18081802int SSLWrap<Base>::TLSExtStatusCallback(SSL* s, void * arg) {
1809- Base* w = static_cast <Base*>(arg );
1803+ Base* w = static_cast <Base*>(SSL_get_app_data (s) );
18101804 Environment* env = w->env ();
18111805 HandleScope handle_scope (env->isolate ());
18121806
@@ -2122,7 +2116,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
21222116 if (secure_context_constructor_template->HasInstance (ret)) {
21232117 conn->sniContext_ .Reset (env->isolate (), ret);
21242118 SecureContext* sc = Unwrap<SecureContext>(ret.As <Object>());
2125- InitNPN (sc, conn );
2119+ InitNPN (sc);
21262120 SSL_set_SSL_CTX (s, sc->ctx_ );
21272121 } else {
21282122 return SSL_TLSEXT_ERR_NOACK;
@@ -2158,7 +2152,7 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
21582152 if (is_server)
21592153 SSL_set_info_callback (conn->ssl_ , SSLInfoCallback);
21602154
2161- InitNPN (sc, conn );
2155+ InitNPN (sc);
21622156
21632157#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
21642158 if (is_server) {
0 commit comments