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

Unified Diff: net/socket/ssl_client_socket_openssl.cc

Issue 396803002: Implement TLS client auth in the OS X OpenSSL port. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: EVP_PKEY_set1_RSA has a saner ownership story. Created 6 years, 5 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 3e5de8c5e47abf88107b029f6e36b295726520b1..42fca0358791d0f776fa84f83fda31e7299f6c58 100644
--- a/net/socket/ssl_client_socket_openssl.cc
+++ b/net/socket/ssl_client_socket_openssl.cc
@@ -23,14 +23,19 @@
#include "net/cert/cert_verifier.h"
#include "net/cert/single_request_cert_verifier.h"
#include "net/cert/x509_certificate_net_log_param.h"
-#include "net/socket/openssl_ssl_util.h"
#include "net/socket/ssl_error_params.h"
#include "net/socket/ssl_session_cache_openssl.h"
-#include "net/ssl/openssl_client_key_store.h"
+#include "net/ssl/openssl_ssl_util.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/ssl/ssl_connection_status_flags.h"
#include "net/ssl/ssl_info.h"
+#if defined(USE_OPENSSL_CERTS)
+#include "net/ssl/openssl_client_key_store.h"
+#else // !defined(USE_OPENSSL_CERTS)
+#include "net/ssl/openssl_platform_key.h"
+#endif // defined(USE_OPENSSL_CERTS)
wtc 2014/07/16 00:09:58 Nit: I would omit the comments on lines 35 and 37
davidben 2014/07/16 16:25:35 Done.
+
namespace net {
namespace {
@@ -1335,6 +1340,11 @@ int SSLClientSocketOpenSSL::ClientCertRequestCallback(SSL* ssl,
DCHECK(ssl == ssl_);
DCHECK(*x509 == NULL);
DCHECK(*pkey == NULL);
+
+#if defined(OS_IOS)
+ // TODO(droger): Support client auth on iOS. See http://crbug.com/145954).
+ LOG(WARNING) << "Client auth is not supported";
+#else // !defined(OS_IOS)
if (!ssl_config_.send_client_cert) {
// First pass: we know that a client certificate is needed, but we do not
// have one at hand.
@@ -1373,25 +1383,25 @@ int SSLClientSocketOpenSSL::ClientCertRequestCallback(SSL* ssl,
return -1;
}
- crypto::ScopedEVP_PKEY privkey;
+ // TODO(davidben): With Linux client auth support, this should be
+ // conditioned on OS_ANDROID and then, with https://crbug.com/394131,
+ // removed altogether. OpenSSLClientKeyStore is mostly an artifact of the
+ // net/ client auth API lacking a private key handle.
#if defined(USE_OPENSSL_CERTS)
- // 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.
- if (!OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey(
- ssl_config_.client_cert.get(), &privkey)) {
+ crypto::ScopedEVP_PKEY privkey =
+ OpenSSLClientKeyStore::GetInstance()->FetchClientCertPrivateKey(
+ ssl_config_.client_cert.get());
+#else // !defined(USE_OPENSSL_CERTS)
+ crypto::ScopedEVP_PKEY privkey =
+ FetchClientCertPrivateKey(ssl_config_.client_cert.get());
+#endif // defined(USE_OPENSSL_CERTS)
+ if (!privkey) {
// Could not find the private key. Fail the handshake and surface an
// appropriate error to the caller.
LOG(WARNING) << "Client cert found without private key";
OpenSSLPutNetError(FROM_HERE, ERR_SSL_CLIENT_AUTH_CERT_NO_PRIVATE_KEY);
return -1;
}
-#else // !defined(USE_OPENSSL_CERTS)
- // OS handling of private keys is not yet implemented.
- NOTIMPLEMENTED();
- return 0;
-#endif // defined(USE_OPENSSL_CERTS)
// TODO(joth): (copied from NSS) We should wait for server certificate
// verification before sending our credentials. See http://crbug.com/13934
@@ -1399,6 +1409,7 @@ int SSLClientSocketOpenSSL::ClientCertRequestCallback(SSL* ssl,
*pkey = privkey.release();
return 1;
}
+#endif // defined(OS_IOS)
// Send no client certificate.
return 0;

Powered by Google App Engine
This is Rietveld 408576698