Chromium Code Reviews| Index: chrome/common/net/x509_certificate_model_nss.cc |
| diff --git a/chrome/common/net/x509_certificate_model_nss.cc b/chrome/common/net/x509_certificate_model_nss.cc |
| index 3fccdc092e0d82aba8dfc1eeea0d7be1f0a23ce8..c1ee73e36c0aa6b98a100a8b0bd2cb3a954db9c7 100644 |
| --- a/chrome/common/net/x509_certificate_model_nss.cc |
| +++ b/chrome/common/net/x509_certificate_model_nss.cc |
| @@ -71,6 +71,19 @@ std::string ProcessExtension( |
| &extension->value); |
| } |
| +std::string GetNickname(net::X509Certificate::OSCertHandle cert_handle) { |
| + std::string name; |
| + if (cert_handle->nickname) { |
| + name = cert_handle->nickname; |
| + // Hack copied from mozilla: Cut off text before first :, which seems to |
| + // just be the token name. |
| + size_t colon_pos = name.find(':'); |
| + if (colon_pos != std::string::npos) |
| + name = name.substr(colon_pos + 1); |
| + } |
| + return name; |
| +} |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // NSS certificate export functions. |
| @@ -104,19 +117,6 @@ string GetCertNameOrNickname(X509Certificate::OSCertHandle cert_handle) { |
| return GetNickname(cert_handle); |
| } |
| -string GetNickname(X509Certificate::OSCertHandle cert_handle) { |
| - string name; |
| - if (cert_handle->nickname) { |
| - name = cert_handle->nickname; |
| - // Hack copied from mozilla: Cut off text before first :, which seems to |
| - // just be the token name. |
| - size_t colon_pos = name.find(':'); |
| - if (colon_pos != string::npos) |
| - name = name.substr(colon_pos + 1); |
| - } |
| - return name; |
| -} |
| - |
| string GetTokenName(X509Certificate::OSCertHandle cert_handle) { |
| return psm::GetCertTokenName(cert_handle); |
| } |
| @@ -136,28 +136,11 @@ net::CertType GetType(X509Certificate::OSCertHandle cert_handle) { |
| return psm::GetCertType(cert_handle); |
| } |
| -string GetEmailAddress(X509Certificate::OSCertHandle cert_handle) { |
| - if (cert_handle->emailAddr) |
| - return cert_handle->emailAddr; |
| - return std::string(); |
| -} |
| - |
| void GetUsageStrings(X509Certificate::OSCertHandle cert_handle, |
| std::vector<string>* usages) { |
| psm::GetCertUsageStrings(cert_handle, usages); |
| } |
| -string GetKeyUsageString(X509Certificate::OSCertHandle cert_handle) { |
| - SECItem key_usage; |
| - key_usage.data = NULL; |
| - string key_usage_str; |
| - if (CERT_FindKeyUsageExtension(cert_handle, &key_usage) == SECSuccess) { |
| - key_usage_str = psm::ProcessKeyUsageBitString(&key_usage, ','); |
| - PORT_Free(key_usage.data); |
| - } |
| - return key_usage_str; |
| -} |
| - |
| string GetSerialNumberHexified(X509Certificate::OSCertHandle cert_handle, |
| const string& alternative_text) { |
| return Stringize(CERT_Hexify(&cert_handle->serialNumber, true), |
| @@ -218,52 +201,13 @@ string GetSubjectName(X509Certificate::OSCertHandle cert_handle) { |
| return psm::ProcessName(&cert_handle->subject); |
| } |
| -void GetEmailAddresses(X509Certificate::OSCertHandle cert_handle, |
| - std::vector<string>* email_addresses) { |
| - for (const char* addr = CERT_GetFirstEmailAddress(cert_handle); |
| - addr; addr = CERT_GetNextEmailAddress(cert_handle, addr)) { |
| - // The first email addr (from Subject) may be duplicated in Subject |
| - // Alternative Name, so check subsequent addresses are not equal to the |
| - // first one before adding to the list. |
| - if (!email_addresses->size() || (*email_addresses)[0] != addr) |
| - email_addresses->push_back(addr); |
| - } |
| -} |
| - |
| -void GetNicknameStringsFromCertList( |
| - const std::vector<scoped_refptr<X509Certificate> >& certs, |
| - const string& cert_expired, |
| - const string& cert_not_yet_valid, |
| - std::vector<string>* nick_names) { |
| - CERTCertList* cert_list = CERT_NewCertList(); |
| - for (size_t i = 0; i < certs.size(); ++i) { |
| - CERT_AddCertToListTail( |
| - cert_list, |
| - CERT_DupCertificate(certs[i]->os_cert_handle())); |
| - } |
| - // Would like to use CERT_GetCertNicknameWithValidity on each cert |
| - // individually instead of having to build a CERTCertList for this, but that |
| - // function is not exported. |
| - CERTCertNicknames* cert_nicknames = CERT_NicknameStringsFromCertList( |
| - cert_list, |
| - const_cast<char*>(cert_expired.c_str()), |
| - const_cast<char*>(cert_not_yet_valid.c_str())); |
| - DCHECK_EQ(cert_nicknames->numnicknames, |
| - static_cast<int>(certs.size())); |
| - |
| - for (int i = 0; i < cert_nicknames->numnicknames; ++i) |
| - nick_names->push_back(cert_nicknames->nicknames[i]); |
| - |
| - CERT_FreeNicknames(cert_nicknames); |
| - CERT_DestroyCertList(cert_list); |
| -} |
| - |
| void GetExtensions( |
| const string& critical_label, |
| const string& non_critical_label, |
| X509Certificate::OSCertHandle cert_handle, |
| Extensions* extensions) { |
| if (cert_handle->extensions) { |
| + psm::RegisterDynamicOids(); |
|
Ryan Sleevi
2014/05/08 00:34:38
This needs to be called before getting the subject
mattm
2014/05/13 00:57:40
Hm, seems easiest to just move it to GetOIDText, w
|
| for (size_t i = 0; cert_handle->extensions[i] != NULL; ++i) { |
| Extension extension; |
| extension.name = psm::GetOIDText(&cert_handle->extensions[i]->id); |
| @@ -383,8 +327,4 @@ string ProcessRawBitsSignatureWrap(X509Certificate::OSCertHandle cert_handle) { |
| cert_handle->signatureWrap.signature.len); |
| } |
| -void RegisterDynamicOids() { |
| - psm::RegisterDynamicOids(); |
| -} |
| - |
| } // namespace x509_certificate_model |