Commit 8564f159 authored by pneubeck@chromium.org's avatar pneubeck@chromium.org

Fix WiFi config view for previously configured client cert.

Before, wifi_config_view expected to read only a plain PKCS#11 ID from the shill::kEapCertIdProperty. However the format changed to '<slot_id>:<key_id>' since the system token is enabled in ChromeOS. This lead to the view not correctly pre-selecting the previously configured certificate.
With this change, the property is correctly parsed and the pre-selection works again for certificates from the user's slot.

BUG=358366, 396181

Review URL: https://codereview.chromium.org/410113002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285806 0039d316-1c4b-4281-b951-d872f2087c98
parent 8e3beab3
......@@ -1295,9 +1295,10 @@ void WifiConfigView::InitFromProperties(
std::string eap_cert_id;
properties.GetStringWithoutPathExpansion(
shill::kEapCertIdProperty, &eap_cert_id);
if (!eap_cert_id.empty()) {
std::string pkcs11_id = client_cert::GetPkcs11IdFromEapCertId(eap_cert_id);
if (!pkcs11_id.empty()) {
int cert_index =
CertLibrary::Get()->GetUserCertIndexByPkcs11Id(eap_cert_id);
CertLibrary::Get()->GetUserCertIndexByPkcs11Id(pkcs11_id);
if (cert_index >= 0)
user_cert_combobox_->SetSelectedIndex(cert_index);
}
......
......@@ -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,
......
......@@ -63,6 +63,11 @@ CHROMEOS_EXPORT scoped_refptr<net::X509Certificate> GetCertificateMatch(
const CertificatePattern& pattern,
const net::CertificateList& all_certs);
// Returns the PKCS11 id part of |cert_id|, which is expected to be the value of
// the Shill property kEapCertIdProperty or kEapKeyIdProperty.
CHROMEOS_EXPORT std::string GetPkcs11IdFromEapCertId(
const std::string& cert_id);
// If not empty, sets the TPM properties in |properties|. If |pkcs11_id| is not
// NULL, also sets the ClientCertID. |cert_config_type| determines which
// dictionary entries to set.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment