Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/network/client_cert_util.h" | 5 #include "chromeos/network/client_cert_util.h" |
| 6 | 6 |
| 7 #include <cert.h> | 7 #include <cert.h> |
| 8 #include <pk11pub.h> | 8 #include <pk11pub.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 84 } | 84 } |
| 85 | 85 |
| 86 return (std::find(issuer_ca_pems_.begin(), issuer_ca_pems_.end(), | 86 return (std::find(issuer_ca_pems_.begin(), issuer_ca_pems_.end(), |
| 87 pem_encoded) == | 87 pem_encoded) == |
| 88 issuer_ca_pems_.end()); | 88 issuer_ca_pems_.end()); |
| 89 } | 89 } |
| 90 private: | 90 private: |
| 91 const std::vector<std::string>& issuer_ca_pems_; | 91 const std::vector<std::string>& issuer_ca_pems_; |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 std::string GetStringFromDictionary(const base::DictionaryValue& dict, | |
| 95 const std::string& key) { | |
| 96 std::string s; | |
| 97 dict.GetStringWithoutPathExpansion(key, &s); | |
| 98 return s; | |
| 99 } | |
| 100 | |
| 94 } // namespace | 101 } // namespace |
| 95 | 102 |
| 96 // Returns true only if any fields set in this pattern match exactly with | 103 // Returns true only if any fields set in this pattern match exactly with |
| 97 // similar fields in the principal. If organization_ or organizational_unit_ | 104 // similar fields in the principal. If organization_ or organizational_unit_ |
| 98 // are set, then at least one of the organizations or units in the principal | 105 // are set, then at least one of the organizations or units in the principal |
| 99 // must match. | 106 // must match. |
| 100 bool CertPrincipalMatches(const IssuerSubjectPattern& pattern, | 107 bool CertPrincipalMatches(const IssuerSubjectPattern& pattern, |
| 101 const net::CertPrincipal& principal) { | 108 const net::CertPrincipal& principal) { |
| 102 if (!pattern.common_name().empty() && | 109 if (!pattern.common_name().empty() && |
| 103 pattern.common_name() != principal.common_name) { | 110 pattern.common_name() != principal.common_name) { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 *pkcs11_id); | 238 *pkcs11_id); |
| 232 } | 239 } |
| 233 break; | 240 break; |
| 234 } | 241 } |
| 235 } | 242 } |
| 236 DCHECK(tpm_pin_property); | 243 DCHECK(tpm_pin_property); |
| 237 if (!tpm_pin.empty()) | 244 if (!tpm_pin.empty()) |
| 238 properties->SetStringWithoutPathExpansion(tpm_pin_property, tpm_pin); | 245 properties->SetStringWithoutPathExpansion(tpm_pin_property, tpm_pin); |
| 239 } | 246 } |
| 240 | 247 |
| 248 bool IsCertificateConfigured(const client_cert::ConfigType cert_config_type, | |
| 249 const base::DictionaryValue& service_properties) { | |
| 250 // VPN certificate properties are read from the Provider dictionary. | |
| 251 const base::DictionaryValue* provider_properties = NULL; | |
| 252 service_properties.GetDictionaryWithoutPathExpansion( | |
| 253 flimflam::kProviderProperty, &provider_properties); | |
| 254 switch (cert_config_type) { | |
| 255 case CONFIG_TYPE_NONE: | |
| 256 return true; | |
| 257 case CONFIG_TYPE_OPENVPN: { | |
| 258 if (!provider_properties) | |
| 259 return false; | |
| 260 std::string cert_id = GetStringFromDictionary( | |
| 261 *provider_properties, flimflam::kOpenVPNClientCertIdProperty); | |
| 262 std::string username = GetStringFromDictionary( | |
| 263 *provider_properties, flimflam::kOpenVPNUserProperty); | |
|
pneubeck (no reviews)
2013/08/31 05:31:30
I'm find it irritating that here Username is check
stevenjb
2013/09/03 22:33:05
TPM Pin is something configured by Chrome, so it d
| |
| 264 return !cert_id.empty() && !username.empty(); | |
| 265 } | |
| 266 case CONFIG_TYPE_IPSEC: { | |
| 267 if (!provider_properties) | |
| 268 return false; | |
| 269 std::string cert_id = GetStringFromDictionary( | |
| 270 *provider_properties, flimflam::kL2tpIpsecClientCertIdProperty); | |
| 271 std::string username = GetStringFromDictionary( | |
|
pneubeck (no reviews)
2013/08/31 05:31:30
and here, tpm pin + slot instead of username.
Is
stevenjb
2013/09/03 22:33:05
This isn't really intended to be the opposite of S
pneubeck (no reviews)
2013/09/04 08:40:00
AFAIU, VPNs can be setup without Username or witho
stevenjb
2013/09/04 17:58:13
Until/unless Shill sets 'Configured' properly, all
| |
| 272 *provider_properties, flimflam::kL2tpIpsecUserProperty); | |
| 273 return !cert_id.empty() && !username.empty(); | |
| 274 } | |
| 275 case CONFIG_TYPE_EAP: { | |
| 276 std::string cert_id = GetStringFromDictionary( | |
| 277 service_properties, flimflam::kEapCertIdProperty); | |
| 278 std::string key_id = GetStringFromDictionary( | |
| 279 service_properties, flimflam::kEapKeyIdProperty); | |
| 280 std::string identity = GetStringFromDictionary( | |
| 281 service_properties, flimflam::kEapIdentityProperty); | |
| 282 return !cert_id.empty() && !key_id.empty() && !identity.empty(); | |
| 283 } | |
| 284 } | |
| 285 NOTREACHED(); | |
| 286 return false; | |
| 287 } | |
| 288 | |
| 241 } // namespace client_cert | 289 } // namespace client_cert |
| 242 | 290 |
| 243 } // namespace chromeos | 291 } // namespace chromeos |
| OLD | NEW |