OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "net/spdy/spdy_test_util_common.h" | 5 #include "net/spdy/spdy_test_util_common.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <cstddef> | 9 #include <cstddef> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/string_split.h" | 16 #include "base/strings/string_split.h" |
17 #include "net/base/host_port_pair.h" | 17 #include "net/base/host_port_pair.h" |
18 #include "net/cert/ct_policy_enforcer.h" | 18 #include "net/cert/ct_policy_enforcer.h" |
| 19 #include "net/cert/ct_policy_status.h" |
19 #include "net/cert/mock_cert_verifier.h" | 20 #include "net/cert/mock_cert_verifier.h" |
20 #include "net/cert/multi_log_ct_verifier.h" | 21 #include "net/cert/multi_log_ct_verifier.h" |
21 #include "net/http/http_cache.h" | 22 #include "net/http/http_cache.h" |
22 #include "net/http/http_network_session.h" | 23 #include "net/http/http_network_session.h" |
23 #include "net/http/http_network_transaction.h" | 24 #include "net/http/http_network_transaction.h" |
24 #include "net/http/http_server_properties_impl.h" | 25 #include "net/http/http_server_properties_impl.h" |
25 #include "net/socket/next_proto.h" | 26 #include "net/socket/next_proto.h" |
26 #include "net/socket/socket_test_util.h" | 27 #include "net/socket/socket_test_util.h" |
27 #include "net/socket/ssl_client_socket.h" | 28 #include "net/socket/ssl_client_socket.h" |
28 #include "net/socket/transport_client_socket_pool.h" | 29 #include "net/socket/transport_client_socket_pool.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 params.spdy_stream_max_recv_window_size = | 394 params.spdy_stream_max_recv_window_size = |
394 session_deps->stream_max_recv_window_size; | 395 session_deps->stream_max_recv_window_size; |
395 params.time_func = session_deps->time_func; | 396 params.time_func = session_deps->time_func; |
396 params.proxy_delegate = session_deps->proxy_delegate.get(); | 397 params.proxy_delegate = session_deps->proxy_delegate.get(); |
397 params.enable_http2_alternative_service_with_different_host = | 398 params.enable_http2_alternative_service_with_different_host = |
398 session_deps->enable_http2_alternative_service_with_different_host; | 399 session_deps->enable_http2_alternative_service_with_different_host; |
399 params.net_log = session_deps->net_log; | 400 params.net_log = session_deps->net_log; |
400 return params; | 401 return params; |
401 } | 402 } |
402 | 403 |
| 404 class AllowAnyCertCTPolicyEnforcer : public CTPolicyEnforcer { |
| 405 public: |
| 406 AllowAnyCertCTPolicyEnforcer(){}; |
| 407 ~AllowAnyCertCTPolicyEnforcer() override = default; |
| 408 |
| 409 ct::CertPolicyCompliance DoesConformToCertPolicy( |
| 410 X509Certificate* cert, |
| 411 const SCTList& verified_scts, |
| 412 const BoundNetLog& net_log) override { |
| 413 return ct::CertPolicyCompliance::CERT_POLICY_COMPLIES_VIA_SCTS; |
| 414 } |
| 415 |
| 416 ct::EVPolicyCompliance DoesConformToCTEVPolicy( |
| 417 X509Certificate* cert, |
| 418 const ct::EVCertsWhitelist* ev_whitelist, |
| 419 const SCTList& verified_scts, |
| 420 const BoundNetLog& net_log) override { |
| 421 return ct::EVPolicyCompliance::EV_POLICY_COMPLIES_VIA_SCTS; |
| 422 } |
| 423 }; |
| 424 |
| 425 class IgnoresCTVerifier : public net::CTVerifier { |
| 426 public: |
| 427 IgnoresCTVerifier() = default; |
| 428 ~IgnoresCTVerifier() override = default; |
| 429 |
| 430 int Verify(net::X509Certificate* cert, |
| 431 const std::string& stapled_ocsp_response, |
| 432 const std::string& sct_list_from_tls_extension, |
| 433 net::ct::CTVerifyResult* result, |
| 434 const net::BoundNetLog& net_log) override { |
| 435 return net::OK; |
| 436 } |
| 437 |
| 438 void SetObserver(Observer* observer) override {} |
| 439 }; |
| 440 |
403 SpdyURLRequestContext::SpdyURLRequestContext() : storage_(this) { | 441 SpdyURLRequestContext::SpdyURLRequestContext() : storage_(this) { |
404 storage_.set_host_resolver( | 442 storage_.set_host_resolver( |
405 std::unique_ptr<HostResolver>(new MockHostResolver)); | 443 std::unique_ptr<HostResolver>(new MockHostResolver)); |
406 storage_.set_cert_verifier(base::WrapUnique(new MockCertVerifier)); | 444 storage_.set_cert_verifier(base::WrapUnique(new MockCertVerifier)); |
407 storage_.set_transport_security_state( | 445 storage_.set_transport_security_state( |
408 base::WrapUnique(new TransportSecurityState)); | 446 base::WrapUnique(new TransportSecurityState)); |
409 storage_.set_proxy_service(ProxyService::CreateDirect()); | 447 storage_.set_proxy_service(ProxyService::CreateDirect()); |
410 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); | 448 storage_.set_ssl_config_service(new SSLConfigServiceDefaults); |
411 storage_.set_http_auth_handler_factory( | 449 storage_.set_http_auth_handler_factory( |
412 HttpAuthHandlerFactory::CreateDefault(host_resolver())); | 450 HttpAuthHandlerFactory::CreateDefault(host_resolver())); |
413 storage_.set_http_server_properties( | 451 storage_.set_http_server_properties( |
414 std::unique_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); | 452 std::unique_ptr<HttpServerProperties>(new HttpServerPropertiesImpl())); |
415 storage_.set_job_factory(base::WrapUnique(new URLRequestJobFactoryImpl())); | 453 storage_.set_job_factory(base::WrapUnique(new URLRequestJobFactoryImpl())); |
416 HttpNetworkSession::Params params; | 454 HttpNetworkSession::Params params; |
417 params.client_socket_factory = &socket_factory_; | 455 params.client_socket_factory = &socket_factory_; |
418 params.host_resolver = host_resolver(); | 456 params.host_resolver = host_resolver(); |
419 params.cert_verifier = cert_verifier(); | 457 params.cert_verifier = cert_verifier(); |
420 params.transport_security_state = transport_security_state(); | 458 params.transport_security_state = transport_security_state(); |
421 params.proxy_service = proxy_service(); | 459 params.proxy_service = proxy_service(); |
| 460 params.ct_policy_enforcer = new AllowAnyCertCTPolicyEnforcer(); |
| 461 params.cert_transparency_verifier = new IgnoresCTVerifier(); |
422 params.ssl_config_service = ssl_config_service(); | 462 params.ssl_config_service = ssl_config_service(); |
423 params.http_auth_handler_factory = http_auth_handler_factory(); | 463 params.http_auth_handler_factory = http_auth_handler_factory(); |
424 params.enable_spdy_ping_based_connection_checking = false; | 464 params.enable_spdy_ping_based_connection_checking = false; |
425 params.http_server_properties = http_server_properties(); | 465 params.http_server_properties = http_server_properties(); |
426 storage_.set_http_network_session( | 466 storage_.set_http_network_session( |
427 base::WrapUnique(new HttpNetworkSession(params))); | 467 base::WrapUnique(new HttpNetworkSession(params))); |
428 SpdySessionPoolPeer pool_peer( | 468 SpdySessionPoolPeer pool_peer( |
429 storage_.http_network_session()->spdy_session_pool()); | 469 storage_.http_network_session()->spdy_session_pool()); |
430 pool_peer.SetEnableSendingInitialData(false); | 470 pool_peer.SetEnableSendingInitialData(false); |
431 storage_.set_http_transaction_factory(base::WrapUnique( | 471 storage_.set_http_transaction_factory(base::WrapUnique( |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1096 headers[GetSchemeKey()] = scheme.c_str(); | 1136 headers[GetSchemeKey()] = scheme.c_str(); |
1097 headers[GetPathKey()] = path.c_str(); | 1137 headers[GetPathKey()] = path.c_str(); |
1098 if (content_length) { | 1138 if (content_length) { |
1099 std::string length_str = base::Int64ToString(*content_length); | 1139 std::string length_str = base::Int64ToString(*content_length); |
1100 headers["content-length"] = length_str; | 1140 headers["content-length"] = length_str; |
1101 } | 1141 } |
1102 return headers; | 1142 return headers; |
1103 } | 1143 } |
1104 | 1144 |
1105 } // namespace net | 1145 } // namespace net |
OLD | NEW |