| Index: chromeos/network/client_cert_util.cc
|
| diff --git a/chromeos/network/client_cert_util.cc b/chromeos/network/client_cert_util.cc
|
| index 536d5787b43430bd24d5f174f2b2b9ae9cfd4cc3..57eb4fda1de14cf3679185df5fd83f1fd98150bb 100644
|
| --- a/chromeos/network/client_cert_util.cc
|
| +++ b/chromeos/network/client_cert_util.cc
|
| @@ -14,6 +14,7 @@
|
| #include "base/values.h"
|
| #include "chromeos/network/certificate_pattern.h"
|
| #include "chromeos/network/network_event_log.h"
|
| +#include "components/onc/onc_constants.h"
|
| #include "net/base/net_errors.h"
|
| #include "net/cert/cert_database.h"
|
| #include "net/cert/nss_cert_database.h"
|
| @@ -101,6 +102,24 @@ std::string GetStringFromDictionary(const base::DictionaryValue& dict,
|
| return s;
|
| }
|
|
|
| +void GetClientCertTypeAndPattern(
|
| + const base::DictionaryValue& dict_with_client_cert,
|
| + ClientCertConfig* cert_config) {
|
| + using namespace ::onc::client_cert;
|
| + dict_with_client_cert.GetStringWithoutPathExpansion(
|
| + kClientCertType, &cert_config->client_cert_type);
|
| +
|
| + if (cert_config->client_cert_type == kPattern) {
|
| + const base::DictionaryValue* pattern = NULL;
|
| + dict_with_client_cert.GetDictionaryWithoutPathExpansion(kClientCertPattern,
|
| + &pattern);
|
| + if (pattern) {
|
| + bool success = cert_config->pattern.ReadFromONCDictionary(*pattern);
|
| + DCHECK(success);
|
| + }
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| // Returns true only if any fields set in this pattern match exactly with
|
| @@ -199,7 +218,7 @@ scoped_refptr<net::X509Certificate> GetCertificateMatch(
|
| return latest;
|
| }
|
|
|
| -void SetShillProperties(const client_cert::ConfigType cert_config_type,
|
| +void SetShillProperties(const ConfigType cert_config_type,
|
| const std::string& tpm_slot,
|
| const std::string& tpm_pin,
|
| const std::string* pkcs11_id,
|
| @@ -258,7 +277,67 @@ void SetShillProperties(const client_cert::ConfigType cert_config_type,
|
| properties->SetStringWithoutPathExpansion(tpm_pin_property, tpm_pin);
|
| }
|
|
|
| -bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type,
|
| +ClientCertConfig::ClientCertConfig()
|
| + : location(CONFIG_TYPE_NONE),
|
| + client_cert_type(onc::client_cert::kClientCertTypeNone) {
|
| +}
|
| +
|
| +void OncToClientCertConfig(const base::DictionaryValue& network_config,
|
| + ClientCertConfig* cert_config) {
|
| + using namespace ::onc;
|
| +
|
| + *cert_config = ClientCertConfig();
|
| +
|
| + const base::DictionaryValue* dict_with_client_cert = NULL;
|
| +
|
| + const base::DictionaryValue* wifi = NULL;
|
| + network_config.GetDictionaryWithoutPathExpansion(network_config::kWiFi,
|
| + &wifi);
|
| + if (wifi) {
|
| + const base::DictionaryValue* eap = NULL;
|
| + wifi->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
|
| + if (!eap)
|
| + return;
|
| +
|
| + dict_with_client_cert = eap;
|
| + cert_config->location = CONFIG_TYPE_EAP;
|
| + }
|
| +
|
| + const base::DictionaryValue* vpn = NULL;
|
| + network_config.GetDictionaryWithoutPathExpansion(network_config::kVPN, &vpn);
|
| + if (vpn) {
|
| + const base::DictionaryValue* openvpn = NULL;
|
| + vpn->GetDictionaryWithoutPathExpansion(vpn::kOpenVPN, &openvpn);
|
| + const base::DictionaryValue* ipsec = NULL;
|
| + vpn->GetDictionaryWithoutPathExpansion(vpn::kIPsec, &ipsec);
|
| + if (openvpn) {
|
| + dict_with_client_cert = openvpn;
|
| + cert_config->location = CONFIG_TYPE_OPENVPN;
|
| + } else if (ipsec) {
|
| + dict_with_client_cert = ipsec;
|
| + cert_config->location = CONFIG_TYPE_IPSEC;
|
| + } else {
|
| + return;
|
| + }
|
| + }
|
| +
|
| + const base::DictionaryValue* ethernet = NULL;
|
| + network_config.GetDictionaryWithoutPathExpansion(network_config::kEthernet,
|
| + ðernet);
|
| + if (ethernet) {
|
| + const base::DictionaryValue* eap = NULL;
|
| + ethernet->GetDictionaryWithoutPathExpansion(wifi::kEAP, &eap);
|
| + if (!eap)
|
| + return;
|
| + dict_with_client_cert = eap;
|
| + cert_config->location = CONFIG_TYPE_EAP;
|
| + }
|
| +
|
| + if (dict_with_client_cert)
|
| + GetClientCertTypeAndPattern(*dict_with_client_cert, cert_config);
|
| +}
|
| +
|
| +bool IsCertificateConfigured(const ConfigType cert_config_type,
|
| const base::DictionaryValue& service_properties) {
|
| // VPN certificate properties are read from the Provider dictionary.
|
| const base::DictionaryValue* provider_properties = NULL;
|
|
|