Index: chrome/browser/chromeos/cros/cert_library.cc |
diff --git a/chrome/browser/chromeos/cros/cert_library.cc b/chrome/browser/chromeos/cros/cert_library.cc |
index 736d6cb0642dc41b2d70ecbecdbeef18c56e4ee9..bb8cf70aea66c91a8cb49ad987fc7330a20bb2ba 100644 |
--- a/chrome/browser/chromeos/cros/cert_library.cc |
+++ b/chrome/browser/chromeos/cros/cert_library.cc |
@@ -19,6 +19,7 @@ |
#include "chromeos/dbus/cryptohome_client.h" |
#include "chromeos/dbus/dbus_thread_manager.h" |
#include "chromeos/login/login_state.h" |
+#include "chromeos/network/onc/onc_utils.h" |
#include "content/public/browser/browser_thread.h" |
#include "crypto/nss_util.h" |
#include "grit/generated_resources.h" |
@@ -148,9 +149,9 @@ string16 CertLibrary::GetCertDisplayStringAt(CertType type, int index) const { |
return GetDisplayString(cert, hardware_backed); |
} |
-std::string CertLibrary::GetCertNicknameAt(CertType type, int index) const { |
+std::string CertLibrary::GetCertFingerprintAt(CertType type, int index) const { |
net::X509Certificate* cert = GetCertificateAt(type, index); |
- return x509_certificate_model::GetNickname(cert->os_cert_handle()); |
+ return onc::GetHexFingerprintOfCert(*cert); |
} |
std::string CertLibrary::GetCertPkcs11IdAt(CertType type, int index) const { |
@@ -168,17 +169,22 @@ bool CertLibrary::IsCertHardwareBackedAt(CertType type, int index) const { |
NetworkHandler::Get()->cert_loader()->tpm_token_name(); |
} |
-int CertLibrary::GetCertIndexByNickname(CertType type, |
- const std::string& nickname) const { |
+int CertLibrary::GetCertIndexByFingerprint( |
+ CertType type, |
+ const std::string& fingerprint) const { |
int num_certs = NumCertificates(type); |
+ int found_index = -1; |
for (int index = 0; index < num_certs; ++index) { |
net::X509Certificate* cert = GetCertificateAt(type, index); |
- net::X509Certificate::OSCertHandle cert_handle = cert->os_cert_handle(); |
- std::string nick = x509_certificate_model::GetNickname(cert_handle); |
- if (nick == nickname) |
- return index; |
+ if (onc::GetHexFingerprintOfCert(*cert) != fingerprint) |
+ continue; |
+ if (found_index != -1) { |
+ LOG(ERROR) << "Fingerprint not unique in list."; |
+ return -1; |
+ } |
+ found_index = index; |
} |
- return -1; // Not found. |
+ return found_index; |
} |
int CertLibrary::GetCertIndexByPkcs11Id(CertType type, |
@@ -272,4 +278,4 @@ const net::CertificateList& CertLibrary::GetCertificateListForType( |
return certs_; |
} |
-} // chromeos |
+} // namespace chromeos |