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

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

Issue 88913003: Revert: "net: don't allow SSLv3 fallback for Google properties." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | net/http/transport_security_state_static.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <string> 5 #include <string>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "net/base/net_util.h" 10 #include "net/base/net_util.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); 125 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR);
126 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2); 126 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2);
127 StaticSocketDataProvider data2(NULL, 0, NULL, 0); 127 StaticSocketDataProvider data2(NULL, 0, NULL, 0);
128 mock_socket_factory_.AddSocketDataProvider(&data2); 128 mock_socket_factory_.AddSocketDataProvider(&data2);
129 129
130 scoped_refptr<HttpNetworkSession> session( 130 scoped_refptr<HttpNetworkSession> session(
131 new HttpNetworkSession(session_params_)); 131 new HttpNetworkSession(session_params_));
132 scoped_ptr<HttpNetworkTransaction> trans( 132 scoped_ptr<HttpNetworkTransaction> trans(
133 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 133 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
134 134
135 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
136 ssl_config.unrestricted_ssl3_fallback_enabled = false;
137
135 TestCompletionCallback callback; 138 TestCompletionCallback callback;
136 // This will consume only |ssl_data1|. |ssl_data2| will not be consumed. 139 // This will consume only |ssl_data1|. |ssl_data2| will not be consumed.
137 int rv = callback.GetResult( 140 int rv = callback.GetResult(
138 trans->Start(GetRequestInfo("https://www.google.com/"), 141 trans->Start(GetRequestInfo("https://www.google.com/"),
139 callback.callback(), BoundNetLog())); 142 callback.callback(), BoundNetLog()));
140 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 143 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
141 144
142 SocketDataProviderArray<SocketDataProvider>& mock_data = 145 SocketDataProviderArray<SocketDataProvider>& mock_data =
143 mock_socket_factory_.mock_data(); 146 mock_socket_factory_.mock_data();
144 // Confirms that only |ssl_data1| is consumed. 147 // Confirms that only |ssl_data1| is consumed.
145 EXPECT_EQ(1u, mock_data.next_index()); 148 EXPECT_EQ(1u, mock_data.next_index());
146 149
147 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
148 // |version_max| never fallbacks to SSLv3 for Google properties. 150 // |version_max| never fallbacks to SSLv3 for Google properties.
149 EXPECT_EQ(SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_max); 151 EXPECT_EQ(SSL_PROTOCOL_VERSION_TLS1, ssl_config.version_max);
150 EXPECT_FALSE(ssl_config.version_fallback); 152 EXPECT_FALSE(ssl_config.version_fallback);
151 } 153 }
152 154
153 // Tests that HttpNetworkTransaction attempts to fallback to SSL 3.0 155 // Tests that HttpNetworkTransaction attempts to fallback to SSL 3.0
154 // when a TLS 1.0 handshake fails and: 156 // when a TLS 1.0 handshake fails and:
155 // * the site is pinned to the Google pin list (indicating that 157 // * the site is pinned to the Google pin list (indicating that
156 // it is a Google site); 158 // it is a Google site);
157 // * unrestricted SSL 3.0 fallback is enabled. 159 // * unrestricted SSL 3.0 fallback is enabled.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); 218 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR);
217 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2); 219 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data2);
218 StaticSocketDataProvider data2(NULL, 0, NULL, 0); 220 StaticSocketDataProvider data2(NULL, 0, NULL, 0);
219 mock_socket_factory_.AddSocketDataProvider(&data2); 221 mock_socket_factory_.AddSocketDataProvider(&data2);
220 222
221 scoped_refptr<HttpNetworkSession> session( 223 scoped_refptr<HttpNetworkSession> session(
222 new HttpNetworkSession(session_params_)); 224 new HttpNetworkSession(session_params_));
223 scoped_ptr<HttpNetworkTransaction> trans( 225 scoped_ptr<HttpNetworkTransaction> trans(
224 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 226 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
225 227
228 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
229 ssl_config.unrestricted_ssl3_fallback_enabled = false;
230
226 TestCompletionCallback callback; 231 TestCompletionCallback callback;
227 // This will consume |ssl_data1| and |ssl_data2|. 232 // This will consume |ssl_data1| and |ssl_data2|.
228 int rv = callback.GetResult( 233 int rv = callback.GetResult(
229 trans->Start(GetRequestInfo("https://www.paypal.com/"), 234 trans->Start(GetRequestInfo("https://www.paypal.com/"),
230 callback.callback(), BoundNetLog())); 235 callback.callback(), BoundNetLog()));
231 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 236 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
232 237
233 SocketDataProviderArray<SocketDataProvider>& mock_data = 238 SocketDataProviderArray<SocketDataProvider>& mock_data =
234 mock_socket_factory_.mock_data(); 239 mock_socket_factory_.mock_data();
235 // Confirms that both |ssl_data1| and |ssl_data2| are consumed. 240 // Confirms that both |ssl_data1| and |ssl_data2| are consumed.
236 EXPECT_EQ(2u, mock_data.next_index()); 241 EXPECT_EQ(2u, mock_data.next_index());
237 242
238 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
239 // |version_max| fallbacks to SSL 3.0. 243 // |version_max| fallbacks to SSL 3.0.
240 EXPECT_EQ(SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max); 244 EXPECT_EQ(SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max);
241 EXPECT_TRUE(ssl_config.version_fallback); 245 EXPECT_TRUE(ssl_config.version_fallback);
242 } 246 }
243 247
244 // Tests that HttpNetworkTransaction attempts to fallback from 248 // Tests that HttpNetworkTransaction attempts to fallback from
245 // TLS 1.1 to TLS 1.0, then from TLS 1.0 to SSL 3.0. 249 // TLS 1.1 to TLS 1.0, then from TLS 1.0 to SSL 3.0.
246 TEST_F(HttpNetworkTransactionSSLTest, SSLFallback) { 250 TEST_F(HttpNetworkTransactionSSLTest, SSLFallback) {
247 ssl_config_service_ = new TLS11SSLConfigService; 251 ssl_config_service_ = new TLS11SSLConfigService;
248 session_params_.ssl_config_service = ssl_config_service_.get(); 252 session_params_.ssl_config_service = ssl_config_service_.get();
(...skipping 18 matching lines...) Expand all
267 SSLSocketDataProvider ssl_data3(ASYNC, ERR_SSL_PROTOCOL_ERROR); 271 SSLSocketDataProvider ssl_data3(ASYNC, ERR_SSL_PROTOCOL_ERROR);
268 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data3); 272 mock_socket_factory_.AddSSLSocketDataProvider(&ssl_data3);
269 StaticSocketDataProvider data3(NULL, 0, NULL, 0); 273 StaticSocketDataProvider data3(NULL, 0, NULL, 0);
270 mock_socket_factory_.AddSocketDataProvider(&data3); 274 mock_socket_factory_.AddSocketDataProvider(&data3);
271 275
272 scoped_refptr<HttpNetworkSession> session( 276 scoped_refptr<HttpNetworkSession> session(
273 new HttpNetworkSession(session_params_)); 277 new HttpNetworkSession(session_params_));
274 scoped_ptr<HttpNetworkTransaction> trans( 278 scoped_ptr<HttpNetworkTransaction> trans(
275 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); 279 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get()));
276 280
281 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
282 ssl_config.unrestricted_ssl3_fallback_enabled = true;
283
277 TestCompletionCallback callback; 284 TestCompletionCallback callback;
278 // This will consume |ssl_data1|, |ssl_data2| and |ssl_data3|. 285 // This will consume |ssl_data1|, |ssl_data2| and |ssl_data3|.
279 int rv = callback.GetResult( 286 int rv = callback.GetResult(
280 trans->Start(GetRequestInfo("https://www.paypal.com/"), 287 trans->Start(GetRequestInfo("https://www.paypal.com/"),
281 callback.callback(), BoundNetLog())); 288 callback.callback(), BoundNetLog()));
282 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv); 289 EXPECT_EQ(ERR_SSL_PROTOCOL_ERROR, rv);
283 290
284 SocketDataProviderArray<SocketDataProvider>& mock_data = 291 SocketDataProviderArray<SocketDataProvider>& mock_data =
285 mock_socket_factory_.mock_data(); 292 mock_socket_factory_.mock_data();
286 // Confirms that |ssl_data1|, |ssl_data2| and |ssl_data3| are consumed. 293 // Confirms that |ssl_data1|, |ssl_data2| and |ssl_data3| are consumed.
287 EXPECT_EQ(3u, mock_data.next_index()); 294 EXPECT_EQ(3u, mock_data.next_index());
288 295
289 SSLConfig& ssl_config = GetServerSSLConfig(trans.get());
290 // |version_max| fallbacks to SSL 3.0. 296 // |version_max| fallbacks to SSL 3.0.
291 EXPECT_EQ(SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max); 297 EXPECT_EQ(SSL_PROTOCOL_VERSION_SSL3, ssl_config.version_max);
292 EXPECT_TRUE(ssl_config.version_fallback); 298 EXPECT_TRUE(ssl_config.version_fallback);
293 } 299 }
294 300
295 } // namespace net 301 } // namespace net
296 302
OLDNEW
« no previous file with comments | « chrome/common/chrome_switches.cc ('k') | net/http/transport_security_state_static.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698