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 NET_BASE_CERT_DATABASE_H_ | 5 #ifndef NET_BASE_CERT_DATABASE_H_ |
6 #define NET_BASE_CERT_DATABASE_H_ | 6 #define NET_BASE_CERT_DATABASE_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 | 73 |
74 // Constants that define which usages a certificate is trusted for. | 74 // Constants that define which usages a certificate is trusted for. |
75 // They are used in combination with CertType to specify trust for each type | 75 // They are used in combination with CertType to specify trust for each type |
76 // of certificate. | 76 // of certificate. |
77 // For a CA_CERT, they specify that the CA is trusted for issuing server and | 77 // For a CA_CERT, they specify that the CA is trusted for issuing server and |
78 // client certs of each type. | 78 // client certs of each type. |
79 // For SERVER_CERT, only TRUSTED_SSL makes sense, and specifies the cert is | 79 // For SERVER_CERT, only TRUSTED_SSL makes sense, and specifies the cert is |
80 // trusted as a server. | 80 // trusted as a server. |
81 // For EMAIL_CERT, only TRUSTED_EMAIL makes sense, and specifies the cert is | 81 // For EMAIL_CERT, only TRUSTED_EMAIL makes sense, and specifies the cert is |
82 // trusted for email. | 82 // trusted for email. |
83 // EXPLICIT_DISTRUST specifies that the cert should not be trusted, regardless | |
84 // of whether it would otherwise inherit trust from the issuer chain. | |
wtc
2012/05/16 23:37:12
The difference between UNTRUSTED and EXPLICIT_DIST
mattm
2012/05/18 03:40:54
Done.
| |
83 // NOTE: The actual constants are defined using an enum instead of static | 85 // NOTE: The actual constants are defined using an enum instead of static |
84 // consts due to compilation/linkage constraints with template functions. | 86 // consts due to compilation/linkage constraints with template functions. |
85 typedef uint32 TrustBits; | 87 typedef uint32 TrustBits; |
86 enum { | 88 enum { |
87 UNTRUSTED = 0, | 89 UNTRUSTED = 0, |
88 TRUSTED_SSL = 1 << 0, | 90 TRUSTED_SSL = 1 << 0, |
89 TRUSTED_EMAIL = 1 << 1, | 91 TRUSTED_EMAIL = 1 << 1, |
90 TRUSTED_OBJ_SIGN = 1 << 2, | 92 TRUSTED_OBJ_SIGN = 1 << 2, |
93 EXPLICIT_DISTRUST = 1 << 3, | |
91 }; | 94 }; |
92 | 95 |
93 CertDatabase(); | 96 CertDatabase(); |
94 | 97 |
95 // Check whether this is a valid user cert that we have the private key for. | 98 // Check whether this is a valid user cert that we have the private key for. |
96 // Returns OK or a network error code such as ERR_CERT_CONTAINS_ERRORS. | 99 // Returns OK or a network error code such as ERR_CERT_CONTAINS_ERRORS. |
97 int CheckUserCert(X509Certificate* cert); | 100 int CheckUserCert(X509Certificate* cert); |
98 | 101 |
99 // Store user (client) certificate. Assumes CheckUserCert has already passed. | 102 // Store user (client) certificate. Assumes CheckUserCert has already passed. |
100 // Returns OK, or ERR_ADD_USER_CERT_FAILED if there was a problem saving to | 103 // Returns OK, or ERR_ADD_USER_CERT_FAILED if there was a problem saving to |
101 // the platform cert database, or possibly other network error codes. | 104 // the platform cert database, or possibly other network error codes. |
102 int AddUserCert(X509Certificate* cert); | 105 int AddUserCert(X509Certificate* cert); |
103 | 106 |
104 #if defined(USE_NSS) || defined(USE_OPENSSL) | 107 #if defined(USE_NSS) |
105 // Get a list of unique certificates in the certificate database (one | 108 // Get a list of unique certificates in the certificate database (one |
106 // instance of all certificates). | 109 // instance of all certificates). |
107 void ListCerts(CertificateList* certs); | 110 void ListCerts(CertificateList* certs); |
108 | 111 |
109 // Get the default module for public key data. | 112 // Get the default module for public key data. |
110 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. | 113 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. |
111 CryptoModule* GetPublicModule() const; | 114 CryptoModule* GetPublicModule() const; |
112 | 115 |
113 // Get the default module for private key or mixed private/public key data. | 116 // Get the default module for private key or mixed private/public key data. |
114 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. | 117 // The returned pointer must be stored in a scoped_refptr<CryptoModule>. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 // will be listed in |not_imported|. | 151 // will be listed in |not_imported|. |
149 // Returns false if there is an internal error, otherwise true is returned and | 152 // Returns false if there is an internal error, otherwise true is returned and |
150 // |not_imported| should be checked for any certificates that were not | 153 // |not_imported| should be checked for any certificates that were not |
151 // imported. | 154 // imported. |
152 bool ImportCACerts(const CertificateList& certificates, | 155 bool ImportCACerts(const CertificateList& certificates, |
153 TrustBits trust_bits, | 156 TrustBits trust_bits, |
154 ImportCertFailureList* not_imported); | 157 ImportCertFailureList* not_imported); |
155 | 158 |
156 // Import server certificate. The first cert should be the server cert. Any | 159 // Import server certificate. The first cert should be the server cert. Any |
157 // additional certs should be intermediate/CA certs and will be imported but | 160 // additional certs should be intermediate/CA certs and will be imported but |
158 // not given any trust. | 161 // not given any trust. |
wtc
2012/05/16 23:37:12
The new trust_bits parameter should be documented.
mattm
2012/05/18 03:40:54
When using the "import" option in the server tab o
| |
159 // Any certificates that could not be imported will be listed in | 162 // Any certificates that could not be imported will be listed in |
160 // |not_imported|. | 163 // |not_imported|. |
161 // Returns false if there is an internal error, otherwise true is returned and | 164 // Returns false if there is an internal error, otherwise true is returned and |
162 // |not_imported| should be checked for any certificates that were not | 165 // |not_imported| should be checked for any certificates that were not |
163 // imported. | 166 // imported. |
164 bool ImportServerCert(const CertificateList& certificates, | 167 bool ImportServerCert(const CertificateList& certificates, |
168 TrustBits trust_bits, | |
165 ImportCertFailureList* not_imported); | 169 ImportCertFailureList* not_imported); |
166 | 170 |
167 // Get trust bits for certificate. | 171 // Get trust bits for certificate. |
168 TrustBits GetCertTrust(const X509Certificate* cert, CertType type) const; | 172 TrustBits GetCertTrust(const X509Certificate* cert, CertType type) const; |
169 | 173 |
170 // IsUntrusted returns true if |cert| is specifically untrusted. These | 174 // IsUntrusted returns true if |cert| is specifically untrusted. These |
171 // certificates are stored in the database for the specific purpose of | 175 // certificates are stored in the database for the specific purpose of |
172 // rejecting them. | 176 // rejecting them. |
173 bool IsUntrusted(const X509Certificate* cert) const; | 177 bool IsUntrusted(const X509Certificate* cert) const; |
174 | 178 |
(...skipping 26 matching lines...) Expand all Loading... | |
201 static void NotifyObserversOfUserCertAdded(const X509Certificate* cert); | 205 static void NotifyObserversOfUserCertAdded(const X509Certificate* cert); |
202 static void NotifyObserversOfUserCertRemoved(const X509Certificate* cert); | 206 static void NotifyObserversOfUserCertRemoved(const X509Certificate* cert); |
203 static void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); | 207 static void NotifyObserversOfCertTrustChanged(const X509Certificate* cert); |
204 | 208 |
205 DISALLOW_COPY_AND_ASSIGN(CertDatabase); | 209 DISALLOW_COPY_AND_ASSIGN(CertDatabase); |
206 }; | 210 }; |
207 | 211 |
208 } // namespace net | 212 } // namespace net |
209 | 213 |
210 #endif // NET_BASE_CERT_DATABASE_H_ | 214 #endif // NET_BASE_CERT_DATABASE_H_ |
OLD | NEW |