Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "base/ref_counted.h" | 14 #include "base/ref_counted.h" |
| 15 #include "net/base/cert_type.h" | 15 #include "net/base/cert_type.h" |
| 16 | 16 |
| 17 namespace net { | 17 namespace net { |
| 18 | 18 |
| 19 class PK11Slot; | |
| 20 typedef std::vector<scoped_refptr<PK11Slot> > PK11SlotList; | |
| 19 class X509Certificate; | 21 class X509Certificate; |
| 20 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; | 22 typedef std::vector<scoped_refptr<X509Certificate> > CertificateList; |
| 21 | 23 |
| 22 | 24 |
| 23 // This class provides functions to manipulate the local | 25 // This class provides functions to manipulate the local |
| 24 // certificate store. | 26 // certificate store. |
| 25 | 27 |
| 26 // TODO(gauravsh): This class could be augmented with methods | 28 // TODO(gauravsh): This class could be augmented with methods |
| 27 // for all operations that manipulate the underlying system | 29 // for all operations that manipulate the underlying system |
| 28 // certificate store. | 30 // certificate store. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 // Store user (client) certificate. Assumes CheckUserCert has already passed. | 67 // 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 | 68 // 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. | 69 // the platform cert database, or possibly other network error codes. |
| 68 int AddUserCert(X509Certificate* cert); | 70 int AddUserCert(X509Certificate* cert); |
| 69 | 71 |
| 70 #if defined(USE_NSS) || defined(USE_OPENSSL) | 72 #if defined(USE_NSS) || defined(USE_OPENSSL) |
| 71 // Get a list of unique certificates in the certificate database. (One | 73 // Get a list of unique certificates in the certificate database. (One |
| 72 // instance of all certificates.) | 74 // instance of all certificates.) |
| 73 void ListCerts(CertificateList* certs); | 75 void ListCerts(CertificateList* certs); |
| 74 | 76 |
| 77 // Get a list of slots containing tokens which can be used for PKCS #12 | |
| 78 // import. | |
| 79 void ListTokensForPKCS12(PK11SlotList* slots) const; | |
|
wtc
2010/12/15 20:54:36
Nit: ListTokensForPKCS12 => ListTokensForPKCS12Imp
mattm
2011/01/12 01:22:07
Done.
| |
| 80 | |
| 75 // Import certificates and private keys from PKCS #12 blob. | 81 // Import certificates and private keys from PKCS #12 blob. |
|
wtc
2010/12/15 20:54:36
Add "into the slot".
mattm
2011/01/12 01:22:07
Done.
| |
| 76 // Returns OK or a network error code such as ERR_PKCS12_IMPORT_BAD_PASSWORD | 82 // Returns OK or a network error code such as ERR_PKCS12_IMPORT_BAD_PASSWORD |
| 77 // or ERR_PKCS12_IMPORT_ERROR. | 83 // or ERR_PKCS12_IMPORT_ERROR. |
| 78 int ImportFromPKCS12(const std::string& data, const string16& password); | 84 int ImportFromPKCS12(net::PK11Slot* slot, |
| 85 const std::string& data, | |
| 86 const string16& password); | |
| 79 | 87 |
| 80 // Export the given certificates and private keys into a PKCS #12 blob, | 88 // Export the given certificates and private keys into a PKCS #12 blob, |
| 81 // storing into |output|. | 89 // storing into |output|. |
| 82 // Returns the number of certificates successfully exported. | 90 // Returns the number of certificates successfully exported. |
| 83 int ExportToPKCS12(const CertificateList& certs, const string16& password, | 91 int ExportToPKCS12(const CertificateList& certs, const string16& password, |
| 84 std::string* output) const; | 92 std::string* output) const; |
| 85 | 93 |
| 86 // Uses similar logic to nsNSSCertificateDB::handleCACertDownload to find the | 94 // Uses similar logic to nsNSSCertificateDB::handleCACertDownload to find the |
| 87 // root. Assumes the list is an ordered hierarchy with the root being either | 95 // root. Assumes the list is an ordered hierarchy with the root being either |
| 88 // the first or last element. | 96 // the first or last element. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 bool IsReadOnly(const X509Certificate* cert) const; | 137 bool IsReadOnly(const X509Certificate* cert) const; |
| 130 #endif | 138 #endif |
| 131 | 139 |
| 132 private: | 140 private: |
| 133 DISALLOW_COPY_AND_ASSIGN(CertDatabase); | 141 DISALLOW_COPY_AND_ASSIGN(CertDatabase); |
| 134 }; | 142 }; |
| 135 | 143 |
| 136 } // namespace net | 144 } // namespace net |
| 137 | 145 |
| 138 #endif // NET_BASE_CERT_DATABASE_H_ | 146 #endif // NET_BASE_CERT_DATABASE_H_ |
| OLD | NEW |