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 // OpenSSL binding for SSLClientSocket. The class layout and general principle | 5 // OpenSSL binding for SSLClientSocket. The class layout and general principle |
6 // of operation is derived from SSLClientSocketNSS. | 6 // of operation is derived from SSLClientSocketNSS. |
7 | 7 |
8 #include "net/socket/ssl_client_socket_openssl.h" | 8 #include "net/socket/ssl_client_socket_openssl.h" |
9 | 9 |
10 #include <errno.h> | 10 #include <errno.h> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "base/lazy_instance.h" | 23 #include "base/lazy_instance.h" |
24 #include "base/macros.h" | 24 #include "base/macros.h" |
25 #include "base/memory/singleton.h" | 25 #include "base/memory/singleton.h" |
26 #include "base/metrics/histogram_macros.h" | 26 #include "base/metrics/histogram_macros.h" |
27 #include "base/metrics/sparse_histogram.h" | 27 #include "base/metrics/sparse_histogram.h" |
28 #include "base/profiler/scoped_tracker.h" | 28 #include "base/profiler/scoped_tracker.h" |
29 #include "base/strings/string_number_conversions.h" | 29 #include "base/strings/string_number_conversions.h" |
30 #include "base/strings/string_piece.h" | 30 #include "base/strings/string_piece.h" |
31 #include "base/synchronization/lock.h" | 31 #include "base/synchronization/lock.h" |
32 #include "base/threading/thread_local.h" | 32 #include "base/threading/thread_local.h" |
| 33 #include "base/trace_event/trace_event.h" |
33 #include "base/values.h" | 34 #include "base/values.h" |
34 #include "crypto/auto_cbb.h" | 35 #include "crypto/auto_cbb.h" |
35 #include "crypto/ec_private_key.h" | 36 #include "crypto/ec_private_key.h" |
36 #include "crypto/openssl_util.h" | 37 #include "crypto/openssl_util.h" |
37 #include "crypto/scoped_openssl_types.h" | 38 #include "crypto/scoped_openssl_types.h" |
38 #include "net/base/ip_address.h" | 39 #include "net/base/ip_address.h" |
39 #include "net/base/net_errors.h" | 40 #include "net/base/net_errors.h" |
40 #include "net/cert/cert_verifier.h" | 41 #include "net/cert/cert_verifier.h" |
41 #include "net/cert/ct_ev_whitelist.h" | 42 #include "net/cert/ct_ev_whitelist.h" |
42 #include "net/cert/ct_policy_enforcer.h" | 43 #include "net/cert/ct_policy_enforcer.h" |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1450 OnHandshakeIOComplete(result); | 1451 OnHandshakeIOComplete(result); |
1451 return; | 1452 return; |
1452 } | 1453 } |
1453 | 1454 |
1454 // During a renegotiation, a Read call may also be blocked on a transport | 1455 // During a renegotiation, a Read call may also be blocked on a transport |
1455 // write, so retry both operations. | 1456 // write, so retry both operations. |
1456 PumpReadWriteEvents(); | 1457 PumpReadWriteEvents(); |
1457 } | 1458 } |
1458 | 1459 |
1459 void SSLClientSocketOpenSSL::OnRecvComplete(int result) { | 1460 void SSLClientSocketOpenSSL::OnRecvComplete(int result) { |
| 1461 TRACE_EVENT0("net", "SSLClientSocketOpenSSL::OnRecvComplete"); |
1460 if (next_handshake_state_ == STATE_HANDSHAKE) { | 1462 if (next_handshake_state_ == STATE_HANDSHAKE) { |
1461 // In handshake phase. | 1463 // In handshake phase. |
1462 OnHandshakeIOComplete(result); | 1464 OnHandshakeIOComplete(result); |
1463 return; | 1465 return; |
1464 } | 1466 } |
1465 | 1467 |
1466 // Network layer received some data, check if client requested to read | 1468 // Network layer received some data, check if client requested to read |
1467 // decrypted data. | 1469 // decrypted data. |
1468 if (!user_read_buf_.get()) | 1470 if (!user_read_buf_.get()) |
1469 return; | 1471 return; |
1470 | 1472 |
1471 int rv = DoReadLoop(); | 1473 int rv = DoReadLoop(); |
1472 if (rv != ERR_IO_PENDING) | 1474 if (rv != ERR_IO_PENDING) |
1473 DoReadCallback(rv); | 1475 DoReadCallback(rv); |
1474 } | 1476 } |
1475 | 1477 |
1476 int SSLClientSocketOpenSSL::DoHandshakeLoop(int last_io_result) { | 1478 int SSLClientSocketOpenSSL::DoHandshakeLoop(int last_io_result) { |
| 1479 TRACE_EVENT0("net", "SSLClientSocketOpenSSL::DoHandshakeLoop"); |
1477 int rv = last_io_result; | 1480 int rv = last_io_result; |
1478 do { | 1481 do { |
1479 // Default to STATE_NONE for next state. | 1482 // Default to STATE_NONE for next state. |
1480 // (This is a quirk carried over from the windows | 1483 // (This is a quirk carried over from the windows |
1481 // implementation. It makes reading the logs a bit harder.) | 1484 // implementation. It makes reading the logs a bit harder.) |
1482 // State handlers can and often do call GotoState just | 1485 // State handlers can and often do call GotoState just |
1483 // to stay in the current state. | 1486 // to stay in the current state. |
1484 State state = next_handshake_state_; | 1487 State state = next_handshake_state_; |
1485 GotoState(STATE_NONE); | 1488 GotoState(STATE_NONE); |
1486 switch (state) { | 1489 switch (state) { |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2302 tb_was_negotiated_ = true; | 2305 tb_was_negotiated_ = true; |
2303 return 1; | 2306 return 1; |
2304 } | 2307 } |
2305 } | 2308 } |
2306 | 2309 |
2307 *out_alert_value = SSL_AD_ILLEGAL_PARAMETER; | 2310 *out_alert_value = SSL_AD_ILLEGAL_PARAMETER; |
2308 return 0; | 2311 return 0; |
2309 } | 2312 } |
2310 | 2313 |
2311 } // namespace net | 2314 } // namespace net |
OLD | NEW |