OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/http/http_network_transaction.h" | 5 #include "net/http/http_network_transaction.h" |
6 | 6 |
7 #include <math.h> // ceil | 7 #include <math.h> // ceil |
8 #include <stdarg.h> | 8 #include <stdarg.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 11071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11082 // rather than a Finished message, because it requires a client | 11082 // rather than a Finished message, because it requires a client |
11083 // certificate and none was supplied. | 11083 // certificate and none was supplied. |
11084 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); | 11084 SSLSocketDataProvider ssl_data2(ASYNC, ERR_SSL_PROTOCOL_ERROR); |
11085 ssl_data2.cert_request_info = cert_request.get(); | 11085 ssl_data2.cert_request_info = cert_request.get(); |
11086 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data2); | 11086 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data2); |
11087 StaticSocketDataProvider data2(NULL, 0, NULL, 0); | 11087 StaticSocketDataProvider data2(NULL, 0, NULL, 0); |
11088 session_deps_.socket_factory->AddSocketDataProvider(&data2); | 11088 session_deps_.socket_factory->AddSocketDataProvider(&data2); |
11089 | 11089 |
11090 // [ssl_]data3 contains the data for the third SSL handshake. When a | 11090 // [ssl_]data3 contains the data for the third SSL handshake. When a |
11091 // connection to a server fails during an SSL handshake, | 11091 // connection to a server fails during an SSL handshake, |
11092 // HttpNetworkTransaction will attempt to fallback to TLSv1 if the previous | 11092 // HttpNetworkTransaction will attempt to fallback to TLSv1.1 if the previous |
11093 // connection was attempted with TLSv1.1. This is transparent to the caller | 11093 // connection was attempted with TLSv1.2. This is transparent to the caller |
11094 // of the HttpNetworkTransaction. Because this test failure is due to | 11094 // of the HttpNetworkTransaction. Because this test failure is due to |
11095 // requiring a client certificate, this fallback handshake should also | 11095 // requiring a client certificate, this fallback handshake should also |
11096 // fail. | 11096 // fail. |
11097 SSLSocketDataProvider ssl_data3(ASYNC, ERR_SSL_PROTOCOL_ERROR); | 11097 SSLSocketDataProvider ssl_data3(ASYNC, ERR_SSL_PROTOCOL_ERROR); |
11098 ssl_data3.cert_request_info = cert_request.get(); | 11098 ssl_data3.cert_request_info = cert_request.get(); |
11099 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data3); | 11099 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data3); |
11100 StaticSocketDataProvider data3(NULL, 0, NULL, 0); | 11100 StaticSocketDataProvider data3(NULL, 0, NULL, 0); |
11101 session_deps_.socket_factory->AddSocketDataProvider(&data3); | 11101 session_deps_.socket_factory->AddSocketDataProvider(&data3); |
11102 | 11102 |
11103 // [ssl_]data4 contains the data for the fourth SSL handshake. When a | 11103 // [ssl_]data4 contains the data for the fourth SSL handshake. When a |
11104 // connection to a server fails during an SSL handshake, | 11104 // connection to a server fails during an SSL handshake, |
11105 // HttpNetworkTransaction will attempt to fallback to SSLv3 if the previous | 11105 // HttpNetworkTransaction will attempt to fallback to TLSv1 if the previous |
11106 // connection was attempted with TLSv1. This is transparent to the caller | 11106 // connection was attempted with TLSv1.1. This is transparent to the caller |
11107 // of the HttpNetworkTransaction. Because this test failure is due to | 11107 // of the HttpNetworkTransaction. Because this test failure is due to |
11108 // requiring a client certificate, this fallback handshake should also | 11108 // requiring a client certificate, this fallback handshake should also |
11109 // fail. | 11109 // fail. |
11110 SSLSocketDataProvider ssl_data4(ASYNC, ERR_SSL_PROTOCOL_ERROR); | 11110 SSLSocketDataProvider ssl_data4(ASYNC, ERR_SSL_PROTOCOL_ERROR); |
11111 ssl_data4.cert_request_info = cert_request.get(); | 11111 ssl_data4.cert_request_info = cert_request.get(); |
11112 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); | 11112 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data4); |
11113 StaticSocketDataProvider data4(NULL, 0, NULL, 0); | 11113 StaticSocketDataProvider data4(NULL, 0, NULL, 0); |
11114 session_deps_.socket_factory->AddSocketDataProvider(&data4); | 11114 session_deps_.socket_factory->AddSocketDataProvider(&data4); |
11115 | 11115 |
11116 // Need one more if TLSv1.2 is enabled. | |
11117 SSLSocketDataProvider ssl_data5(ASYNC, ERR_SSL_PROTOCOL_ERROR); | |
11118 ssl_data5.cert_request_info = cert_request.get(); | |
11119 session_deps_.socket_factory->AddSSLSocketDataProvider(&ssl_data5); | |
11120 StaticSocketDataProvider data5(NULL, 0, NULL, 0); | |
11121 session_deps_.socket_factory->AddSocketDataProvider(&data5); | |
11122 | |
11123 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); | 11116 scoped_refptr<HttpNetworkSession> session(CreateSession(&session_deps_)); |
11124 scoped_ptr<HttpTransaction> trans( | 11117 scoped_ptr<HttpTransaction> trans( |
11125 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); | 11118 new HttpNetworkTransaction(DEFAULT_PRIORITY, session.get())); |
11126 | 11119 |
11127 // Begin the SSL handshake with the peer. This consumes ssl_data1. | 11120 // Begin the SSL handshake with the peer. This consumes ssl_data1. |
11128 TestCompletionCallback callback; | 11121 TestCompletionCallback callback; |
11129 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); | 11122 int rv = trans->Start(&request_info, callback.callback(), BoundNetLog()); |
11130 ASSERT_EQ(ERR_IO_PENDING, rv); | 11123 ASSERT_EQ(ERR_IO_PENDING, rv); |
11131 | 11124 |
11132 // Complete the SSL handshake, which should abort due to requiring a | 11125 // Complete the SSL handshake, which should abort due to requiring a |
(...skipping 3146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
14279 ASSERT_TRUE(response); | 14272 ASSERT_TRUE(response); |
14280 ASSERT_TRUE(response->headers.get()); | 14273 ASSERT_TRUE(response->headers.get()); |
14281 | 14274 |
14282 EXPECT_EQ(101, response->headers->response_code()); | 14275 EXPECT_EQ(101, response->headers->response_code()); |
14283 | 14276 |
14284 trans.reset(); | 14277 trans.reset(); |
14285 session->CloseAllConnections(); | 14278 session->CloseAllConnections(); |
14286 } | 14279 } |
14287 | 14280 |
14288 } // namespace net | 14281 } // namespace net |
OLD | NEW |