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

Side by Side Diff: net/http/http_network_transaction.cc

Issue 1127623005: Gather metrics classifying the cause of the TLS fallback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fallback-required
Patch Set: rsleevi comments Created 5 years, 7 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 (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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 session->http_stream_factory()->ProcessAlternateProtocol( 88 session->http_stream_factory()->ProcessAlternateProtocol(
89 session->http_server_properties(), 89 session->http_server_properties(),
90 alternate_protocol_values, 90 alternate_protocol_values,
91 http_host_port_pair, 91 http_host_port_pair,
92 *session); 92 *session);
93 } 93 }
94 94
95 base::Value* NetLogSSLVersionFallbackCallback( 95 base::Value* NetLogSSLVersionFallbackCallback(
96 const GURL* url, 96 const GURL* url,
97 int net_error, 97 int net_error,
98 SSLFailureState ssl_failure_state,
98 uint16 version_before, 99 uint16 version_before,
99 uint16 version_after, 100 uint16 version_after,
100 NetLogCaptureMode /* capture_mode */) { 101 NetLogCaptureMode /* capture_mode */) {
101 base::DictionaryValue* dict = new base::DictionaryValue(); 102 base::DictionaryValue* dict = new base::DictionaryValue();
102 dict->SetString("host_and_port", GetHostAndPort(*url)); 103 dict->SetString("host_and_port", GetHostAndPort(*url));
103 dict->SetInteger("net_error", net_error); 104 dict->SetInteger("net_error", net_error);
105 dict->SetInteger("ssl_failure_state", ssl_failure_state);
104 dict->SetInteger("version_before", version_before); 106 dict->SetInteger("version_before", version_before);
105 dict->SetInteger("version_after", version_after); 107 dict->SetInteger("version_after", version_after);
106 return dict; 108 return dict;
107 } 109 }
108 110
109 base::Value* NetLogSSLCipherFallbackCallback( 111 base::Value* NetLogSSLCipherFallbackCallback(
110 const GURL* url, 112 const GURL* url,
111 int net_error, 113 int net_error,
112 NetLogCaptureMode /* capture_mode */) { 114 NetLogCaptureMode /* capture_mode */) {
113 base::DictionaryValue* dict = new base::DictionaryValue(); 115 base::DictionaryValue* dict = new base::DictionaryValue();
114 dict->SetString("host_and_port", GetHostAndPort(*url)); 116 dict->SetString("host_and_port", GetHostAndPort(*url));
115 dict->SetInteger("net_error", net_error); 117 dict->SetInteger("net_error", net_error);
116 return dict; 118 return dict;
117 } 119 }
118 120
119 } // namespace 121 } // namespace
120 122
121 //----------------------------------------------------------------------------- 123 //-----------------------------------------------------------------------------
122 124
123 HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority, 125 HttpNetworkTransaction::HttpNetworkTransaction(RequestPriority priority,
124 HttpNetworkSession* session) 126 HttpNetworkSession* session)
125 : pending_auth_target_(HttpAuth::AUTH_NONE), 127 : pending_auth_target_(HttpAuth::AUTH_NONE),
126 io_callback_(base::Bind(&HttpNetworkTransaction::OnIOComplete, 128 io_callback_(base::Bind(&HttpNetworkTransaction::OnIOComplete,
127 base::Unretained(this))), 129 base::Unretained(this))),
128 session_(session), 130 session_(session),
129 request_(NULL), 131 request_(NULL),
130 priority_(priority), 132 priority_(priority),
131 headers_valid_(false), 133 headers_valid_(false),
134 server_ssl_failure_state_(kSSLFailureNone),
132 fallback_error_code_(ERR_SSL_INAPPROPRIATE_FALLBACK), 135 fallback_error_code_(ERR_SSL_INAPPROPRIATE_FALLBACK),
136 fallback_failure_state_(kSSLFailureNone),
133 request_headers_(), 137 request_headers_(),
134 read_buf_len_(0), 138 read_buf_len_(0),
135 total_received_bytes_(0), 139 total_received_bytes_(0),
136 next_state_(STATE_NONE), 140 next_state_(STATE_NONE),
137 establishing_tunnel_(false), 141 establishing_tunnel_(false),
138 websocket_handshake_stream_base_create_helper_(NULL) { 142 websocket_handshake_stream_base_create_helper_(NULL) {
139 session->ssl_config_service()->GetSSLConfig(&server_ssl_config_); 143 session->ssl_config_service()->GetSSLConfig(&server_ssl_config_);
140 session->GetNextProtos(&server_ssl_config_.next_protos); 144 session->GetNextProtos(&server_ssl_config_.next_protos);
141 proxy_ssl_config_ = server_ssl_config_; 145 proxy_ssl_config_ = server_ssl_config_;
142 } 146 }
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 } 499 }
496 500
497 void HttpNetworkTransaction::OnWebSocketHandshakeStreamReady( 501 void HttpNetworkTransaction::OnWebSocketHandshakeStreamReady(
498 const SSLConfig& used_ssl_config, 502 const SSLConfig& used_ssl_config,
499 const ProxyInfo& used_proxy_info, 503 const ProxyInfo& used_proxy_info,
500 WebSocketHandshakeStreamBase* stream) { 504 WebSocketHandshakeStreamBase* stream) {
501 OnStreamReady(used_ssl_config, used_proxy_info, stream); 505 OnStreamReady(used_ssl_config, used_proxy_info, stream);
502 } 506 }
503 507
504 void HttpNetworkTransaction::OnStreamFailed(int result, 508 void HttpNetworkTransaction::OnStreamFailed(int result,
505 const SSLConfig& used_ssl_config) { 509 const SSLConfig& used_ssl_config,
510 SSLFailureState ssl_failure_state) {
506 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); 511 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_);
507 DCHECK_NE(OK, result); 512 DCHECK_NE(OK, result);
508 DCHECK(stream_request_.get()); 513 DCHECK(stream_request_.get());
509 DCHECK(!stream_.get()); 514 DCHECK(!stream_.get());
510 server_ssl_config_ = used_ssl_config; 515 server_ssl_config_ = used_ssl_config;
516 server_ssl_failure_state_ = ssl_failure_state;
511 517
512 OnIOComplete(result); 518 OnIOComplete(result);
513 } 519 }
514 520
515 void HttpNetworkTransaction::OnCertificateError( 521 void HttpNetworkTransaction::OnCertificateError(
516 int result, 522 int result,
517 const SSLConfig& used_ssl_config, 523 const SSLConfig& used_ssl_config,
518 const SSLInfo& ssl_info) { 524 const SSLInfo& ssl_info) {
519 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_); 525 DCHECK_EQ(STATE_CREATE_STREAM_COMPLETE, next_state_);
520 DCHECK_NE(OK, result); 526 DCHECK_NE(OK, result);
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 // could trigger ERR_SSL_INAPPROPRIATE_FALLBACK with the initial 1350 // could trigger ERR_SSL_INAPPROPRIATE_FALLBACK with the initial
1345 // connection. |fallback_error_code_| is initialised to 1351 // connection. |fallback_error_code_| is initialised to
1346 // ERR_SSL_INAPPROPRIATE_FALLBACK to catch this case. 1352 // ERR_SSL_INAPPROPRIATE_FALLBACK to catch this case.
1347 error = fallback_error_code_; 1353 error = fallback_error_code_;
1348 break; 1354 break;
1349 } 1355 }
1350 1356
1351 if (should_fallback) { 1357 if (should_fallback) {
1352 net_log_.AddEvent( 1358 net_log_.AddEvent(
1353 NetLog::TYPE_SSL_VERSION_FALLBACK, 1359 NetLog::TYPE_SSL_VERSION_FALLBACK,
1354 base::Bind(&NetLogSSLVersionFallbackCallback, 1360 base::Bind(&NetLogSSLVersionFallbackCallback, &request_->url, error,
1355 &request_->url, error, server_ssl_config_.version_max, 1361 server_ssl_failure_state_, server_ssl_config_.version_max,
1356 version_max)); 1362 version_max));
1357 fallback_error_code_ = error; 1363 fallback_error_code_ = error;
1364 fallback_failure_state_ = server_ssl_failure_state_;
1358 server_ssl_config_.version_max = version_max; 1365 server_ssl_config_.version_max = version_max;
1359 server_ssl_config_.version_fallback = true; 1366 server_ssl_config_.version_fallback = true;
1360 ResetConnectionAndRequestForResend(); 1367 ResetConnectionAndRequestForResend();
1361 error = OK; 1368 error = OK;
1362 } 1369 }
1363 1370
1364 return error; 1371 return error;
1365 } 1372 }
1366 1373
1367 // This method determines whether it is safe to resend the request after an 1374 // This method determines whether it is safe to resend the request after an
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 // This helps estimate intolerant locally-configured SSL MITMs. 1473 // This helps estimate intolerant locally-configured SSL MITMs.
1467 const std::string& host = request_->url.host(); 1474 const std::string& host = request_->url.host();
1468 if (EndsWith(host, "google.com", true) && 1475 if (EndsWith(host, "google.com", true) &&
1469 (host.size() == 10 || host[host.size() - 11] == '.')) { 1476 (host.size() == 10 || host[host.size() - 11] == '.')) {
1470 UMA_HISTOGRAM_ENUMERATION("Net.GoogleConnectionUsedSSLVersionFallback2", 1477 UMA_HISTOGRAM_ENUMERATION("Net.GoogleConnectionUsedSSLVersionFallback2",
1471 fallback, FALLBACK_MAX); 1478 fallback, FALLBACK_MAX);
1472 } 1479 }
1473 1480
1474 UMA_HISTOGRAM_BOOLEAN("Net.ConnectionUsedSSLDeprecatedCipherFallback2", 1481 UMA_HISTOGRAM_BOOLEAN("Net.ConnectionUsedSSLDeprecatedCipherFallback2",
1475 server_ssl_config_.enable_deprecated_cipher_suites); 1482 server_ssl_config_.enable_deprecated_cipher_suites);
1483
1484 if (server_ssl_config_.version_fallback) {
1485 // Record the error code which triggered the fallback and the state the
1486 // handshake was in.
1487 UMA_HISTOGRAM_CUSTOM_ENUMERATION("Net.SSLFallbackErrorCode",
1488 -fallback_error_code_,
1489 net::GetAllErrorCodesForUma());
Alexei Svitkine (slow) 2015/05/15 14:39:36 It's more efficient to use UMA_HISTOGRAM_SPARSE_SL
davidben 2015/05/15 18:00:23 Done. In that case should we switch all code that
Alexei Svitkine (slow) 2015/05/15 18:05:22 Yes, preferably all the places should be switched.
1490 UMA_HISTOGRAM_ENUMERATION("Net.SSLFallbackFailureState",
1491 fallback_failure_state_, kSSLFailureMax);
1492 }
1476 } 1493 }
1477 1494
1478 HttpResponseHeaders* HttpNetworkTransaction::GetResponseHeaders() const { 1495 HttpResponseHeaders* HttpNetworkTransaction::GetResponseHeaders() const {
1479 return response_.headers.get(); 1496 return response_.headers.get();
1480 } 1497 }
1481 1498
1482 bool HttpNetworkTransaction::ShouldResendRequest() const { 1499 bool HttpNetworkTransaction::ShouldResendRequest() const {
1483 bool connection_is_proven = stream_->IsConnectionReused(); 1500 bool connection_is_proven = stream_->IsConnectionReused();
1484 bool has_received_headers = GetResponseHeaders() != NULL; 1501 bool has_received_headers = GetResponseHeaders() != NULL;
1485 1502
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 DCHECK(stream_request_); 1639 DCHECK(stream_request_);
1623 1640
1624 // Since the transaction can restart with auth credentials, it may create a 1641 // Since the transaction can restart with auth credentials, it may create a
1625 // stream more than once. Accumulate all of the connection attempts across 1642 // stream more than once. Accumulate all of the connection attempts across
1626 // those streams by appending them to the vector: 1643 // those streams by appending them to the vector:
1627 for (const auto& attempt : stream_request_->connection_attempts()) 1644 for (const auto& attempt : stream_request_->connection_attempts())
1628 connection_attempts_.push_back(attempt); 1645 connection_attempts_.push_back(attempt);
1629 } 1646 }
1630 1647
1631 } // namespace net 1648 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698