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 "net/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 #include "net/http/http_proxy_client_socket_pool.h" | 40 #include "net/http/http_proxy_client_socket_pool.h" |
| 41 #include "net/http/http_request_headers.h" | 41 #include "net/http/http_request_headers.h" |
| 42 #include "net/http/http_request_info.h" | 42 #include "net/http/http_request_info.h" |
| 43 #include "net/http/http_response_headers.h" | 43 #include "net/http/http_response_headers.h" |
| 44 #include "net/http/http_response_info.h" | 44 #include "net/http/http_response_info.h" |
| 45 #include "net/http/http_server_properties.h" | 45 #include "net/http/http_server_properties.h" |
| 46 #include "net/http/http_status_code.h" | 46 #include "net/http/http_status_code.h" |
| 47 #include "net/http/http_stream_base.h" | 47 #include "net/http/http_stream_base.h" |
| 48 #include "net/http/http_stream_factory.h" | 48 #include "net/http/http_stream_factory.h" |
| 49 #include "net/http/http_util.h" | 49 #include "net/http/http_util.h" |
| 50 #include "net/http/transport_security_state.h" | |
| 50 #include "net/http/url_security_manager.h" | 51 #include "net/http/url_security_manager.h" |
| 51 #include "net/socket/client_socket_factory.h" | 52 #include "net/socket/client_socket_factory.h" |
| 52 #include "net/socket/socks_client_socket_pool.h" | 53 #include "net/socket/socks_client_socket_pool.h" |
| 53 #include "net/socket/ssl_client_socket.h" | 54 #include "net/socket/ssl_client_socket.h" |
| 54 #include "net/socket/ssl_client_socket_pool.h" | 55 #include "net/socket/ssl_client_socket_pool.h" |
| 55 #include "net/socket/transport_client_socket_pool.h" | 56 #include "net/socket/transport_client_socket_pool.h" |
| 56 #include "net/spdy/spdy_http_stream.h" | 57 #include "net/spdy/spdy_http_stream.h" |
| 57 #include "net/spdy/spdy_session.h" | 58 #include "net/spdy/spdy_session.h" |
| 58 #include "net/spdy/spdy_session_pool.h" | 59 #include "net/spdy/spdy_session_pool.h" |
| 59 #include "net/ssl/ssl_cert_request_info.h" | 60 #include "net/ssl/ssl_cert_request_info.h" |
| (...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1209 // by the endpoint host, request_->url, rather than considering if they were | 1210 // by the endpoint host, request_->url, rather than considering if they were |
| 1210 // generated by the SSL proxy. http://crbug.com/69329 | 1211 // generated by the SSL proxy. http://crbug.com/69329 |
| 1211 int HttpNetworkTransaction::HandleSSLHandshakeError(int error) { | 1212 int HttpNetworkTransaction::HandleSSLHandshakeError(int error) { |
| 1212 DCHECK(request_); | 1213 DCHECK(request_); |
| 1213 if (server_ssl_config_.send_client_cert && | 1214 if (server_ssl_config_.send_client_cert && |
| 1214 (error == ERR_SSL_PROTOCOL_ERROR || IsClientCertificateError(error))) { | 1215 (error == ERR_SSL_PROTOCOL_ERROR || IsClientCertificateError(error))) { |
| 1215 session_->ssl_client_auth_cache()->Remove( | 1216 session_->ssl_client_auth_cache()->Remove( |
| 1216 GetHostAndPort(request_->url)); | 1217 GetHostAndPort(request_->url)); |
| 1217 } | 1218 } |
| 1218 | 1219 |
| 1220 uint16 version_before = server_ssl_config_.version_max; | |
|
Ryan Sleevi
2013/04/17 01:16:36
So after reading the code (which, yes, I realize I
thaidn_google
2013/04/17 04:34:47
Nice catch :-).
On 2013/04/17 01:16:36, Ryan Slee
| |
| 1221 uint16 version_max = version_before; | |
| 1222 | |
| 1219 switch (error) { | 1223 switch (error) { |
| 1220 case ERR_SSL_PROTOCOL_ERROR: | 1224 case ERR_SSL_PROTOCOL_ERROR: |
| 1221 case ERR_SSL_VERSION_OR_CIPHER_MISMATCH: | 1225 case ERR_SSL_VERSION_OR_CIPHER_MISMATCH: |
| 1222 if (server_ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1 && | 1226 if (version_max >= SSL_PROTOCOL_VERSION_TLS1 && |
| 1223 server_ssl_config_.version_max > server_ssl_config_.version_min) { | 1227 version_max > server_ssl_config_.version_min) { |
| 1224 // This could be a TLS-intolerant server or a server that chose a | 1228 // This could be a TLS-intolerant server or a server that chose a |
| 1225 // cipher suite defined only for higher protocol versions (such as | 1229 // cipher suite defined only for higher protocol versions (such as |
| 1226 // an SSL 3.0 server that chose a TLS-only cipher suite). Fall | 1230 // an SSL 3.0 server that chose a TLS-only cipher suite). Fall |
| 1227 // back to the next lower version and retry. | 1231 // back to the next lower version and retry. |
| 1228 // NOTE: if the SSLClientSocket class doesn't support TLS 1.1, | 1232 // NOTE: if the SSLClientSocket class doesn't support TLS 1.1, |
| 1229 // specifying TLS 1.1 in version_max will result in a TLS 1.0 | 1233 // specifying TLS 1.1 in version_max will result in a TLS 1.0 |
| 1230 // handshake, so falling back from TLS 1.1 to TLS 1.0 will simply | 1234 // handshake, so falling back from TLS 1.1 to TLS 1.0 will simply |
| 1231 // repeat the TLS 1.0 handshake. To avoid this problem, the default | 1235 // repeat the TLS 1.0 handshake. To avoid this problem, the default |
| 1232 // version_max should match the maximum protocol version supported | 1236 // version_max should match the maximum protocol version supported |
| 1233 // by the SSLClientSocket class. | 1237 // by the SSLClientSocket class. |
| 1234 uint16 version_before = server_ssl_config_.version_max; | 1238 version_max--; |
| 1235 server_ssl_config_.version_max--; | |
| 1236 net_log_.AddEvent( | |
| 1237 NetLog::TYPE_SSL_VERSION_FALLBACK, | |
| 1238 base::Bind(&NetLogSSLVersionFallbackCallback, | |
| 1239 &request_->url, error, version_before, | |
| 1240 server_ssl_config_.version_max)); | |
| 1241 server_ssl_config_.version_fallback = true; | |
| 1242 ResetConnectionAndRequestForResend(); | |
| 1243 error = OK; | |
| 1244 } | 1239 } |
| 1245 break; | 1240 break; |
| 1246 case ERR_SSL_DECOMPRESSION_FAILURE_ALERT: | 1241 case ERR_SSL_DECOMPRESSION_FAILURE_ALERT: |
| 1247 case ERR_SSL_BAD_RECORD_MAC_ALERT: | 1242 case ERR_SSL_BAD_RECORD_MAC_ALERT: |
| 1248 if (server_ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1 && | 1243 if (version_max >= SSL_PROTOCOL_VERSION_TLS1 && |
| 1249 server_ssl_config_.version_min == SSL_PROTOCOL_VERSION_SSL3) { | 1244 version_max == SSL_PROTOCOL_VERSION_SSL3) { |
| 1250 // This could be a server with buggy DEFLATE support. Turn off TLS, | 1245 // This could be a server with buggy DEFLATE support. Turn off TLS, |
| 1251 // DEFLATE support and retry. | 1246 // DEFLATE support and retry. |
| 1252 // TODO(wtc): turn off DEFLATE support only. Do not tie it to TLS. | 1247 // TODO(wtc): turn off DEFLATE support only. Do not tie it to TLS. |
| 1253 uint16 version_before = server_ssl_config_.version_max; | 1248 version_max = SSL_PROTOCOL_VERSION_SSL3; |
| 1254 server_ssl_config_.version_max = SSL_PROTOCOL_VERSION_SSL3; | |
| 1255 net_log_.AddEvent( | |
| 1256 NetLog::TYPE_SSL_VERSION_FALLBACK, | |
| 1257 base::Bind(&NetLogSSLVersionFallbackCallback, | |
| 1258 &request_->url, error, version_before, | |
| 1259 server_ssl_config_.version_max)); | |
| 1260 server_ssl_config_.version_fallback = true; | |
| 1261 ResetConnectionAndRequestForResend(); | |
| 1262 error = OK; | |
| 1263 } | 1249 } |
| 1264 break; | 1250 break; |
| 1265 } | 1251 } |
| 1252 | |
| 1253 if (version_max != version_before && | |
| 1254 // Do not fallback to SSL 3.0 on Google properties. | |
| 1255 !(version_max <= SSL_PROTOCOL_VERSION_SSL3 && | |
| 1256 !server_ssl_config_.ssl_version_min_preloaded_disabled && | |
| 1257 TransportSecurityState::IsGooglePinnedProperty( | |
| 1258 request_->url.host(), true /* include SNI */))) { | |
| 1259 server_ssl_config_.version_max = version_max; | |
| 1260 net_log_.AddEvent( | |
| 1261 NetLog::TYPE_SSL_VERSION_FALLBACK, | |
| 1262 base::Bind(&NetLogSSLVersionFallbackCallback, | |
| 1263 &request_->url, error, version_before, | |
| 1264 server_ssl_config_.version_max)); | |
| 1265 server_ssl_config_.version_fallback = true; | |
| 1266 ResetConnectionAndRequestForResend(); | |
| 1267 error = OK; | |
| 1268 } | |
| 1269 | |
| 1266 return error; | 1270 return error; |
| 1267 } | 1271 } |
| 1268 | 1272 |
| 1269 // This method determines whether it is safe to resend the request after an | 1273 // This method determines whether it is safe to resend the request after an |
| 1270 // IO error. It can only be called in response to request header or body | 1274 // IO error. It can only be called in response to request header or body |
| 1271 // write errors or response header read errors. It should not be used in | 1275 // write errors or response header read errors. It should not be used in |
| 1272 // other cases, such as a Connect error. | 1276 // other cases, such as a Connect error. |
| 1273 int HttpNetworkTransaction::HandleIOError(int error) { | 1277 int HttpNetworkTransaction::HandleIOError(int error) { |
| 1274 // SSL errors may happen at any time during the stream and indicate issues | 1278 // SSL errors may happen at any time during the stream and indicate issues |
| 1275 // with the underlying connection. Because the peer may request | 1279 // with the underlying connection. Because the peer may request |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1461 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, | 1465 description = base::StringPrintf("Unknown state 0x%08X (%u)", state, |
| 1462 state); | 1466 state); |
| 1463 break; | 1467 break; |
| 1464 } | 1468 } |
| 1465 return description; | 1469 return description; |
| 1466 } | 1470 } |
| 1467 | 1471 |
| 1468 #undef STATE_CASE | 1472 #undef STATE_CASE |
| 1469 | 1473 |
| 1470 } // namespace net | 1474 } // namespace net |
| OLD | NEW |