Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: chrome/browser/chromeos/cros/network_library.cc

Issue 16946002: Resolve certificate references in ONC by PEM. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix trust update. Add a utils test. Remove X509 dependency from Shill parsing. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/chromeos/cros/network_library.h" 5 #include "chrome/browser/chromeos/cros/network_library.h"
6 6
7 #include "base/i18n/icu_encoding_detection.h" 7 #include "base/i18n/icu_encoding_detection.h"
8 #include "base/i18n/icu_string_conversions.h" 8 #include "base/i18n/icu_string_conversions.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/json/json_writer.h" // for debug output only. 10 #include "base/json/json_writer.h" // for debug output only.
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversion_utils.h" 12 #include "base/strings/utf_string_conversion_utils.h"
13 #include "chrome/browser/chromeos/cros/cros_library.h" 13 #include "chrome/browser/chromeos/cros/cros_library.h"
14 #include "chrome/browser/chromeos/cros/native_network_constants.h" 14 #include "chrome/browser/chromeos/cros/native_network_constants.h"
15 #include "chrome/browser/chromeos/cros/native_network_parser.h" 15 #include "chrome/browser/chromeos/cros/native_network_parser.h"
16 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h" 16 #include "chrome/browser/chromeos/cros/network_library_impl_cros.h"
17 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h" 17 #include "chrome/browser/chromeos/cros/network_library_impl_stub.h"
18 #include "chrome/common/net/x509_certificate_model.h" 18 #include "chrome/common/net/x509_certificate_model.h"
19 #include "chromeos/network/cert_loader.h"
19 #include "chromeos/network/certificate_pattern.h" 20 #include "chromeos/network/certificate_pattern.h"
20 #include "chromeos/network/certificate_pattern_matcher.h" 21 #include "chromeos/network/certificate_pattern_matcher.h"
21 #include "chromeos/network/cros_network_functions.h" 22 #include "chromeos/network/cros_network_functions.h"
22 #include "chromeos/network/network_state_handler.h" 23 #include "chromeos/network/network_state_handler.h"
24 #include "chromeos/network/onc/onc_utils.h"
23 #include "content/public/browser/browser_thread.h" 25 #include "content/public/browser/browser_thread.h"
24 #include "grit/ash_strings.h" 26 #include "grit/ash_strings.h"
25 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
26 #include "net/base/url_util.h" 28 #include "net/base/url_util.h"
27 #include "third_party/cros_system_api/dbus/service_constants.h" 29 #include "third_party/cros_system_api/dbus/service_constants.h"
28 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
29 31
30 using content::BrowserThread; 32 using content::BrowserThread;
31 33
32 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK), 586 provider_type_(PROVIDER_TYPE_L2TP_IPSEC_PSK),
585 // Assume PSK and user passphrase are not available initially 587 // Assume PSK and user passphrase are not available initially
586 psk_passphrase_required_(true), 588 psk_passphrase_required_(true),
587 user_passphrase_required_(true), 589 user_passphrase_required_(true),
588 weak_pointer_factory_(this) { 590 weak_pointer_factory_(this) {
589 } 591 }
590 592
591 VirtualNetwork::~VirtualNetwork() {} 593 VirtualNetwork::~VirtualNetwork() {}
592 594
593 void VirtualNetwork::EraseCredentials() { 595 void VirtualNetwork::EraseCredentials() {
594 WipeString(&ca_cert_nss_); 596 WipeString(&ca_cert_fingerprint_);
595 WipeString(&psk_passphrase_); 597 WipeString(&psk_passphrase_);
596 WipeString(&client_cert_id_); 598 WipeString(&client_cert_id_);
597 WipeString(&user_passphrase_); 599 WipeString(&user_passphrase_);
598 } 600 }
599 601
600 void VirtualNetwork::CalculateUniqueId() { 602 void VirtualNetwork::CalculateUniqueId() {
601 std::string provider_type(ProviderTypeToString(provider_type_)); 603 std::string provider_type(ProviderTypeToString(provider_type_));
602 set_unique_id(provider_type + "|" + server_hostname_); 604 set_unique_id(provider_type + "|" + server_hostname_);
603 } 605 }
604 606
605 bool VirtualNetwork::RequiresUserProfile() const { 607 bool VirtualNetwork::RequiresUserProfile() const {
606 return true; 608 return true;
607 } 609 }
608 610
609 void VirtualNetwork::AttemptConnection(const base::Closure& connect) { 611 void VirtualNetwork::AttemptConnection(const base::Closure& connect) {
610 if (client_cert_type() == CLIENT_CERT_TYPE_PATTERN) { 612 if (client_cert_type() == CLIENT_CERT_TYPE_PATTERN) {
611 MatchCertificatePattern(true, connect); 613 MatchCertificatePattern(true, connect);
612 } else { 614 } else {
613 connect.Run(); 615 connect.Run();
614 } 616 }
615 } 617 }
616 618
617 void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) { 619 void VirtualNetwork::CopyCredentialsFromRemembered(Network* remembered) {
618 CHECK_EQ(remembered->type(), TYPE_VPN); 620 CHECK_EQ(remembered->type(), TYPE_VPN);
619 VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered); 621 VirtualNetwork* remembered_vpn = static_cast<VirtualNetwork*>(remembered);
620 VLOG(1) << "Copy VPN credentials: " << name() 622 VLOG(1) << "Copy VPN credentials: " << name()
621 << " username: " << remembered_vpn->username(); 623 << " username: " << remembered_vpn->username();
622 if (ca_cert_nss_.empty()) 624 if (ca_cert_fingerprint_.empty())
623 ca_cert_nss_ = remembered_vpn->ca_cert_nss(); 625 ca_cert_fingerprint_ = remembered_vpn->ca_cert_fingerprint();
624 if (psk_passphrase_.empty()) 626 if (psk_passphrase_.empty())
625 psk_passphrase_ = remembered_vpn->psk_passphrase(); 627 psk_passphrase_ = remembered_vpn->psk_passphrase();
626 if (client_cert_id_.empty()) 628 if (client_cert_id_.empty())
627 client_cert_id_ = remembered_vpn->client_cert_id(); 629 client_cert_id_ = remembered_vpn->client_cert_id();
628 if (username_.empty()) 630 if (username_.empty())
629 username_ = remembered_vpn->username(); 631 username_ = remembered_vpn->username();
630 if (user_passphrase_.empty()) 632 if (user_passphrase_.empty())
631 user_passphrase_ = remembered_vpn->user_passphrase(); 633 user_passphrase_ = remembered_vpn->user_passphrase();
632 } 634 }
633 635
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 } 706 }
705 707
706 bool VirtualNetwork::IsPSKPassphraseRequired() const { 708 bool VirtualNetwork::IsPSKPassphraseRequired() const {
707 return psk_passphrase_required_ && psk_passphrase_.empty(); 709 return psk_passphrase_required_ && psk_passphrase_.empty();
708 } 710 }
709 711
710 bool VirtualNetwork::IsUserPassphraseRequired() const { 712 bool VirtualNetwork::IsUserPassphraseRequired() const {
711 return user_passphrase_required_ && user_passphrase_.empty(); 713 return user_passphrase_required_ && user_passphrase_.empty();
712 } 714 }
713 715
714 void VirtualNetwork::SetCACertNSS(const std::string& ca_cert_nss) { 716 void VirtualNetwork::SetCACertFingerprint(
715 if (provider_type_ == PROVIDER_TYPE_OPEN_VPN) { 717 const std::string& ca_cert_fingerprint) {
716 SetStringProperty( 718 VLOG(1) << "SetCACertFingerprint " << ca_cert_fingerprint;
717 flimflam::kOpenVPNCaCertNSSProperty, ca_cert_nss, &ca_cert_nss_); 719 std::string pem_encoded_cert = onc::GetPEMEncodedCertFromFingerprint(
718 } else { 720 NetworkHandler::Get()->cert_loader()->cert_list(), ca_cert_fingerprint);
719 SetStringProperty( 721 if (pem_encoded_cert.empty())
stevenjb 2013/06/27 16:50:04 warning or error?
pneubeck (no reviews) 2013/06/28 17:40:06 Done.
720 flimflam::kL2tpIpsecCaCertNssProperty, ca_cert_nss, &ca_cert_nss_); 722 return;
721 } 723
724 ca_cert_fingerprint_ = ca_cert_fingerprint;
725
726 base::ListValue pem_list;
727 pem_list.AppendString(pem_encoded_cert);
728
729 const char* shill_property;
730 if (provider_type_ == PROVIDER_TYPE_OPEN_VPN)
731 shill_property = shill::kOpenVPNCaCertPemProperty;
732 else
733 shill_property = shill::kL2tpIpsecCaCertPemProperty;
734 SetValueProperty(shill_property, pem_list);
722 } 735 }
723 736
724 void VirtualNetwork::SetL2TPIPsecPSKCredentials( 737 void VirtualNetwork::SetL2TPIPsecPSKCredentials(
725 const std::string& psk_passphrase, 738 const std::string& psk_passphrase,
726 const std::string& username, 739 const std::string& username,
727 const std::string& user_passphrase, 740 const std::string& user_passphrase,
728 const std::string& group_name) { 741 const std::string& group_name) {
729 if (!psk_passphrase.empty()) { 742 if (!psk_passphrase.empty()) {
730 SetStringProperty(flimflam::kL2tpIpsecPskProperty, 743 SetStringProperty(flimflam::kL2tpIpsecPskProperty,
731 psk_passphrase, &psk_passphrase_); 744 psk_passphrase, &psk_passphrase_);
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 // Send the change to shill. If the format is valid, it will propagate to 1115 // Send the change to shill. If the format is valid, it will propagate to
1103 // passphrase_ with a service update. 1116 // passphrase_ with a service update.
1104 SetOrClearStringProperty(flimflam::kPassphraseProperty, passphrase, NULL); 1117 SetOrClearStringProperty(flimflam::kPassphraseProperty, passphrase, NULL);
1105 } 1118 }
1106 1119
1107 // See src/third_party/shill/doc/service-api.txt for properties that 1120 // See src/third_party/shill/doc/service-api.txt for properties that
1108 // shill will forget when SaveCredentials is false. 1121 // shill will forget when SaveCredentials is false.
1109 void WifiNetwork::EraseCredentials() { 1122 void WifiNetwork::EraseCredentials() {
1110 WipeString(&passphrase_); 1123 WipeString(&passphrase_);
1111 WipeString(&user_passphrase_); 1124 WipeString(&user_passphrase_);
1125 WipeString(&eap_server_ca_cert_fingerprint_);
1112 WipeString(&eap_client_cert_pkcs11_id_); 1126 WipeString(&eap_client_cert_pkcs11_id_);
1113 WipeString(&eap_identity_); 1127 WipeString(&eap_identity_);
1114 WipeString(&eap_anonymous_identity_); 1128 WipeString(&eap_anonymous_identity_);
1115 WipeString(&eap_passphrase_); 1129 WipeString(&eap_passphrase_);
1116 } 1130 }
1117 1131
1118 void WifiNetwork::SetIdentity(const std::string& identity) { 1132 void WifiNetwork::SetIdentity(const std::string& identity) {
1119 SetStringProperty(flimflam::kIdentityProperty, identity, &identity_); 1133 SetStringProperty(flimflam::kIdentityProperty, identity, &identity_);
1120 } 1134 }
1121 1135
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 SetStringProperty(flimflam::kEapPhase2AuthProperty, 1189 SetStringProperty(flimflam::kEapPhase2AuthProperty,
1176 flimflam::kEapPhase2AuthTTLSPAP, NULL); 1190 flimflam::kEapPhase2AuthTTLSPAP, NULL);
1177 break; 1191 break;
1178 case EAP_PHASE_2_AUTH_CHAP: 1192 case EAP_PHASE_2_AUTH_CHAP:
1179 SetStringProperty(flimflam::kEapPhase2AuthProperty, 1193 SetStringProperty(flimflam::kEapPhase2AuthProperty,
1180 flimflam::kEapPhase2AuthTTLSCHAP, NULL); 1194 flimflam::kEapPhase2AuthTTLSCHAP, NULL);
1181 break; 1195 break;
1182 } 1196 }
1183 } 1197 }
1184 1198
1185 void WifiNetwork::SetEAPServerCaCertNssNickname( 1199 void WifiNetwork::SetEAPServerCaCertFingerprint(
1186 const std::string& nss_nickname) { 1200 const std::string& ca_cert_fingerprint) {
1187 VLOG(1) << "SetEAPServerCaCertNssNickname " << nss_nickname; 1201 VLOG(1) << "SetEAPServerCaCertFingerprint " << ca_cert_fingerprint;
1188 SetOrClearStringProperty(flimflam::kEapCaCertNssProperty, 1202 std::string pem_encoded_cert = onc::GetPEMEncodedCertFromFingerprint(
1189 nss_nickname, &eap_server_ca_cert_nss_nickname_); 1203 NetworkHandler::Get()->cert_loader()->cert_list(), ca_cert_fingerprint);
1204 if (pem_encoded_cert.empty())
stevenjb 2013/06/27 16:50:04 warning or error?
pneubeck (no reviews) 2013/06/28 17:40:06 Done.
1205 return;
1206
1207 eap_server_ca_cert_fingerprint_ = ca_cert_fingerprint;
1208 SetStringProperty(shill::kEapCaCertPemProperty, pem_encoded_cert, NULL);
1190 } 1209 }
1191 1210
1192 void WifiNetwork::SetEAPClientCertPkcs11Id(const std::string& pkcs11_id) { 1211 void WifiNetwork::SetEAPClientCertPkcs11Id(const std::string& pkcs11_id) {
1193 VLOG(1) << "SetEAPClientCertPkcs11Id " << pkcs11_id; 1212 VLOG(1) << "SetEAPClientCertPkcs11Id " << pkcs11_id;
1194 SetOrClearStringProperty( 1213 SetOrClearStringProperty(
1195 flimflam::kEapCertIdProperty, pkcs11_id, &eap_client_cert_pkcs11_id_); 1214 flimflam::kEapCertIdProperty, pkcs11_id, &eap_client_cert_pkcs11_id_);
1196 // shill requires both CertID and KeyID for TLS connections, despite 1215 // shill requires both CertID and KeyID for TLS connections, despite
1197 // the fact that by convention they are the same ID. 1216 // the fact that by convention they are the same ID.
1198 SetOrClearStringProperty(flimflam::kEapKeyIdProperty, pkcs11_id, NULL); 1217 SetOrClearStringProperty(flimflam::kEapKeyIdProperty, pkcs11_id, NULL);
1199 } 1218 }
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 NetworkLibrary* impl; 1417 NetworkLibrary* impl;
1399 if (stub) 1418 if (stub)
1400 impl = new NetworkLibraryImplStub(); 1419 impl = new NetworkLibraryImplStub();
1401 else 1420 else
1402 impl = new NetworkLibraryImplCros(); 1421 impl = new NetworkLibraryImplCros();
1403 impl->Init(); 1422 impl->Init();
1404 return impl; 1423 return impl;
1405 } 1424 }
1406 1425
1407 } // namespace chromeos 1426 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698