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

Side by Side Diff: net/ssl/client_key_store.cc

Issue 2937553003: Make CertificateProviderService vend ClientCertIdentities directly. (Closed)
Patch Set: review changes for comments 11 & 12 Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « net/ssl/client_key_store.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/ssl/client_key_store.h"
6
7 #include <algorithm>
8 #include <utility>
9
10 #include "net/cert/x509_certificate.h"
11 #include "net/ssl/ssl_private_key.h"
12
13 namespace net {
14
15 namespace {
16 static base::LazyInstance<ClientKeyStore>::Leaky g_client_key_store =
17 LAZY_INSTANCE_INITIALIZER;
18 } // namespace
19
20 ClientKeyStore::ClientKeyStore() {}
21
22 ClientKeyStore::~ClientKeyStore() {}
23
24 // static
25 ClientKeyStore* ClientKeyStore::GetInstance() {
26 return g_client_key_store.Pointer();
27 }
28
29 void ClientKeyStore::AddProvider(CertKeyProvider* provider) {
30 base::AutoLock auto_lock(lock_);
31 providers_.push_back(provider);
32 }
33
34 void ClientKeyStore::RemoveProvider(const CertKeyProvider* provider) {
35 base::AutoLock auto_lock(lock_);
36
37 const auto& it = std::find(providers_.begin(), providers_.end(), provider);
38 if (it != providers_.end())
39 providers_.erase(it);
40 }
41
42 scoped_refptr<SSLPrivateKey> ClientKeyStore::FetchClientCertPrivateKey(
43 const X509Certificate& certificate) {
44 base::AutoLock auto_lock(lock_);
45
46 for (auto* provider : providers_) {
47 scoped_refptr<SSLPrivateKey> key;
48 if (provider->GetCertificateKey(certificate, &key))
49 return key;
50 }
51 return nullptr;
52 }
53
54 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/client_key_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698