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

Unified Diff: net/socket/ssl_client_socket_openssl.cc

Issue 12220104: Wire up SSL client authentication for OpenSSL/Android through the net/ stack (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: address nits Created 7 years, 10 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
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 c49326d89fefd85971c4b8ba3ee8b8ab15a4296e..70b5dcee610468cbfa5cbff581e5aa2b5b7d247c 100644
--- a/net/socket/ssl_client_socket_openssl.cc
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -19,7 +19,7 @@
#include "crypto/openssl_util.h"
#include "net/base/cert_verifier.h"
#include "net/base/net_errors.h"
-#include "net/base/openssl_private_key_store.h"
+#include "net/base/openssl_client_key_store.h"
#include "net/base/single_request_cert_verifier.h"
#include "net/base/ssl_cert_request_info.h"
#include "net/base/ssl_connection_status_flags.h"
@@ -590,15 +590,18 @@ int SSLClientSocketOpenSSL::ClientCertRequestCallback(SSL* ssl,
// Second pass: a client certificate should have been selected.
if (ssl_config_.client_cert) {
- EVP_PKEY* privkey = OpenSSLPrivateKeyStore::GetInstance()->FetchPrivateKey(
- X509_PUBKEY_get(X509_get_X509_PUBKEY(
- ssl_config_.client_cert->os_cert_handle())));
- if (privkey) {
+ // A note about ownership: FetchClientCertPrivateKey() increments
+ // the reference count of the EVP_PKEY. Ownership of this reference
+ // is passed directly to OpenSSL, which will release the reference
+ // using EVP_PKEY_free() when the SSL object is destroyed.
+ OpenSSLClientKeyStore::ScopedEVP_PKEY privkey;
+ if (OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey(
+ ssl_config_.client_cert.get(), &privkey)) {
// TODO(joth): (copied from NSS) We should wait for server certificate
// verification before sending our credentials. See http://crbug.com/13934
*x509 = X509Certificate::DupOSCertHandle(
ssl_config_.client_cert->os_cert_handle());
- *pkey = privkey;
+ *pkey = privkey.release();
return 1;
}
LOG(WARNING) << "Client cert found without private key";

Powered by Google App Engine
This is Rietveld 408576698