| OLD | NEW |
| 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 #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 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 // This class provides functions to manipulate the local | 23 // This class provides functions to manipulate the local |
| 24 // certificate store. | 24 // certificate store. |
| 25 | 25 |
| 26 // TODO(gauravsh): This class could be augmented with methods | 26 // TODO(gauravsh): This class could be augmented with methods |
| 27 // for all operations that manipulate the underlying system | 27 // for all operations that manipulate the underlying system |
| 28 // certificate store. | 28 // certificate store. |
| 29 | 29 |
| 30 class CertDatabase { | 30 class CertDatabase { |
| 31 public: | 31 public: |
| 32 // Stores per-certificate error codes for import failures. |
| 33 struct ImportCertFailure { |
| 34 public: |
| 35 ImportCertFailure(X509Certificate* cert, int err); |
| 36 ~ImportCertFailure(); |
| 37 |
| 38 scoped_refptr<X509Certificate> certificate; |
| 39 int net_error; |
| 40 }; |
| 41 typedef std::vector<ImportCertFailure> ImportCertFailureList; |
| 42 |
| 32 // Constants that define which usages a certificate is trusted for. | 43 // Constants that define which usages a certificate is trusted for. |
| 33 // They are used in combination with CertType to specify trust for each type | 44 // They are used in combination with CertType to specify trust for each type |
| 34 // of certificate. | 45 // of certificate. |
| 35 // For a CA_CERT, they specify that the CA is trusted for issuing server and | 46 // For a CA_CERT, they specify that the CA is trusted for issuing server and |
| 36 // client certs of each type. | 47 // client certs of each type. |
| 37 // For SERVER_CERT, only TRUSTED_SSL makes sense, and specifies the cert is | 48 // For SERVER_CERT, only TRUSTED_SSL makes sense, and specifies the cert is |
| 38 // trusted as a server. | 49 // trusted as a server. |
| 39 // For EMAIL_CERT, only TRUSTED_EMAIL makes sense, and specifies the cert is | 50 // For EMAIL_CERT, only TRUSTED_EMAIL makes sense, and specifies the cert is |
| 40 // trusted for email. | 51 // trusted for email. |
| 41 enum { | 52 enum { |
| 42 UNTRUSTED = 0, | 53 UNTRUSTED = 0, |
| 43 TRUSTED_SSL = 1 << 0, | 54 TRUSTED_SSL = 1 << 0, |
| 44 TRUSTED_EMAIL = 1 << 1, | 55 TRUSTED_EMAIL = 1 << 1, |
| 45 TRUSTED_OBJ_SIGN = 1 << 2, | 56 TRUSTED_OBJ_SIGN = 1 << 2, |
| 46 }; | 57 }; |
| 47 | 58 |
| 48 // Stores per-certificate error codes for import failures. | |
| 49 struct ImportCertFailure { | |
| 50 public: | |
| 51 ImportCertFailure(X509Certificate* cert, int err); | |
| 52 ~ImportCertFailure(); | |
| 53 | |
| 54 scoped_refptr<X509Certificate> certificate; | |
| 55 int net_error; | |
| 56 }; | |
| 57 typedef std::vector<ImportCertFailure> ImportCertFailureList; | |
| 58 | |
| 59 CertDatabase(); | 59 CertDatabase(); |
| 60 | 60 |
| 61 // Check whether this is a valid user cert that we have the private key for. | 61 // Check whether this is a valid user cert that we have the private key for. |
| 62 // Returns OK or a network error code such as ERR_CERT_CONTAINS_ERRORS. | 62 // Returns OK or a network error code such as ERR_CERT_CONTAINS_ERRORS. |
| 63 int CheckUserCert(X509Certificate* cert); | 63 int CheckUserCert(X509Certificate* cert); |
| 64 | 64 |
| 65 // Store user (client) certificate. Assumes CheckUserCert has already passed. | 65 // Store user (client) certificate. Assumes CheckUserCert has already passed. |
| 66 // Returns OK, or ERR_ADD_USER_CERT_FAILED if there was a problem saving to | 66 // Returns OK, or ERR_ADD_USER_CERT_FAILED if there was a problem saving to |
| 67 // the platform cert database, or possibly other network error codes. | 67 // the platform cert database, or possibly other network error codes. |
| 68 int AddUserCert(X509Certificate* cert); | 68 int AddUserCert(X509Certificate* cert); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 bool IsReadOnly(const X509Certificate* cert) const; | 129 bool IsReadOnly(const X509Certificate* cert) const; |
| 130 #endif | 130 #endif |
| 131 | 131 |
| 132 private: | 132 private: |
| 133 DISALLOW_COPY_AND_ASSIGN(CertDatabase); | 133 DISALLOW_COPY_AND_ASSIGN(CertDatabase); |
| 134 }; | 134 }; |
| 135 | 135 |
| 136 } // namespace net | 136 } // namespace net |
| 137 | 137 |
| 138 #endif // NET_BASE_CERT_DATABASE_H_ | 138 #endif // NET_BASE_CERT_DATABASE_H_ |
| OLD | NEW |