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

Side by Side Diff: net/cert/nss_cert_database.h

Issue 18121007: *WIP* Store NSS slots per profile. Move keygen to chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: certdb: handle GetCertTrust and IsUntrusted, failed attempt to handle SetCertTrust Created 7 years, 1 month 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
« no previous file with comments | « net/cert/cert_database_nss.cc ('k') | net/cert/nss_cert_database.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_CERT_NSS_CERT_DATABASE_H_ 5 #ifndef NET_CERT_NSS_CERT_DATABASE_H_
6 #define NET_CERT_NSS_CERT_DATABASE_H_ 6 #define NET_CERT_NSS_CERT_DATABASE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "crypto/scoped_nss_types.h"
14 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
15 #include "net/cert/cert_type.h" 16 #include "net/cert/cert_type.h"
16 #include "net/cert/x509_certificate.h" 17 #include "net/cert/x509_certificate.h"
17 18
18 template <typename T> struct DefaultSingletonTraits; 19 template <typename T> struct DefaultSingletonTraits;
19 template <class ObserverType> class ObserverListThreadSafe; 20 template <class ObserverType> class ObserverListThreadSafe;
20 21
21 namespace net { 22 namespace net {
22 23
23 class CryptoModule; 24 class CryptoModule;
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 TRUSTED_OBJ_SIGN = 1 << 2, 86 TRUSTED_OBJ_SIGN = 1 << 2,
86 DISTRUSTED_SSL = 1 << 3, 87 DISTRUSTED_SSL = 1 << 3,
87 DISTRUSTED_EMAIL = 1 << 4, 88 DISTRUSTED_EMAIL = 1 << 4,
88 DISTRUSTED_OBJ_SIGN = 1 << 5, 89 DISTRUSTED_OBJ_SIGN = 1 << 5,
89 }; 90 };
90 91
91 static NSSCertDatabase* GetInstance(); 92 static NSSCertDatabase* GetInstance();
92 93
93 // Get a list of unique certificates in the certificate database (one 94 // Get a list of unique certificates in the certificate database (one
94 // instance of all certificates). 95 // instance of all certificates).
95 void ListCerts(CertificateList* certs); 96 virtual void ListCerts(CertificateList* certs);
97
98 // Get the default slot for public key data.
99 virtual crypto::ScopedPK11Slot GetPublicSlot() const;
100
101 // Get the default slot for private key or mixed private/public key data.
102 virtual crypto::ScopedPK11Slot GetPrivateSlot() const;
96 103
97 // Get the default module for public key data. 104 // Get the default module for public key data.
98 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. 105 // The returned pointer must be stored in a scoped_refptr<CryptoModule>.
106 // DEPRECATED: use GetPublicSlot instead.
99 CryptoModule* GetPublicModule() const; 107 CryptoModule* GetPublicModule() const;
100 108
101 // Get the default module for private key or mixed private/public key data. 109 // Get the default module for private key or mixed private/public key data.
102 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. 110 // The returned pointer must be stored in a scoped_refptr<CryptoModule>.
111 // DEPRECATED: use GetPrivateSlot instead.
103 CryptoModule* GetPrivateModule() const; 112 CryptoModule* GetPrivateModule() const;
104 113
105 // Get all modules. 114 // Get all modules.
106 // If |need_rw| is true, only writable modules will be returned. 115 // If |need_rw| is true, only writable modules will be returned.
107 void ListModules(CryptoModuleList* modules, bool need_rw) const; 116 virtual void ListModules(CryptoModuleList* modules, bool need_rw) const;
108 117
109 // Import certificates and private keys from PKCS #12 blob into the module. 118 // Import certificates and private keys from PKCS #12 blob into the module.
110 // If |is_extractable| is false, mark the private key as being unextractable 119 // If |is_extractable| is false, mark the private key as being unextractable
111 // from the module. 120 // from the module.
112 // Returns OK or a network error code such as ERR_PKCS12_IMPORT_BAD_PASSWORD 121 // Returns OK or a network error code such as ERR_PKCS12_IMPORT_BAD_PASSWORD
113 // or ERR_PKCS12_IMPORT_ERROR. |imported_certs|, if non-NULL, returns a list 122 // or ERR_PKCS12_IMPORT_ERROR. |imported_certs|, if non-NULL, returns a list
114 // of certs that were imported. 123 // of certs that were imported.
115 int ImportFromPKCS12(CryptoModule* module, 124 int ImportFromPKCS12(CryptoModule* module,
116 const std::string& data, 125 const std::string& data,
117 const base::string16& password, 126 const base::string16& password,
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 // |trust_bits| can be set to explicitly trust or distrust the certificate, or 159 // |trust_bits| can be set to explicitly trust or distrust the certificate, or
151 // use TRUST_DEFAULT to inherit trust as normal. 160 // use TRUST_DEFAULT to inherit trust as normal.
152 // Returns false if there is an internal error, otherwise true is returned and 161 // Returns false if there is an internal error, otherwise true is returned and
153 // |not_imported| should be checked for any certificates that were not 162 // |not_imported| should be checked for any certificates that were not
154 // imported. 163 // imported.
155 bool ImportServerCert(const CertificateList& certificates, 164 bool ImportServerCert(const CertificateList& certificates,
156 TrustBits trust_bits, 165 TrustBits trust_bits,
157 ImportCertFailureList* not_imported); 166 ImportCertFailureList* not_imported);
158 167
159 // Get trust bits for certificate. 168 // Get trust bits for certificate.
160 TrustBits GetCertTrust(const X509Certificate* cert, CertType type) const; 169 virtual TrustBits GetCertTrust(const X509Certificate* cert,
170 CertType type) const;
161 171
162 // IsUntrusted returns true if |cert| is specifically untrusted. These 172 // IsUntrusted returns true if |cert| is specifically untrusted. These
163 // certificates are stored in the database for the specific purpose of 173 // certificates are stored in the database for the specific purpose of
164 // rejecting them. 174 // rejecting them.
165 bool IsUntrusted(const X509Certificate* cert) const; 175 virtual bool IsUntrusted(const X509Certificate* cert) const;
166 176
167 // Set trust values for certificate. 177 // Set trust values for certificate.
168 // Returns true on success or false on failure. 178 // Returns true on success or false on failure.
169 bool SetCertTrust(const X509Certificate* cert, 179 virtual bool SetCertTrust(const X509Certificate* cert,
170 CertType type, 180 CertType type,
171 TrustBits trust_bits); 181 TrustBits trust_bits);
172 182
173 // Delete certificate and associated private key (if one exists). 183 // Delete certificate and associated private key (if one exists).
174 // |cert| is still valid when this function returns. Returns true on 184 // |cert| is still valid when this function returns. Returns true on
175 // success. 185 // success.
176 bool DeleteCertAndKey(const X509Certificate* cert); 186 bool DeleteCertAndKey(const X509Certificate* cert);
177 187
178 // Check whether cert is stored in a readonly slot. 188 // Check whether cert is stored in a readonly slot.
179 bool IsReadOnly(const X509Certificate* cert) const; 189 bool IsReadOnly(const X509Certificate* cert) const;
180 190
181 // Registers |observer| to receive notifications of certificate changes. The 191 // Registers |observer| to receive notifications of certificate changes. The
182 // thread on which this is called is the thread on which |observer| will be 192 // thread on which this is called is the thread on which |observer| will be
183 // called back with notifications. 193 // called back with notifications.
184 void AddObserver(Observer* observer); 194 void AddObserver(Observer* observer);
185 195
186 // Unregisters |observer| from receiving notifications. This must be called 196 // Unregisters |observer| from receiving notifications. This must be called
187 // on the same thread on which AddObserver() was called. 197 // on the same thread on which AddObserver() was called.
188 void RemoveObserver(Observer* observer); 198 void RemoveObserver(Observer* observer);
189 199
200 protected:
201 NSSCertDatabase();
202 virtual ~NSSCertDatabase();
203
190 private: 204 private:
191 friend struct DefaultSingletonTraits<NSSCertDatabase>; 205 friend struct DefaultSingletonTraits<NSSCertDatabase>;
192 206
193 NSSCertDatabase();
194 ~NSSCertDatabase();
195
196 // Broadcasts notifications to all registered observers. 207 // Broadcasts notifications to all registered observers.
197 void NotifyObserversOfCertAdded(const X509Certificate* cert); 208 void NotifyObserversOfCertAdded(const X509Certificate* cert);
198 void NotifyObserversOfCertRemoved(const X509Certificate* cert); 209 void NotifyObserversOfCertRemoved(const X509Certificate* cert);
199 void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); 210 void NotifyObserversOfCertTrustChanged(const X509Certificate* cert);
200 211
201 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_; 212 const scoped_refptr<ObserverListThreadSafe<Observer> > observer_list_;
202 213
203 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase); 214 DISALLOW_COPY_AND_ASSIGN(NSSCertDatabase);
204 }; 215 };
205 216
206 } // namespace net 217 } // namespace net
207 218
208 #endif // NET_CERT_NSS_CERT_DATABASE_H_ 219 #endif // NET_CERT_NSS_CERT_DATABASE_H_
OLDNEW
« no previous file with comments | « net/cert/cert_database_nss.cc ('k') | net/cert/nss_cert_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698