Skip to content

Commit 98297b9

Browse files
addaleaxtargos
authored andcommitted
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 ce8d8c0 commit 98297b9

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
@@ -119,7 +119,6 @@ static bool extra_root_certs_loaded = false;
119119
template void SSLWrap<TLSWrap>::AddMethods(Environment* env,
120120
Local<FunctionTemplate> t);
121121
template void SSLWrap<TLSWrap>::ConfigureSecureContext(SecureContext* sc);
122-
template void SSLWrap<TLSWrap>::SetSNIContext(SecureContext* sc);
123122
template int SSLWrap<TLSWrap>::SetCACerts(SecureContext* sc);
124123
template void SSLWrap<TLSWrap>::MemoryInfo(MemoryTracker* tracker) const;
125124
template SSL_SESSION* SSLWrap<TLSWrap>::GetSessionCallback(
@@ -2425,12 +2424,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
24252424
if (cons->HasInstance(ctx)) {
24262425
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
24272426
CHECK_NOT_NULL(sc);
2428-
// XXX: There is a method w->SetSNIContext(sc), and you might think that
2429-
// it makes sense to call that here and make setting w->sni_context_ part
2430-
// of it. In fact, that passes the test suite, although SetSNIContext()
2431-
// performs a lot more operations.
2432-
// If anybody is familiar enough with the TLS code to know whether it makes
2433-
// sense, please do so or document why it doesn't.
2427+
// Store the SNI context for later use.
24342428
w->sni_context_ = BaseObjectPtr<SecureContext>(sc);
24352429

24362430
if (UseSNIContext(w->ssl_, sc) && !w->SetCACerts(sc)) {
@@ -2471,15 +2465,6 @@ void SSLWrap<Base>::DestroySSL() {
24712465
}
24722466

24732467

2474-
template <class Base>
2475-
void SSLWrap<Base>::SetSNIContext(SecureContext* sc) {
2476-
ConfigureSecureContext(sc);
2477-
CHECK_EQ(SSL_set_SSL_CTX(ssl_.get(), sc->ctx_.get()), sc->ctx_.get());
2478-
2479-
SetCACerts(sc);
2480-
}
2481-
2482-
24832468
template <class Base>
24842469
int SSLWrap<Base>::SetCACerts(SecureContext* sc) {
24852470
int err = SSL_set1_verify_cert_store(ssl_.get(),

src/node_crypto.h

-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ class SSLWrap {
281281

282282
void DestroySSL();
283283
void WaitForCertCb(CertCb cb, void* arg);
284-
void SetSNIContext(SecureContext* sc);
285284
int SetCACerts(SecureContext* sc);
286285

287286
inline Environment* ssl_env() const {

src/tls_wrap.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,11 @@ int TLSWrap::SelectSNIContextCallback(SSL* s, int* ad, void* arg) {
10941094
SecureContext* sc = Unwrap<SecureContext>(ctx.As<Object>());
10951095
CHECK_NOT_NULL(sc);
10961096
p->sni_context_ = BaseObjectPtr<SecureContext>(sc);
1097-
p->SetSNIContext(sc);
1097+
1098+
p->ConfigureSecureContext(sc);
1099+
CHECK_EQ(SSL_set_SSL_CTX(p->ssl_.get(), sc->ctx_.get()), sc->ctx_.get());
1100+
p->SetCACerts(sc);
1101+
10981102
return SSL_TLSEXT_ERR_OK;
10991103
}
11001104

0 commit comments

Comments
 (0)