 Chromium Code Reviews
 Chromium Code Reviews Issue 4339001:
  Correctly handle SSL Client Authentication requests when connecting...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/
    
  
    Issue 4339001:
  Correctly handle SSL Client Authentication requests when connecting...  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src/| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/http/http_stream_request.h" | 5 #include "net/http/http_stream_request.h" | 
| 6 | 6 | 
| 7 #include "base/stl_util-inl.h" | 7 #include "base/stl_util-inl.h" | 
| 8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" | 
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" | 
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" | 
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 498 // changed. | 498 // changed. | 
| 499 authentication_url = UpgradeUrlToHttps(authentication_url); | 499 authentication_url = UpgradeUrlToHttps(authentication_url); | 
| 500 } | 500 } | 
| 501 establishing_tunnel_ = using_ssl_; | 501 establishing_tunnel_ = using_ssl_; | 
| 502 std::string user_agent; | 502 std::string user_agent; | 
| 503 request_info().extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 503 request_info().extra_headers.GetHeader(HttpRequestHeaders::kUserAgent, | 
| 504 &user_agent); | 504 &user_agent); | 
| 505 scoped_refptr<SSLSocketParams> ssl_params; | 505 scoped_refptr<SSLSocketParams> ssl_params; | 
| 506 if (proxy_info()->is_https()) { | 506 if (proxy_info()->is_https()) { | 
| 507 // Set ssl_params, and unset proxy_tcp_params | 507 // Set ssl_params, and unset proxy_tcp_params | 
| 508 ssl_params = GenerateSslParams(proxy_tcp_params, NULL, NULL, | 508 ssl_params = GenerateSSLParams(proxy_tcp_params, NULL, NULL, | 
| 509 ProxyServer::SCHEME_DIRECT, | 509 ProxyServer::SCHEME_DIRECT, | 
| 510 proxy_host_port->host(), | 510 *proxy_host_port.get(), | 
| 511 want_spdy_over_npn); | 511 want_spdy_over_npn); | 
| 512 proxy_tcp_params = NULL; | 512 proxy_tcp_params = NULL; | 
| 513 } | 513 } | 
| 514 | 514 | 
| 515 http_proxy_params = | 515 http_proxy_params = | 
| 516 new HttpProxySocketParams(proxy_tcp_params, | 516 new HttpProxySocketParams(proxy_tcp_params, | 
| 517 ssl_params, | 517 ssl_params, | 
| 518 authentication_url, | 518 authentication_url, | 
| 519 user_agent, | 519 user_agent, | 
| 520 endpoint_, | 520 endpoint_, | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 537 socks_version == '5', | 537 socks_version == '5', | 
| 538 endpoint_, | 538 endpoint_, | 
| 539 request_info().priority, | 539 request_info().priority, | 
| 540 request_info().referrer); | 540 request_info().referrer); | 
| 541 } | 541 } | 
| 542 } | 542 } | 
| 543 | 543 | 
| 544 // Deal with SSL - which layers on top of any given proxy. | 544 // Deal with SSL - which layers on top of any given proxy. | 
| 545 if (using_ssl_) { | 545 if (using_ssl_) { | 
| 546 scoped_refptr<SSLSocketParams> ssl_params = | 546 scoped_refptr<SSLSocketParams> ssl_params = | 
| 547 GenerateSslParams(tcp_params, http_proxy_params, socks_params, | 547 GenerateSSLParams(tcp_params, http_proxy_params, socks_params, | 
| 548 proxy_info()->proxy_server().scheme(), | 548 proxy_info()->proxy_server().scheme(), | 
| 549 request_info().url.HostNoBrackets(), | 549 HostPortPair(request_info().url.HostNoBrackets(), | 
| 
eroman
2010/11/12 01:12:56
How about:
HostPortPair::FromURL(request_info().ur
 
Ryan Hamilton
2010/11/12 16:47:26
Done.  Awesome!
 | |
| 550 request_info().url.EffectiveIntPort()), | |
| 550 want_spdy_over_npn); | 551 want_spdy_over_npn); | 
| 551 SSLClientSocketPool* ssl_pool = NULL; | 552 SSLClientSocketPool* ssl_pool = NULL; | 
| 552 if (proxy_info()->is_direct()) | 553 if (proxy_info()->is_direct()) | 
| 553 ssl_pool = session_->ssl_socket_pool(); | 554 ssl_pool = session_->ssl_socket_pool(); | 
| 554 else | 555 else | 
| 555 ssl_pool = session_->GetSocketPoolForSSLWithProxy(*proxy_host_port); | 556 ssl_pool = session_->GetSocketPoolForSSLWithProxy(*proxy_host_port); | 
| 556 | 557 | 
| 557 if (preconnect_delegate_) { | 558 if (preconnect_delegate_) { | 
| 558 RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 559 RequestSocketsForPool(ssl_pool, connection_group, ssl_params, | 
| 559 num_streams_, net_log_); | 560 num_streams_, net_log_); | 
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 821 connection_->socket()->SetOmniboxSpeculation(); | 822 connection_->socket()->SetOmniboxSpeculation(); | 
| 822 // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED). | 823 // TODO(mbelshe): Add other motivations (like EARLY_LOAD_MOTIVATED). | 
| 823 } | 824 } | 
| 824 | 825 | 
| 825 bool HttpStreamRequest::IsHttpsProxyAndHttpUrl() { | 826 bool HttpStreamRequest::IsHttpsProxyAndHttpUrl() { | 
| 826 return proxy_info()->is_https() && request_info().url.SchemeIs("http"); | 827 return proxy_info()->is_https() && request_info().url.SchemeIs("http"); | 
| 827 } | 828 } | 
| 828 | 829 | 
| 829 // Returns a newly create SSLSocketParams, and sets several | 830 // Returns a newly create SSLSocketParams, and sets several | 
| 830 // fields of ssl_config_. | 831 // fields of ssl_config_. | 
| 831 scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSslParams( | 832 scoped_refptr<SSLSocketParams> HttpStreamRequest::GenerateSSLParams( | 
| 832 scoped_refptr<TCPSocketParams> tcp_params, | 833 scoped_refptr<TCPSocketParams> tcp_params, | 
| 833 scoped_refptr<HttpProxySocketParams> http_proxy_params, | 834 scoped_refptr<HttpProxySocketParams> http_proxy_params, | 
| 834 scoped_refptr<SOCKSSocketParams> socks_params, | 835 scoped_refptr<SOCKSSocketParams> socks_params, | 
| 835 ProxyServer::Scheme proxy_scheme, | 836 ProxyServer::Scheme proxy_scheme, | 
| 836 std::string hostname, | 837 const HostPortPair& host_and_port, | 
| 837 bool want_spdy_over_npn) { | 838 bool want_spdy_over_npn) { | 
| 838 | 839 | 
| 839 if (factory_->IsTLSIntolerantServer(request_info().url)) { | 840 if (factory_->IsTLSIntolerantServer(request_info().url)) { | 
| 840 LOG(WARNING) << "Falling back to SSLv3 because host is TLS intolerant: " | 841 LOG(WARNING) << "Falling back to SSLv3 because host is TLS intolerant: " | 
| 841 << GetHostAndPort(request_info().url); | 842 << GetHostAndPort(request_info().url); | 
| 842 ssl_config()->ssl3_fallback = true; | 843 ssl_config()->ssl3_fallback = true; | 
| 843 ssl_config()->tls1_enabled = false; | 844 ssl_config()->tls1_enabled = false; | 
| 844 } | 845 } | 
| 845 | 846 | 
| 846 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionUsedSSLv3Fallback", | 847 UMA_HISTOGRAM_ENUMERATION("Net.ConnectionUsedSSLv3Fallback", | 
| 847 static_cast<int>(ssl_config()->ssl3_fallback), 2); | 848 static_cast<int>(ssl_config()->ssl3_fallback), 2); | 
| 848 | 849 | 
| 849 int load_flags = request_info().load_flags; | 850 int load_flags = request_info().load_flags; | 
| 850 if (HttpStreamFactory::ignore_certificate_errors()) | 851 if (HttpStreamFactory::ignore_certificate_errors()) | 
| 851 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | 852 load_flags |= LOAD_IGNORE_ALL_CERT_ERRORS; | 
| 852 if (request_info().load_flags & LOAD_VERIFY_EV_CERT) | 853 if (request_info().load_flags & LOAD_VERIFY_EV_CERT) | 
| 853 ssl_config()->verify_ev_cert = true; | 854 ssl_config()->verify_ev_cert = true; | 
| 854 | 855 | 
| 855 if (proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTP || | 856 if (proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTP || | 
| 856 proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTPS) { | 857 proxy_info()->proxy_server().scheme() == ProxyServer::SCHEME_HTTPS) { | 
| 857 ssl_config()->mitm_proxies_allowed = true; | 858 ssl_config()->mitm_proxies_allowed = true; | 
| 858 } | 859 } | 
| 859 | 860 | 
| 860 scoped_refptr<SSLSocketParams> ssl_params( | 861 scoped_refptr<SSLSocketParams> ssl_params( | 
| 861 new SSLSocketParams(tcp_params, socks_params, http_proxy_params, | 862 new SSLSocketParams(tcp_params, socks_params, http_proxy_params, | 
| 862 proxy_scheme, hostname, | 863 proxy_scheme, host_and_port, | 
| 863 *ssl_config(), load_flags, | 864 *ssl_config(), load_flags, | 
| 864 force_spdy_always_ && force_spdy_over_ssl_, | 865 force_spdy_always_ && force_spdy_over_ssl_, | 
| 865 want_spdy_over_npn)); | 866 want_spdy_over_npn)); | 
| 866 | 867 | 
| 867 return ssl_params; | 868 return ssl_params; | 
| 868 } | 869 } | 
| 869 | 870 | 
| 870 | 871 | 
| 871 void HttpStreamRequest::MarkBrokenAlternateProtocolAndFallback() { | 872 void HttpStreamRequest::MarkBrokenAlternateProtocolAndFallback() { | 
| 872 // We have to: | 873 // We have to: | 
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1039 base::TimeDelta::FromMinutes(6), | 1040 base::TimeDelta::FromMinutes(6), | 
| 1040 100); | 1041 100); | 
| 1041 break; | 1042 break; | 
| 1042 default: | 1043 default: | 
| 1043 NOTREACHED(); | 1044 NOTREACHED(); | 
| 1044 break; | 1045 break; | 
| 1045 } | 1046 } | 
| 1046 } | 1047 } | 
| 1047 | 1048 | 
| 1048 } // namespace net | 1049 } // namespace net | 
| OLD | NEW |