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

Side by Side Diff: net/base/cert_database_nss.cc

Issue 2944008: Refactor X509Certificate caching to cache the OS handle, rather than the X509Certificate (Closed)
Patch Set: Rebase to trunk after splitting out 4645001 Created 9 years, 11 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/base/cert_database.h" 5 #include "net/base/cert_database.h"
6 6
7 #include <cert.h> 7 #include <cert.h>
8 #include <certdb.h> 8 #include <certdb.h>
9 #include <keyhi.h> 9 #include <keyhi.h>
10 #include <pk11pub.h> 10 #include <pk11pub.h>
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 92
93 void CertDatabase::ListCerts(CertificateList* certs) { 93 void CertDatabase::ListCerts(CertificateList* certs) {
94 certs->clear(); 94 certs->clear();
95 95
96 CERTCertList* cert_list = PK11_ListCerts(PK11CertListUnique, NULL); 96 CERTCertList* cert_list = PK11_ListCerts(PK11CertListUnique, NULL);
97 CERTCertListNode* node; 97 CERTCertListNode* node;
98 for (node = CERT_LIST_HEAD(cert_list); 98 for (node = CERT_LIST_HEAD(cert_list);
99 !CERT_LIST_END(node, cert_list); 99 !CERT_LIST_END(node, cert_list);
100 node = CERT_LIST_NEXT(node)) { 100 node = CERT_LIST_NEXT(node)) {
101 certs->push_back(X509Certificate::CreateFromHandle( 101 certs->push_back(X509Certificate::CreateFromHandle(
102 node->cert, 102 node->cert, X509Certificate::OSCertHandles()));
103 X509Certificate::SOURCE_LONE_CERT_IMPORT,
104 X509Certificate::OSCertHandles()));
105 } 103 }
106 CERT_DestroyCertList(cert_list); 104 CERT_DestroyCertList(cert_list);
107 } 105 }
108 106
109 int CertDatabase::ImportFromPKCS12( 107 int CertDatabase::ImportFromPKCS12(
110 const std::string& data, const string16& password) { 108 const std::string& data, const string16& password) {
111 return psm::nsPKCS12Blob_Import(data.data(), data.size(), password); 109 return psm::nsPKCS12Blob_Import(data.data(), data.size(), password);
112 } 110 }
113 111
114 int CertDatabase::ExportToPKCS12( 112 int CertDatabase::ExportToPKCS12(
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 } 201 }
204 return true; 202 return true;
205 } 203 }
206 204
207 bool CertDatabase::IsReadOnly(const X509Certificate* cert) const { 205 bool CertDatabase::IsReadOnly(const X509Certificate* cert) const {
208 PK11SlotInfo* slot = cert->os_cert_handle()->slot; 206 PK11SlotInfo* slot = cert->os_cert_handle()->slot;
209 return slot && PK11_IsReadOnly(slot); 207 return slot && PK11_IsReadOnly(slot);
210 } 208 }
211 209
212 } // namespace net 210 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698