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

Side by Side Diff: components/cronet/ios/cronet_environment.mm

Issue 2928653002: [Cronet-iOS] Public-Key-Pinning Tests (Closed)
Patch Set: Addressed Lily's comments. Created 3 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/cronet/ios/cronet_environment.h" 5 #include "components/cronet/ios/cronet_environment.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/atomicops.h" 10 #include "base/atomicops.h"
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 cache_path.value(); // Storage path for http cache and cookie storage. 293 cache_path.value(); // Storage path for http cache and cookie storage.
294 context_config_builder.user_agent = 294 context_config_builder.user_agent =
295 user_agent_; // User-Agent request header field. 295 user_agent_; // User-Agent request header field.
296 context_config_builder.experimental_options = 296 context_config_builder.experimental_options =
297 experimental_options_; // Set experimental Cronet options. 297 experimental_options_; // Set experimental Cronet options.
298 context_config_builder.mock_cert_verifier = std::move( 298 context_config_builder.mock_cert_verifier = std::move(
299 mock_cert_verifier_); // MockCertVerifier to use for testing purposes. 299 mock_cert_verifier_); // MockCertVerifier to use for testing purposes.
300 std::unique_ptr<URLRequestContextConfig> config = 300 std::unique_ptr<URLRequestContextConfig> config =
301 context_config_builder.Build(); 301 context_config_builder.Build();
302 302
303 config->pkp_list = std::move(pkp_list_);
304
303 net::URLRequestContextBuilder context_builder; 305 net::URLRequestContextBuilder context_builder;
304 306
305 context_builder.set_accept_language(accept_language_); 307 context_builder.set_accept_language(accept_language_);
306 308
309 // Explicitly disable the persister for Cronet to avoid persistence of dynamic
310 // HPKP. This is a safety measure ensuring that nobody enables the
311 // persistence of HPKP by specifying transport_security_persister_path in the
312 // future.
313 context_builder.set_transport_security_persister_path(base::FilePath());
314
307 config->ConfigureURLRequestContextBuilder(&context_builder, net_log_.get(), 315 config->ConfigureURLRequestContextBuilder(&context_builder, net_log_.get(),
308 file_thread_.get()->task_runner()); 316 file_thread_.get()->task_runner());
309 317
310 std::unique_ptr<net::MappedHostResolver> mapped_host_resolver( 318 std::unique_ptr<net::MappedHostResolver> mapped_host_resolver(
311 new net::MappedHostResolver( 319 new net::MappedHostResolver(
312 net::HostResolver::CreateDefaultResolver(nullptr))); 320 net::HostResolver::CreateDefaultResolver(nullptr)));
313 321
314 context_builder.set_host_resolver(std::move(mapped_host_resolver)); 322 context_builder.set_host_resolver(std::move(mapped_host_resolver));
315 323
316 // TODO(690969): This behavior matches previous behavior of CookieStoreIOS in 324 // TODO(690969): This behavior matches previous behavior of CookieStoreIOS in
(...skipping 13 matching lines...) Expand all
330 quic_hint.port()); 338 quic_hint.port());
331 url::SchemeHostPort quic_hint_server("https", quic_hint.host(), 339 url::SchemeHostPort quic_hint_server("https", quic_hint.host(),
332 quic_hint.port()); 340 quic_hint.port());
333 http_server_properties->SetAlternativeService( 341 http_server_properties->SetAlternativeService(
334 quic_hint_server, alternative_service, base::Time::Max()); 342 quic_hint_server, alternative_service, base::Time::Max());
335 } 343 }
336 344
337 context_builder.SetHttpServerProperties(std::move(http_server_properties)); 345 context_builder.SetHttpServerProperties(std::move(http_server_properties));
338 346
339 main_context_ = context_builder.Build(); 347 main_context_ = context_builder.Build();
348
349 // Iterate trhough PKP configuration for every host.
mef 2017/06/12 22:25:23 nit: through (sp)
kapishnikov 2017/06/16 20:11:04 Done.
350 for (auto* const pkp : config->pkp_list) {
351 // Add the host pinning.
352 main_context_->transport_security_state()->AddHPKP(
353 pkp->host, pkp->expiration_date, pkp->include_subdomains,
354 pkp->pin_hashes, GURL::EmptyGURL());
355 }
340 } 356 }
341 357
342 std::string CronetEnvironment::user_agent() { 358 std::string CronetEnvironment::user_agent() {
343 const net::HttpUserAgentSettings* user_agent_settings = 359 const net::HttpUserAgentSettings* user_agent_settings =
344 main_context_->http_user_agent_settings(); 360 main_context_->http_user_agent_settings();
345 if (!user_agent_settings) { 361 if (!user_agent_settings) {
346 return nullptr; 362 return nullptr;
347 } 363 }
348 364
349 return user_agent_settings->GetUserAgent(); 365 return user_agent_settings->GetUserAgent();
(...skipping 25 matching lines...) Expand all
375 event->Signal(); 391 event->Signal();
376 } 392 }
377 393
378 std::string CronetEnvironment::getDefaultQuicUserAgentId() const { 394 std::string CronetEnvironment::getDefaultQuicUserAgentId() const {
379 return base::SysNSStringToUTF8([[NSBundle mainBundle] 395 return base::SysNSStringToUTF8([[NSBundle mainBundle]
380 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) + 396 objectForInfoDictionaryKey:@"CFBundleDisplayName"]) +
381 " Cronet/" + CRONET_VERSION; 397 " Cronet/" + CRONET_VERSION;
382 } 398 }
383 399
384 } // namespace cronet 400 } // namespace cronet
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698