Index: net/base/cert_database_nss.cc |
diff --git a/net/base/cert_database_nss.cc b/net/base/cert_database_nss.cc |
index 817372d28e0006e999973ec932dde3abd15a4054..af72579dc6db5a55d241c19dfa9c44737d188159 100644 |
--- a/net/base/cert_database_nss.cc |
+++ b/net/base/cert_database_nss.cc |
@@ -66,27 +66,10 @@ int CertDatabase::AddUserCert(X509Certificate* cert_obj) { |
PK11SlotInfo* slot = NULL; |
std::string nickname; |
- // Create a nickname for this certificate. |
- // We use the scheme used by Firefox: |
- // --> <subject's common name>'s <issuer's common name> ID. |
- |
- std::string username, ca_name; |
- char* temp_username = CERT_GetCommonName(&cert->subject); |
- char* temp_ca_name = CERT_GetCommonName(&cert->issuer); |
- if (temp_username) { |
- username = temp_username; |
- PORT_Free(temp_username); |
- } |
- if (temp_ca_name) { |
- ca_name = temp_ca_name; |
- PORT_Free(temp_ca_name); |
- } |
- nickname = username + "'s " + ca_name + " ID"; |
- |
{ |
crypto::AutoNSSWriteLock lock; |
slot = PK11_ImportCertForKey(cert, |
- const_cast<char*>(nickname.c_str()), |
+ cert_obj->GetLabel().c_str(), |
NULL); |
} |
@@ -113,6 +96,18 @@ void CertDatabase::ListCerts(CertificateList* certs) { |
CERT_DestroyCertList(cert_list); |
} |
+void CertDatabase::ListCertsWithLabel(const std::string& label, |
+ CertificateList* certs) { |
+ ListCerts(certs); |
+ CertificateList new_list; |
+ for (CertificateList::iterator iter = certs->begin(); |
+ iter != certs->end(); ++iter) { |
+ if (iter->get()->GetLabel().find(label) != std::string::npos) |
+ new_list.push_back(*iter); |
+ } |
+ certs->swap(new_list); |
+} |
+ |
CryptoModule* CertDatabase::GetPublicModule() const { |
CryptoModule* module = |
CryptoModule::CreateFromHandle(crypto::GetPublicNSSKeySlot()); |
@@ -161,11 +156,13 @@ int CertDatabase::ImportFromPKCS12( |
CryptoModule* module, |
const std::string& data, |
const string16& password, |
- bool is_extractable) { |
+ bool is_extractable, |
+ net::CertificateList* imported_certs) { |
int result = psm::nsPKCS12Blob_Import(module->os_module_handle(), |
data.data(), data.size(), |
password, |
- is_extractable); |
+ is_extractable, |
+ imported_certs); |
if (result == net::OK) |
CertDatabase::NotifyObserversOfUserCertAdded(NULL); |