Skip to content

Commit f837f3a

Browse files
committed
fix
1 parent 7b45a8f commit f837f3a

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/node_crypto.cc

+6-6
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ X509_STORE* root_cert_store;
104104
template class SSLWrap<TLSWrap>;
105105
template void SSLWrap<TLSWrap>::AddMethods(Environment* env,
106106
Handle<FunctionTemplate> t);
107-
template void SSLWrap<TLSWrap>::InitNPN(TLSWrap* w, SecureContext* sc);
107+
template void SSLWrap<TLSWrap>::InitNPN(SecureContext* sc);
108108
template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
109109
SSL* s,
110110
unsigned char* key,
@@ -1012,7 +1012,7 @@ void SSLWrap<Base>::AddMethods(Environment* env, Handle<FunctionTemplate> t) {
10121012

10131013

10141014
template <class Base>
1015-
void SSLWrap<Base>::InitNPN(Base* w, SecureContext* sc) {
1015+
void SSLWrap<Base>::InitNPN(SecureContext* sc) {
10161016
#ifdef OPENSSL_NPN_NEGOTIATED
10171017
// Server should advertise NPN protocols
10181018
SSL_CTX_set_next_protos_advertised_cb(sc->ctx_,
@@ -1028,8 +1028,6 @@ void SSLWrap<Base>::InitNPN(Base* w, SecureContext* sc) {
10281028
SSL_CTX_set_tlsext_status_cb(sc->ctx_, TLSExtStatusCallback);
10291029
SSL_CTX_set_tlsext_status_arg(sc->ctx_, nullptr);
10301030
#endif // NODE__HAVE_TLSEXT_STATUS_CB
1031-
1032-
SSL_set_cert_cb(w->ssl_, SSLWrap<Base>::SSLCertCallback, w);
10331031
}
10341032

10351033

@@ -2257,7 +2255,7 @@ int Connection::SelectSNIContextCallback_(SSL *s, int *ad, void* arg) {
22572255
if (secure_context_constructor_template->HasInstance(ret)) {
22582256
conn->sni_context_.Reset(env->isolate(), ret);
22592257
SecureContext* sc = Unwrap<SecureContext>(ret.As<Object>());
2260-
InitNPN(conn, sc);
2258+
InitNPN(sc);
22612259
SSL_set_SSL_CTX(s, sc->ctx_);
22622260
} else {
22632261
return SSL_TLSEXT_ERR_NOACK;
@@ -2292,7 +2290,9 @@ void Connection::New(const FunctionCallbackInfo<Value>& args) {
22922290
if (is_server)
22932291
SSL_set_info_callback(conn->ssl_, SSLInfoCallback);
22942292

2295-
InitNPN(conn, sc);
2293+
InitNPN(sc);
2294+
2295+
SSL_set_cert_cb(conn->ssl_, SSLWrap<Connection>::SSLCertCallback, conn);
22962296

22972297
#ifdef SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
22982298
if (is_server) {

src/node_crypto.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class SSLWrap {
178178
protected:
179179
typedef void (*CertCb)(void* arg);
180180

181-
static void InitNPN(Base* w, SecureContext* sc);
181+
static void InitNPN(SecureContext* sc);
182182
static void AddMethods(Environment* env, v8::Handle<v8::FunctionTemplate> t);
183183

184184
static SSL_SESSION* GetSessionCallback(SSL* s,

src/tls_wrap.cc

+4-2
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,9 @@ void TLSWrap::InitSSL() {
148148
}
149149
#endif // SSL_CTRL_SET_TLSEXT_SERVERNAME_CB
150150

151-
InitNPN(this, sc_);
151+
InitNPN(sc_);
152+
153+
SSL_set_cert_cb(ssl_, SSLWrap<TLSWrap>::SSLCertCallback, this);
152154

153155
if (is_server()) {
154156
SSL_set_accept_state(ssl_);
@@ -808,7 +810,7 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
808810
p->sni_context_.Reset(env->isolate(), ctx);
809811

810812
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
811-
InitNPN(p, sc);
813+
InitNPN(sc);
812814
SSL_set_SSL_CTX(s, sc->ctx_);
813815
return SSL_TLSEXT_ERR_OK;
814816
}

0 commit comments

Comments
 (0)