Index: chromeos/network/client_cert_util.cc |
diff --git a/chromeos/network/client_cert_util.cc b/chromeos/network/client_cert_util.cc |
index 57eb4fda1de14cf3679185df5fd83f1fd98150bb..4957e0e5c808d1eef1f55a3636bca0e402a9c38e 100644 |
--- a/chromeos/network/client_cert_util.cc |
+++ b/chromeos/network/client_cert_util.cc |
@@ -218,6 +218,22 @@ scoped_refptr<net::X509Certificate> GetCertificateMatch( |
return latest; |
} |
+std::string GetPkcs11IdFromEapCertId(const std::string& cert_id) { |
+ if (cert_id.empty()) |
+ return std::string(); |
+ |
+ size_t delimiter_pos = cert_id.find(':'); |
+ if (delimiter_pos == std::string::npos) { |
+ // No delimiter found, so |cert_id| only contains the PKCS11 id. |
+ return cert_id; |
+ } |
+ if (delimiter_pos + 1 >= cert_id.size()) { |
+ LOG(ERROR) << "Empty PKCS11 id in cert id."; |
+ return std::string(); |
+ } |
+ return cert_id.substr(delimiter_pos + 1); |
+} |
+ |
void SetShillProperties(const ConfigType cert_config_type, |
const std::string& tpm_slot, |
const std::string& tpm_pin, |