OLD | NEW |
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 CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 5 #ifndef CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
6 #define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 6 #define CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 // |data|, using the given |password|. If |is_extractable| is false, | 60 // |data|, using the given |password|. If |is_extractable| is false, |
61 // mark the private key as unextractable from the module. | 61 // mark the private key as unextractable from the module. |
62 // Returns a net error code on failure. | 62 // Returns a net error code on failure. |
63 int ImportFromPKCS12(net::CryptoModule* module, const std::string& data, | 63 int ImportFromPKCS12(net::CryptoModule* module, const std::string& data, |
64 const string16& password, bool is_extractable); | 64 const string16& password, bool is_extractable); |
65 | 65 |
66 // Import CA certificates. | 66 // Import CA certificates. |
67 // Tries to import all the certificates given. The root will be trusted | 67 // Tries to import all the certificates given. The root will be trusted |
68 // according to |trust_bits|. Any certificates that could not be imported | 68 // according to |trust_bits|. Any certificates that could not be imported |
69 // will be listed in |not_imported|. | 69 // will be listed in |not_imported|. |
70 // |trust_bits| should be a bit field of TRUST_* values from CertDatabase, or | 70 // |trust_bits| should be a bit field of TRUST* values from CertDatabase. |
71 // UNTRUSTED. | |
72 // Returns false if there is an internal error, otherwise true is returned and | 71 // Returns false if there is an internal error, otherwise true is returned and |
73 // |not_imported| should be checked for any certificates that were not | 72 // |not_imported| should be checked for any certificates that were not |
74 // imported. | 73 // imported. |
75 bool ImportCACerts(const net::CertificateList& certificates, | 74 bool ImportCACerts(const net::CertificateList& certificates, |
76 net::CertDatabase::TrustBits trust_bits, | 75 net::CertDatabase::TrustBits trust_bits, |
77 net::CertDatabase::ImportCertFailureList* not_imported); | 76 net::CertDatabase::ImportCertFailureList* not_imported); |
78 | 77 |
79 // Import server certificate. The first cert should be the server cert. Any | 78 // Import server certificate. The first cert should be the server cert. Any |
80 // additional certs should be intermediate/CA certs and will be imported but | 79 // additional certs should be intermediate/CA certs and will be imported but |
81 // not given any trust. | 80 // not given any trust. |
82 // Any certificates that could not be imported will be listed in | 81 // Any certificates that could not be imported will be listed in |
83 // |not_imported|. | 82 // |not_imported|. |
| 83 // |trust_bits| can be set to explicitly trust or distrust the certificate, or |
| 84 // use TRUST_DEFAULT to inherit trust as normal. |
84 // Returns false if there is an internal error, otherwise true is returned and | 85 // Returns false if there is an internal error, otherwise true is returned and |
85 // |not_imported| should be checked for any certificates that were not | 86 // |not_imported| should be checked for any certificates that were not |
86 // imported. | 87 // imported. |
87 bool ImportServerCert( | 88 bool ImportServerCert( |
88 const net::CertificateList& certificates, | 89 const net::CertificateList& certificates, |
| 90 net::CertDatabase::TrustBits trust_bits, |
89 net::CertDatabase::ImportCertFailureList* not_imported); | 91 net::CertDatabase::ImportCertFailureList* not_imported); |
90 | 92 |
91 // Set trust values for certificate. | 93 // Set trust values for certificate. |
92 // |trust_bits| should be a bit field of TRUST_* values from CertDatabase, or | 94 // |trust_bits| should be a bit field of TRUST* values from CertDatabase. |
93 // UNTRUSTED. | |
94 // Returns true on success or false on failure. | 95 // Returns true on success or false on failure. |
95 bool SetCertTrust(const net::X509Certificate* cert, | 96 bool SetCertTrust(const net::X509Certificate* cert, |
96 net::CertType type, | 97 net::CertType type, |
97 net::CertDatabase::TrustBits trust_bits); | 98 net::CertDatabase::TrustBits trust_bits); |
98 | 99 |
99 // Delete the cert. Returns true on success. |cert| is still valid when this | 100 // Delete the cert. Returns true on success. |cert| is still valid when this |
100 // function returns. | 101 // function returns. |
101 bool Delete(net::X509Certificate* cert); | 102 bool Delete(net::X509Certificate* cert); |
102 | 103 |
103 // IsHardwareBacked returns true if |cert| is hardware backed. | 104 // IsHardwareBacked returns true if |cert| is hardware backed. |
104 // This function is only implemented for Chrome OS and always returns false | 105 // This function is only implemented for Chrome OS and always returns false |
105 // for other platforms. | 106 // for other platforms. |
106 bool IsHardwareBacked(const net::X509Certificate* cert) const; | 107 bool IsHardwareBacked(const net::X509Certificate* cert) const; |
107 | 108 |
108 private: | 109 private: |
109 // Callback used by Refresh() for when the cert slots have been unlocked. | 110 // Callback used by Refresh() for when the cert slots have been unlocked. |
110 // This method does the actual refreshing. | 111 // This method does the actual refreshing. |
111 void RefreshSlotsUnlocked(); | 112 void RefreshSlotsUnlocked(); |
112 | 113 |
113 net::CertDatabase cert_db_; | 114 net::CertDatabase cert_db_; |
114 net::CertificateList cert_list_; | 115 net::CertificateList cert_list_; |
115 | 116 |
116 // The observer to notify when certificate list is refreshed. | 117 // The observer to notify when certificate list is refreshed. |
117 Observer* observer_; | 118 Observer* observer_; |
118 | 119 |
119 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); | 120 DISALLOW_COPY_AND_ASSIGN(CertificateManagerModel); |
120 }; | 121 }; |
121 | 122 |
122 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ | 123 #endif // CHROME_BROWSER_CERTIFICATE_MANAGER_MODEL_H_ |
OLD | NEW |