Skip to content

Commit 1436977

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 <[email protected]> PR-URL: #33107 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Sam Roberts <[email protected]>
1 parent 9570644 commit 1436977

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
@@ -2466,7 +2466,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
24662466
// Store the SNI context for later use.
24672467
w->sni_context_ = BaseObjectPtr<SecureContext>(sc);
24682468

2469-
if (UseSNIContext(w->ssl_, sc) && !w->SetCACerts(sc)) {
2469+
if (UseSNIContext(w->ssl_, w->sni_context_) && !w->SetCACerts(sc)) {
24702470
// Not clear why sometimes we throw error, and sometimes we call
24712471
// onerror(). Both cause .destroy(), but onerror does a bit more.
24722472
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)