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.
5 #include "net/ssl/client_key_store.h"
9 #include "net/cert/x509_certificate.h"
10 #include "net/ssl/ssl_private_key.h"
15 static base::LazyInstance
<ClientKeyStore
>::Leaky g_client_key_store
=
16 LAZY_INSTANCE_INITIALIZER
;
19 ClientKeyStore::ClientKeyStore() {}
21 ClientKeyStore::~ClientKeyStore() {}
24 ClientKeyStore
* ClientKeyStore::GetInstance() {
25 return g_client_key_store
.Pointer();
28 void ClientKeyStore::AddProvider(CertKeyProvider
* provider
) {
29 base::AutoLock
auto_lock(lock_
);
30 providers_
.push_back(provider
);
33 void ClientKeyStore::RemoveProvider(const CertKeyProvider
* provider
) {
34 base::AutoLock
auto_lock(lock_
);
36 const auto& it
= std::find(providers_
.begin(), providers_
.end(), provider
);
37 if (it
!= providers_
.end())
41 scoped_ptr
<SSLPrivateKey
> ClientKeyStore::FetchClientCertPrivateKey(
42 const X509Certificate
& certificate
) {
43 base::AutoLock
auto_lock(lock_
);
45 for (const auto& provider
: providers_
) {
46 scoped_ptr
<SSLPrivateKey
> key
;
47 if (provider
->GetCertificateKey(certificate
, &key
))