Skip to content

Commit fc11db1

Browse files
committed
src: inline SetSNICallback
Refs: #30548 (comment) PR-URL: #30548 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: David Carlier <devnexen@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 7bd587e commit fc11db1

File tree

3 files changed

+6
-18
lines changed

3 files changed

+6
-18
lines changed

src/node_crypto.cc

+1-16
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ static bool extra_root_certs_loaded = false;
142142
template void SSLWrap<TLSWrap>::AddMethods(Environment* env,
143143
Local<FunctionTemplate> t);
144144
template void SSLWrap<TLSWrap>::ConfigureSecureContext(SecureContext* sc);
145-
template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc);
146145
template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc);
147146
template void SSLWrap<TLSWrap>::MemoryInfo(MemoryTracker* tracker) const;
148147
template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
@@ -2993,12 +2992,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
29932992
if (cons->HasInstance(ctx)) {
29942993
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
29952994
CHECK_NOT_NULL(sc);
2996-
// XXX: There is a method w->SetSNIContext(sc), and you might think that
2997-
// it makes sense to call that here and make setting w->sni_context_ part
2998-
// of it. In fact, that passes the test suite, although SetSNIContext()
2999-
// performs a lot more operations.
3000-
// If anybody is familiar enough with the TLS code to know whether it makes
3001-
// sense, please do so or document why it doesn't.
2995+
// Store the SNI context for later use.
30022996
w->sni_context_ = BaseObjectPtr<SecureContext>(sc);
30032997

30042998
int rv;
@@ -3057,15 +3051,6 @@ void SSLWrap<Base>::DestroySSL() {
30573051
}
30583052

30593053

3060-
template <class Base>
3061-
void SSLWrap<Base>::SetSNIContext(SecureContext* sc) {
3062-
ConfigureSecureContext(sc);
3063-
CHECK_EQ(SSL_set_SSL_CTX(ssl_.get(), sc->ctx_.get()), sc->ctx_.get());
3064-
3065-
SetCACerts(sc);
3066-
}
3067-
3068-
30693054
template <class Base>
30703055
int SSLWrap<Base>::SetCACerts(SecureContext* sc) {
30713056
int err = SSL_set1_verify_cert_store(ssl_.get(),

src/node_crypto.h

-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ class SSLWrap {
288288

289289
void DestroySSL();
290290
void WaitForCertCb(CertCb cb, void* arg);
291-
void SetSNIContext(SecureContext* sc);
292291
int SetCACerts(SecureContext* sc);
293292

294293
inline Environment* ssl_env() const {

src/tls_wrap.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1068,7 +1068,11 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
10681068
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
10691069
CHECK_NOT_NULL(sc);
10701070
p->sni_context_ = BaseObjectPtr<SecureContext>(sc);
1071-
p->SetSNIContext(sc);
1071+
1072+
p->ConfigureSecureContext(sc);
1073+
CHECK_EQ(SSL_set_SSL_CTX(p->ssl_.get(), sc->ctx_.get()), sc->ctx_.get());
1074+
p->SetCACerts(sc);
1075+
10721076
return SSL_TLSEXT_ERR_OK;
10731077
}
10741078

0 commit comments

Comments
 (0)