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/socket/ssl_client_socket.h" | 5 #include "net/socket/ssl_client_socket.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1126 // test that the handshake has finished. This is because it may be | 1126 // test that the handshake has finished. This is because it may be |
| 1127 // desirable to disconnect the socket before showing a user prompt, since | 1127 // desirable to disconnect the socket before showing a user prompt, since |
| 1128 // the user may take indefinitely long to respond. | 1128 // the user may take indefinitely long to respond. |
| 1129 TestNetLogEntry::List entries; | 1129 TestNetLogEntry::List entries; |
| 1130 log_.GetEntries(&entries); | 1130 log_.GetEntries(&entries); |
| 1131 EXPECT_TRUE(LogContainsEndEvent(entries, -1, NetLogEventType::SSL_CONNECT)); | 1131 EXPECT_TRUE(LogContainsEndEvent(entries, -1, NetLogEventType::SSL_CONNECT)); |
| 1132 } | 1132 } |
| 1133 | 1133 |
| 1134 #if defined(OS_WIN) | 1134 #if defined(OS_WIN) |
| 1135 // Tests that certificates parsable by SSLClientSocket's internal SSL | 1135 // Tests that certificates parsable by SSLClientSocket's internal SSL |
| 1136 // implementation, but not X509Certificate are treated as fatal non-certificate | 1136 // implementation, but not X509Certificate are treated as fatal connection |
| 1137 // errors. This is regression test for https://crbug.com/91341. | 1137 // errors. This is a regression test for https://crbug.com/91341. |
| 1138 TEST_F(SSLClientSocketTest, ConnectBadValidity) { | 1138 TEST_F(SSLClientSocketTest, ConnectBadValidity) { |
| 1139 SpawnedTestServer::SSLOptions ssl_options( | 1139 SpawnedTestServer::SSLOptions ssl_options( |
| 1140 SpawnedTestServer::SSLOptions::CERT_BAD_VALIDITY); | 1140 SpawnedTestServer::SSLOptions::CERT_BAD_VALIDITY); |
| 1141 ASSERT_TRUE(StartTestServer(ssl_options)); | 1141 ASSERT_TRUE(StartTestServer(ssl_options)); |
| 1142 SSLConfig ssl_config; | 1142 SSLConfig ssl_config; |
| 1143 int rv; | 1143 int rv; |
| 1144 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); | 1144 ASSERT_TRUE(CreateAndConnectSSLClientSocket(ssl_config, &rv)); |
| 1145 | 1145 |
| 1146 EXPECT_THAT(rv, IsError(ERR_SSL_SERVER_CERT_BAD_FORMAT)); | 1146 EXPECT_THAT(rv, IsError(ERR_SSL_SERVER_CERT_BAD_FORMAT)); |
| 1147 EXPECT_FALSE(IsCertificateError(rv)); | 1147 EXPECT_FALSE(IsCertificateError(rv)); |
| 1148 | |
| 1149 SSLInfo ssl_info; | |
| 1150 ASSERT_TRUE(sock_->GetSSLInfo(&ssl_info)); | |
| 1151 EXPECT_FALSE(ssl_info.cert); | |
|
davidben
2017/03/07 00:19:34
Note this is a behavior change: before we'd get fa
| |
| 1152 } | 1148 } |
| 1153 #endif // defined(OS_WIN) | 1149 #endif // defined(OS_WIN) |
| 1154 | 1150 |
| 1155 // Attempt to connect to a page which requests a client certificate. It should | 1151 // Attempt to connect to a page which requests a client certificate. It should |
| 1156 // return an error code on connect. | 1152 // return an error code on connect. |
| 1157 TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { | 1153 TEST_F(SSLClientSocketTest, ConnectClientAuthCertRequested) { |
| 1158 SpawnedTestServer::SSLOptions ssl_options; | 1154 SpawnedTestServer::SSLOptions ssl_options; |
| 1159 ssl_options.request_client_certificate = true; | 1155 ssl_options.request_client_certificate = true; |
| 1160 ASSERT_TRUE(StartTestServer(ssl_options)); | 1156 ASSERT_TRUE(StartTestServer(ssl_options)); |
| 1161 | 1157 |
| (...skipping 2453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3615 // Dump memory again and check that |buffer_size| contain the read buffer. | 3611 // Dump memory again and check that |buffer_size| contain the read buffer. |
| 3616 StreamSocket::SocketMemoryStats stats2; | 3612 StreamSocket::SocketMemoryStats stats2; |
| 3617 sock_->DumpMemoryStats(&stats2); | 3613 sock_->DumpMemoryStats(&stats2); |
| 3618 EXPECT_EQ(17 * 1024u, stats2.buffer_size); | 3614 EXPECT_EQ(17 * 1024u, stats2.buffer_size); |
| 3619 EXPECT_EQ(1u, stats2.cert_count); | 3615 EXPECT_EQ(1u, stats2.cert_count); |
| 3620 EXPECT_LT(0u, stats2.cert_size); | 3616 EXPECT_LT(0u, stats2.cert_size); |
| 3621 EXPECT_LT(17 * 1024u, stats2.total_size); | 3617 EXPECT_LT(17 * 1024u, stats2.total_size); |
| 3622 } | 3618 } |
| 3623 | 3619 |
| 3624 } // namespace net | 3620 } // namespace net |
| OLD | NEW |