Skip to content

Commit f4e5ab1

Browse files
jasnelltargos
authored andcommitted
src: crypto::UseSNIContext to use BaseObjectPtr
Extracted from the QUIC PR. Not specific to QUIC. Signed-off-by: James M Snell <jasnell@gmail.com> PR-URL: #33107 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
1 parent eab4be1 commit f4e5ab1

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/node_crypto.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2486,7 +2486,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
24862486
// Store the SNI context for later use.
24872487
w->sni_context_ = BaseObjectPtr<SecureContext>(sc);
24882488

2489-
if (UseSNIContext(w->ssl_, sc) && !w->SetCACerts(sc)) {
2489+
if (UseSNIContext(w->ssl_, w->sni_context_) && !w->SetCACerts(sc)) {
24902490
// Not clear why sometimes we throw error, and sometimes we call
24912491
// onerror(). Both cause .destroy(), but onerror does a bit more.
24922492
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)

src/node_crypto_common.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "base_object-inl.h"
12
#include "env-inl.h"
23
#include "node_buffer.h"
34
#include "node_crypto.h"
@@ -223,7 +224,7 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
223224
return err;
224225
}
225226

226-
int UseSNIContext(const SSLPointer& ssl, SecureContext* context) {
227+
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
227228
SSL_CTX* ctx = context->ctx_.get();
228229
X509* x509 = SSL_CTX_get0_certificate(ctx);
229230
EVP_PKEY* pkey = SSL_CTX_get0_privatekey(ctx);

src/node_crypto_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
7171
const SSLPointer& ssl,
7272
long def = X509_V_ERR_UNSPECIFIED); // NOLINT(runtime/int)
7373

74-
int UseSNIContext(const SSLPointer& ssl, SecureContext* context);
74+
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context);
7575

7676
const char* GetClientHelloALPN(const SSLPointer& ssl);
7777

0 commit comments

Comments
 (0)