diff --git a/deps/ncrypto/ncrypto.h b/deps/ncrypto/ncrypto.h index 83ce2458bddaf45..479b4dcf07da975 100644 --- a/deps/ncrypto/ncrypto.h +++ b/deps/ncrypto/ncrypto.h @@ -570,6 +570,8 @@ class X509View final { NCRYPTO_DISALLOW_MOVE(X509View) inline X509* get() const { return const_cast(cert_); } + inline operator X509*() const { return const_cast(cert_); } + inline operator const X509*() const { return cert_; } inline bool operator==(std::nullptr_t) noexcept { return cert_ == nullptr; } inline operator bool() const { return cert_ != nullptr; } @@ -631,6 +633,8 @@ class X509Pointer final { inline bool operator==(std::nullptr_t) noexcept { return cert_ == nullptr; } inline operator bool() const { return cert_ != nullptr; } inline X509* get() const { return cert_.get(); } + inline operator X509*() const { return cert_.get(); } + inline operator const X509*() const { return cert_.get(); } void reset(X509* cert = nullptr); X509* release(); diff --git a/src/crypto/crypto_common.cc b/src/crypto/crypto_common.cc index 2d1158313c85226..b90415cb33981a1 100644 --- a/src/crypto/crypto_common.cc +++ b/src/crypto/crypto_common.cc @@ -83,7 +83,7 @@ bool UseSNIContext( STACK_OF(X509)* chain; int err = SSL_CTX_get0_chain_certs(ctx, &chain); - if (err == 1) err = SSL_use_certificate(ssl.get(), x509.get()); + if (err == 1) err = SSL_use_certificate(ssl.get(), x509); if (err == 1) err = SSL_use_PrivateKey(ssl.get(), pkey); if (err == 1 && chain != nullptr) err = SSL_set1_chain(ssl.get(), chain); return err == 1; diff --git a/src/crypto/crypto_context.cc b/src/crypto/crypto_context.cc index 21021094da3c2bc..db6f437759c3ecc 100644 --- a/src/crypto/crypto_context.cc +++ b/src/crypto/crypto_context.cc @@ -787,9 +787,8 @@ void SecureContext::SetCACert(const BIOPointer& bio) { while (X509Pointer x509 = X509Pointer(PEM_read_bio_X509_AUX( bio.get(), nullptr, NoPasswordCallback, nullptr))) { CHECK_EQ(1, - X509_STORE_add_cert(GetCertStoreOwnedByThisSecureContext(), - x509.get())); - CHECK_EQ(1, SSL_CTX_add_client_CA(ctx_.get(), x509.get())); + X509_STORE_add_cert(GetCertStoreOwnedByThisSecureContext(), x509)); + CHECK_EQ(1, SSL_CTX_add_client_CA(ctx_.get(), x509)); } }