Skip to content

Commit

Permalink
src: crypto::UseSNIContext to use BaseObjectPtr
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
jasnell authored and targos committed May 4, 2020
1 parent eab4be1 commit f4e5ab1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/node_crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2486,7 +2486,7 @@ void SSLWrap<Base>::CertCbDone(const FunctionCallbackInfo<Value>& args) {
// Store the SNI context for later use.
w->sni_context_ = BaseObjectPtr<SecureContext>(sc);

if (UseSNIContext(w->ssl_, sc) && !w->SetCACerts(sc)) {
if (UseSNIContext(w->ssl_, w->sni_context_) && !w->SetCACerts(sc)) {
// Not clear why sometimes we throw error, and sometimes we call
// onerror(). Both cause .destroy(), but onerror does a bit more.
unsigned long err = ERR_get_error(); // NOLINT(runtime/int)
Expand Down
3 changes: 2 additions & 1 deletion src/node_crypto_common.cc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include "base_object-inl.h"
#include "env-inl.h"
#include "node_buffer.h"
#include "node_crypto.h"
Expand Down Expand Up @@ -223,7 +224,7 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
return err;
}

int UseSNIContext(const SSLPointer& ssl, SecureContext* context) {
int UseSNIContext(const SSLPointer& ssl, BaseObjectPtr<SecureContext> context) {
SSL_CTX* ctx = context->ctx_.get();
X509* x509 = SSL_CTX_get0_certificate(ctx);
EVP_PKEY* pkey = SSL_CTX_get0_privatekey(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/node_crypto_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ long VerifyPeerCertificate( // NOLINT(runtime/int)
const SSLPointer& ssl,
long def = X509_V_ERR_UNSPECIFIED); // NOLINT(runtime/int)

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

const char* GetClientHelloALPN(const SSLPointer& ssl);

Expand Down

0 comments on commit f4e5ab1

Please sign in to comment.