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

Unified Diff: net/ssl/client_key_store.cc

Issue 1278763002: Add a ClientKeyStore to allow injection of non-platform keys for TLS client auth. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@client_cert_store
Patch Set: Nits. Created 5 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/ssl/client_key_store.h ('k') | net/ssl/ssl_platform_key_nss.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/ssl/client_key_store.cc
diff --git a/net/ssl/client_key_store.cc b/net/ssl/client_key_store.cc
new file mode 100644
index 0000000000000000000000000000000000000000..358bc8e2f57b046f0cffd94e9fc20912f7b923cb
--- /dev/null
+++ b/net/ssl/client_key_store.cc
@@ -0,0 +1,53 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/ssl/client_key_store.h"
+
+#include <algorithm>
+
+#include "net/cert/x509_certificate.h"
+#include "net/ssl/ssl_private_key.h"
+
+namespace net {
+
+namespace {
+static base::LazyInstance<ClientKeyStore>::Leaky g_client_key_store =
+ LAZY_INSTANCE_INITIALIZER;
+} // namespace
+
+ClientKeyStore::ClientKeyStore() {}
+
+ClientKeyStore::~ClientKeyStore() {}
+
+// static
+ClientKeyStore* ClientKeyStore::GetInstance() {
+ return g_client_key_store.Pointer();
+}
+
+void ClientKeyStore::AddProvider(CertKeyProvider* provider) {
+ base::AutoLock auto_lock(lock_);
+ providers_.push_back(provider);
+}
+
+void ClientKeyStore::RemoveProvider(const CertKeyProvider* provider) {
+ base::AutoLock auto_lock(lock_);
+
+ const auto& it = std::find(providers_.begin(), providers_.end(), provider);
+ if (it != providers_.end())
+ providers_.erase(it);
+}
+
+scoped_ptr<SSLPrivateKey> ClientKeyStore::FetchClientCertPrivateKey(
+ const X509Certificate& certificate) {
+ base::AutoLock auto_lock(lock_);
+
+ for (const auto& provider : providers_) {
+ scoped_ptr<SSLPrivateKey> key;
+ if (provider->GetCertificateKey(certificate, &key))
+ return key.Pass();
+ }
+ return nullptr;
+}
+
+} // namespace net
« no previous file with comments | « net/ssl/client_key_store.h ('k') | net/ssl/ssl_platform_key_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698