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

Unified Diff: net/base/openssl_private_key_store_android.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: Fix linux_redux build. 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/base/openssl_private_key_store_android.cc
diff --git a/net/base/openssl_private_key_store_android.cc b/net/base/openssl_private_key_store_android.cc
index 4bf1f3fedcb555fd316acfa0a183f0972079146b..cf197cd15c1d6f95e66d59b2807e3c8b0fa80001 100644
--- a/net/base/openssl_private_key_store_android.cc
+++ b/net/base/openssl_private_key_store_android.cc
@@ -9,18 +9,26 @@
#include "base/logging.h"
#include "base/memory/singleton.h"
-#include "crypto/openssl_util.h"
#include "net/android/network_library.h"
namespace net {
namespace {
-class OpenSSLKeyStoreAndroid : public OpenSSLPrivateKeyStore {
+// Android-specific implementation of OpenSSLPrivateKeyStore.
+// This uses platform APIs to store the private/public keygened
+// pair to the system's keychain.
+class OpenSSLPrivateKeyStoreAndroid : public OpenSSLPrivateKeyStore {
public:
- ~OpenSSLKeyStoreAndroid() {}
+ OpenSSLPrivateKeyStoreAndroid() {}
- virtual bool StorePrivateKey(const GURL& url, EVP_PKEY* pkey) {
+ virtual ~OpenSSLPrivateKeyStoreAndroid() {}
+
+ static OpenSSLPrivateKeyStoreAndroid* GetInstance() {
+ return Singleton<OpenSSLPrivateKeyStoreAndroid>::get();
+ }
+
+ virtual bool StoreKeyPair(const GURL& url, EVP_PKEY* pkey) OVERRIDE {
// Always clear openssl errors on exit.
crypto::OpenSSLErrStackTracer err_trace(FROM_HERE);
@@ -45,41 +53,21 @@ class OpenSSLKeyStoreAndroid : public OpenSSLPrivateKeyStore {
static_cast<const uint8*>(public_key), public_len,
static_cast<const uint8*>(private_key), private_len);
}
- LOG_IF(ERROR, !ret) << "StorePrivateKey failed. pub len = " << public_len
+ LOG_IF(ERROR, !ret) << "StoreKeyPair failed. pub len = " << public_len
<< " priv len = " << private_len;
OPENSSL_free(public_key);
OPENSSL_free(private_key);
return ret;
}
- virtual EVP_PKEY* FetchPrivateKey(EVP_PKEY* pkey) {
- // TODO(joth): Implement when client authentication is required.
- NOTIMPLEMENTED();
- return NULL;
- }
-
- static OpenSSLKeyStoreAndroid* GetInstance() {
- // Leak the OpenSSL key store as it is used from a non-joinable worker
- // thread that may still be running at shutdown.
- return Singleton<
- OpenSSLKeyStoreAndroid,
- OpenSSLKeyStoreAndroidLeakyTraits>::get();
- }
-
private:
- friend struct DefaultSingletonTraits<OpenSSLKeyStoreAndroid>;
- typedef LeakySingletonTraits<OpenSSLKeyStoreAndroid>
- OpenSSLKeyStoreAndroidLeakyTraits;
-
- OpenSSLKeyStoreAndroid() {}
-
- DISALLOW_COPY_AND_ASSIGN(OpenSSLKeyStoreAndroid);
+ DISALLOW_COPY_AND_ASSIGN(OpenSSLPrivateKeyStoreAndroid);
};
} // namespace
OpenSSLPrivateKeyStore* OpenSSLPrivateKeyStore::GetInstance() {
- return OpenSSLKeyStoreAndroid::GetInstance();
+ return OpenSSLPrivateKeyStoreAndroid::GetInstance();
}
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698