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 <memory> | 5 #include <memory> |
6 #include <utility> | 6 #include <utility> |
7 | 7 |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 | 10 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
78 #include "net/http/http_util.h" | 78 #include "net/http/http_util.h" |
79 #include "net/log/net_log.h" | 79 #include "net/log/net_log.h" |
80 #include "net/log/test_net_log.h" | 80 #include "net/log/test_net_log.h" |
81 #include "net/log/test_net_log_entry.h" | 81 #include "net/log/test_net_log_entry.h" |
82 #include "net/log/test_net_log_util.h" | 82 #include "net/log/test_net_log_util.h" |
83 #include "net/nqe/external_estimate_provider.h" | 83 #include "net/nqe/external_estimate_provider.h" |
84 #include "net/proxy/proxy_service.h" | 84 #include "net/proxy/proxy_service.h" |
85 #include "net/socket/ssl_client_socket.h" | 85 #include "net/socket/ssl_client_socket.h" |
86 #include "net/ssl/channel_id_service.h" | 86 #include "net/ssl/channel_id_service.h" |
87 #include "net/ssl/default_channel_id_store.h" | 87 #include "net/ssl/default_channel_id_store.h" |
88 #include "net/ssl/ssl_cipher_suite_names.h" | |
89 #include "net/ssl/ssl_connection_status_flags.h" | 88 #include "net/ssl/ssl_connection_status_flags.h" |
90 #include "net/ssl/ssl_server_config.h" | 89 #include "net/ssl/ssl_server_config.h" |
91 #include "net/ssl/token_binding.h" | 90 #include "net/ssl/token_binding.h" |
92 #include "net/test/cert_test_util.h" | 91 #include "net/test/cert_test_util.h" |
93 #include "net/test/embedded_test_server/embedded_test_server.h" | 92 #include "net/test/embedded_test_server/embedded_test_server.h" |
94 #include "net/test/embedded_test_server/http_request.h" | 93 #include "net/test/embedded_test_server/http_request.h" |
95 #include "net/test/embedded_test_server/http_response.h" | 94 #include "net/test/embedded_test_server/http_response.h" |
96 #include "net/test/spawned_test_server/spawned_test_server.h" | 95 #include "net/test/spawned_test_server/spawned_test_server.h" |
97 #include "net/test/url_request/url_request_failed_job.h" | 96 #include "net/test/url_request/url_request_failed_job.h" |
98 #include "net/url_request/data_protocol_handler.h" | 97 #include "net/url_request/data_protocol_handler.h" |
(...skipping 17 matching lines...) Expand all Loading... | |
116 #endif | 115 #endif |
117 | 116 |
118 #if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID) | 117 #if !defined(DISABLE_FTP_SUPPORT) && !defined(OS_ANDROID) |
119 #include "net/ftp/ftp_network_layer.h" | 118 #include "net/ftp/ftp_network_layer.h" |
120 #include "net/url_request/ftp_protocol_handler.h" | 119 #include "net/url_request/ftp_protocol_handler.h" |
121 #endif | 120 #endif |
122 | 121 |
123 #if defined(OS_WIN) | 122 #if defined(OS_WIN) |
124 #include "base/win/scoped_com_initializer.h" | 123 #include "base/win/scoped_com_initializer.h" |
125 #include "base/win/scoped_comptr.h" | 124 #include "base/win/scoped_comptr.h" |
126 #include "base/win/windows_version.h" | |
127 #endif | 125 #endif |
128 | 126 |
129 using base::ASCIIToUTF16; | 127 using base::ASCIIToUTF16; |
130 using base::Time; | 128 using base::Time; |
131 using std::string; | 129 using std::string; |
132 | 130 |
133 namespace net { | 131 namespace net { |
134 | 132 |
135 namespace { | 133 namespace { |
136 | 134 |
(...skipping 8662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8799 // insert xyz | 8797 // insert xyz |
8800 // | 8798 // |
8801 // With a newline at the end which makes the split think that there are | 8799 // With a newline at the end which makes the split think that there are |
8802 // three lines. | 8800 // three lines. |
8803 | 8801 |
8804 EXPECT_EQ(1, d.response_started_count()); | 8802 EXPECT_EQ(1, d.response_started_count()); |
8805 AssertTwoDistinctSessionsInserted(d.data_received()); | 8803 AssertTwoDistinctSessionsInserted(d.data_received()); |
8806 } | 8804 } |
8807 } | 8805 } |
8808 | 8806 |
8809 #if defined(OS_WIN) | |
8810 | |
8811 namespace { | |
8812 | |
8813 bool IsECDSACipherSuite(uint16_t cipher_suite) { | |
8814 const char* key_exchange; | |
8815 const char* cipher; | |
8816 const char* mac; | |
8817 bool is_aead; | |
8818 SSLCipherSuiteToStrings(&key_exchange, &cipher, &mac, &is_aead, cipher_suite); | |
8819 return std::string(key_exchange).find("ECDSA") != std::string::npos; | |
8820 } | |
8821 | |
8822 } // namespace | |
8823 | |
8824 // Test that ECDSA is disabled on Windows XP, where ECDSA certificates cannot be | |
8825 // verified. | |
8826 TEST_F(HTTPSRequestTest, DisableECDSAOnXP) { | |
8827 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { | |
8828 LOG(INFO) << "Skipping test on this version."; | |
8829 return; | |
8830 } | |
8831 | |
8832 EmbeddedTestServer test_server(net::EmbeddedTestServer::TYPE_HTTPS); | |
8833 test_server.ServeFilesFromSourceDirectory("net/data/ssl"); | |
8834 ASSERT_TRUE(test_server.Start()); | |
8835 | |
8836 TestDelegate d; | |
8837 std::unique_ptr<URLRequest> r(default_context_.CreateRequest( | |
8838 test_server.GetURL("/client-cipher-list"), DEFAULT_PRIORITY, &d)); | |
8839 r->Start(); | |
8840 EXPECT_TRUE(r->is_pending()); | |
8841 | |
8842 base::RunLoop().Run(); | |
8843 | |
8844 EXPECT_EQ(1, d.response_started_count()); | |
8845 std::vector<std::string> lines = base::SplitString( | |
8846 d.data_received(), "\n", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
8847 | |
8848 for (size_t i = 0; i < lines.size(); i++) { | |
8849 int cipher_suite; | |
8850 ASSERT_TRUE(base::StringToInt(lines[i], &cipher_suite)); | |
8851 EXPECT_FALSE(IsECDSACipherSuite(cipher_suite)) | |
8852 << "ClientHello advertised " << cipher_suite; | |
8853 } | |
8854 } | |
8855 | |
8856 #endif // OS_WIN | |
8857 | |
8858 class FallbackTestURLRequestContext : public TestURLRequestContext { | 8807 class FallbackTestURLRequestContext : public TestURLRequestContext { |
8859 public: | 8808 public: |
8860 explicit FallbackTestURLRequestContext(bool delay_initialization) | 8809 explicit FallbackTestURLRequestContext(bool delay_initialization) |
8861 : TestURLRequestContext(delay_initialization) {} | 8810 : TestURLRequestContext(delay_initialization) {} |
8862 | 8811 |
8863 void set_fallback_min_version(uint16_t version) { | 8812 void set_fallback_min_version(uint16_t version) { |
8864 TestSSLConfigService* ssl_config_service = new TestSSLConfigService( | 8813 TestSSLConfigService* ssl_config_service = new TestSSLConfigService( |
8865 true /* check for EV */, false /* online revocation checking */, | 8814 true /* check for EV */, false /* online revocation checking */, |
8866 false /* require rev. checking for local | 8815 false /* require rev. checking for local |
8867 anchors */, | 8816 anchors */, |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9308 return false; | 9257 return false; |
9309 #else | 9258 #else |
9310 return true; | 9259 return true; |
9311 #endif | 9260 #endif |
9312 } | 9261 } |
9313 | 9262 |
9314 static bool SystemSupportsOCSP() { | 9263 static bool SystemSupportsOCSP() { |
9315 #if defined(USE_OPENSSL_CERTS) | 9264 #if defined(USE_OPENSSL_CERTS) |
9316 // http://crbug.com/117478 - OpenSSL does not support OCSP. | 9265 // http://crbug.com/117478 - OpenSSL does not support OCSP. |
9317 return false; | 9266 return false; |
9318 #elif defined(OS_WIN) | 9267 #elif defined(OS_WIN) |
svaldez
2016/06/03 14:57:28
nit: Just remove the OS_WIN branch.
davidben
2016/06/03 16:38:38
Done. Also simplified some of the others. (We're n
| |
9319 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9268 return true; |
9320 #elif defined(OS_ANDROID) | 9269 #elif defined(OS_ANDROID) |
9321 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. | 9270 // TODO(jnd): http://crbug.com/117478 - EV verification is not yet supported. |
9322 return false; | 9271 return false; |
9323 #else | 9272 #else |
9324 return true; | 9273 return true; |
9325 #endif | 9274 #endif |
9326 } | 9275 } |
9327 | 9276 |
9328 static bool SystemSupportsOCSPStapling() { | 9277 static bool SystemSupportsOCSPStapling() { |
9329 #if defined(USE_NSS_CERTS) | 9278 #if defined(USE_NSS_CERTS) |
9330 return true; | 9279 return true; |
9331 #elif defined(OS_WIN) | 9280 #elif defined(OS_WIN) |
9332 return base::win::GetVersion() >= base::win::VERSION_VISTA; | 9281 return true; |
9333 #else | 9282 #else |
9334 return false; | 9283 return false; |
9335 #endif | 9284 #endif |
9336 } | 9285 } |
9337 | 9286 |
9338 TEST_F(HTTPSOCSPTest, Valid) { | 9287 TEST_F(HTTPSOCSPTest, Valid) { |
9339 if (!SystemSupportsOCSP()) { | 9288 if (!SystemSupportsOCSP()) { |
9340 LOG(WARNING) << "Skipping test because system doesn't support OCSP"; | 9289 LOG(WARNING) << "Skipping test because system doesn't support OCSP"; |
9341 return; | 9290 return; |
9342 } | 9291 } |
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
10099 AddTestInterceptor()->set_main_intercept_job(std::move(job)); | 10048 AddTestInterceptor()->set_main_intercept_job(std::move(job)); |
10100 | 10049 |
10101 req->Start(); | 10050 req->Start(); |
10102 req->Cancel(); | 10051 req->Cancel(); |
10103 base::RunLoop().RunUntilIdle(); | 10052 base::RunLoop().RunUntilIdle(); |
10104 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); | 10053 EXPECT_EQ(URLRequestStatus::CANCELED, req->status().status()); |
10105 EXPECT_EQ(0, d.received_redirect_count()); | 10054 EXPECT_EQ(0, d.received_redirect_count()); |
10106 } | 10055 } |
10107 | 10056 |
10108 } // namespace net | 10057 } // namespace net |
OLD | NEW |