Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(565)

Unified Diff: net/socket/ssl_client_socket_openssl.cc

Issue 474663002: Remove manual CRYPTO_add calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: speling Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/cert/x509_certificate_openssl.cc ('k') | net/ssl/openssl_client_key_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/socket/ssl_client_socket_openssl.cc
diff --git a/net/socket/ssl_client_socket_openssl.cc b/net/socket/ssl_client_socket_openssl.cc
index 89cb40592952b387939d39c8ea21938f96c2bd2f..ed1138f50dd4e08c89fe76ff7a38a29328f6e24a 100644
--- a/net/socket/ssl_client_socket_openssl.cc
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -244,12 +244,8 @@ SSLClientSocketOpenSSL::PeerCertificateChain::operator=(
// os_chain_ is reference counted by scoped_refptr;
os_chain_ = other.os_chain_;
- // Must increase the reference count manually for sk_X509_dup
- openssl_chain_.reset(sk_X509_dup(other.openssl_chain_.get()));
- for (size_t i = 0; i < sk_X509_num(openssl_chain_.get()); ++i) {
- X509* x = sk_X509_value(openssl_chain_.get(), i);
- CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
- }
+ openssl_chain_.reset(X509_chain_up_ref(other.openssl_chain_.get()));
+
return *this;
}
@@ -271,15 +267,7 @@ void SSLClientSocketOpenSSL::PeerCertificateChain::Reset(
os_chain_ =
X509Certificate::CreateFromHandle(sk_X509_value(chain, 0), intermediates);
- // sk_X509_dup does not increase reference count on the certs in the stack.
- openssl_chain_.reset(sk_X509_dup(chain));
-
- std::vector<base::StringPiece> der_chain;
- for (size_t i = 0; i < sk_X509_num(openssl_chain_.get()); ++i) {
- X509* x = sk_X509_value(openssl_chain_.get(), i);
- // Increase the reference count for the certs in openssl_chain_.
- CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
- }
+ openssl_chain_.reset(X509_chain_up_ref(chain));
}
#else // !defined(USE_OPENSSL_CERTS)
void SSLClientSocketOpenSSL::PeerCertificateChain::Reset(
@@ -290,16 +278,12 @@ void SSLClientSocketOpenSSL::PeerCertificateChain::Reset(
if (!chain)
return;
- // sk_X509_dup does not increase reference count on the certs in the stack.
- openssl_chain_.reset(sk_X509_dup(chain));
+ openssl_chain_.reset(X509_chain_up_ref(chain));
std::vector<base::StringPiece> der_chain;
for (size_t i = 0; i < sk_X509_num(openssl_chain_.get()); ++i) {
X509* x = sk_X509_value(openssl_chain_.get(), i);
- // Increase the reference count for the certs in openssl_chain_.
- CRYPTO_add(&x->references, 1, CRYPTO_LOCK_X509);
-
unsigned char* cert_data = NULL;
int cert_data_length = i2d_X509(x, &cert_data);
if (cert_data_length && cert_data)
« no previous file with comments | « net/cert/x509_certificate_openssl.cc ('k') | net/ssl/openssl_client_key_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698