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

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

Issue 112533002: Add ClientCertStoreChromeOS which only returns the certs for a given user. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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_cert_store_chromeos.h"
6
7 #include <cert.h>
8
9 #include "base/bind.h"
10 #include "crypto/nss_crypto_module_delegate.h"
11 #include "crypto/nss_util_internal.h"
12
13 namespace net {
14
15 ClientCertStoreChromeOS::ClientCertStoreChromeOS(
16 const std::string& username_hash,
17 const PasswordDelegateFactory& password_delegate_factory)
18 : ClientCertStoreNSS(password_delegate_factory),
19 username_hash_(username_hash) {}
20
21 ClientCertStoreChromeOS::~ClientCertStoreChromeOS() {}
22
23 void ClientCertStoreChromeOS::GetClientCerts(
24 const SSLCertRequestInfo& cert_request_info,
25 CertificateList* selected_certs,
26 const base::Closure& callback) {
27 crypto::ScopedPK11Slot private_slot(crypto::GetPrivateSlotForChromeOSUser(
28 username_hash_,
29 base::Bind(&ClientCertStoreChromeOS::DidGetPrivateSlot,
30 base::Unretained(this),
Ryan Sleevi 2013/12/11 06:52:50 Why is this Unretained safe?
mattm 2013/12/12 00:45:22 Added comment (and expanded comment in net/ssl/cli
31 &cert_request_info,
32 selected_certs,
33 callback)));
34 if (private_slot)
35 DidGetPrivateSlot(
36 &cert_request_info, selected_certs, callback, private_slot.Pass());
37 }
38
39 void ClientCertStoreChromeOS::GetClientCertsImpl(CERTCertList* cert_list,
40 const SSLCertRequestInfo& request,
41 bool query_nssdb,
42 CertificateList* selected_certs) {
43 ClientCertStoreNSS::GetClientCertsImpl(
44 cert_list, request, query_nssdb, selected_certs);
45
46 size_t pre_size = selected_certs->size();
47 selected_certs->erase(
48 std::remove_if(selected_certs->begin(),
49 selected_certs->end(),
50 NSSProfileFilterChromeOS::Predicate(profile_filter_)),
51 selected_certs->end());
52 DVLOG(1) << "filtered " << pre_size - selected_certs->size() << " of "
53 << pre_size << " certs";
54 }
55
56 void ClientCertStoreChromeOS::DidGetPrivateSlot(
57 const SSLCertRequestInfo* request,
58 CertificateList* selected_certs,
59 const base::Closure& callback,
60 crypto::ScopedPK11Slot private_slot) {
61 profile_filter_.Init(crypto::GetPublicSlotForChromeOSUser(username_hash_),
62 private_slot.Pass());
63 ClientCertStoreNSS::GetClientCerts(*request, selected_certs, callback);
64 }
65
66 void ClientCertStoreChromeOS::InitForTesting(
67 crypto::ScopedPK11Slot public_slot,
68 crypto::ScopedPK11Slot private_slot) {
69 profile_filter_.Init(public_slot.Pass(), private_slot.Pass());
70 }
71
72 bool ClientCertStoreChromeOS::SelectClientCertsForTesting(
73 const CertificateList& input_certs,
74 const SSLCertRequestInfo& request,
75 CertificateList* selected_certs) {
76 CERTCertList* cert_list = CERT_NewCertList();
77 if (!cert_list)
78 return false;
79 for (size_t i = 0; i < input_certs.size(); ++i) {
80 CERT_AddCertToListTail(
81 cert_list, CERT_DupCertificate(input_certs[i]->os_cert_handle()));
82 }
83
84 GetClientCertsImpl(cert_list, request, false, selected_certs);
85 CERT_DestroyCertList(cert_list);
86 return true;
87 }
88
89
90 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698