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 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 // TransportSecurityState. | 467 // TransportSecurityState. |
468 DCHECK(transport_security_state_); | 468 DCHECK(transport_security_state_); |
469 | 469 |
470 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); | 470 net_log_.BeginEvent(NetLog::TYPE_SSL_CONNECT); |
471 | 471 |
472 // Set up new ssl object. | 472 // Set up new ssl object. |
473 int rv = Init(); | 473 int rv = Init(); |
474 if (rv != OK) { | 474 if (rv != OK) { |
475 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 475 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
476 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(rv)); | 476 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(rv)); |
| 477 if (ssl_config_.fastradio_padding_eligible) |
| 478 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error_ClientPadding", |
| 479 std::abs(rv)); |
477 return rv; | 480 return rv; |
478 } | 481 } |
479 | 482 |
480 // Set SSL to client mode. Handshake happens in the loop below. | 483 // Set SSL to client mode. Handshake happens in the loop below. |
481 SSL_set_connect_state(ssl_); | 484 SSL_set_connect_state(ssl_); |
482 | 485 |
| 486 // Enable fastradio padding. |
| 487 SSL_enable_fastradio_padding(ssl_, ssl_config_.enable_fastradio_padding); |
| 488 |
483 GotoState(STATE_HANDSHAKE); | 489 GotoState(STATE_HANDSHAKE); |
484 rv = DoHandshakeLoop(OK); | 490 rv = DoHandshakeLoop(OK); |
485 if (rv == ERR_IO_PENDING) { | 491 if (rv == ERR_IO_PENDING) { |
486 user_connect_callback_ = callback; | 492 user_connect_callback_ = callback; |
487 } else { | 493 } else { |
488 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 494 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
489 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(rv)); | 495 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(rv)); |
| 496 if (ssl_config_.fastradio_padding_eligible) |
| 497 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error_ClientPadding", |
| 498 std::abs(rv)); |
490 if (rv < OK) | 499 if (rv < OK) |
491 OnHandshakeCompletion(); | 500 OnHandshakeCompletion(); |
492 } | 501 } |
493 | 502 |
494 return rv > OK ? OK : rv; | 503 return rv > OK ? OK : rv; |
495 } | 504 } |
496 | 505 |
497 void SSLClientSocketOpenSSL::Disconnect() { | 506 void SSLClientSocketOpenSSL::Disconnect() { |
498 // If a handshake was pending (Connect() had been called), notify interested | 507 // If a handshake was pending (Connect() had been called), notify interested |
499 // parties that it's been aborted now. If the handshake had already | 508 // parties that it's been aborted now. If the handshake had already |
(...skipping 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 } | 1369 } |
1361 } | 1370 } |
1362 } | 1371 } |
1363 } | 1372 } |
1364 | 1373 |
1365 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { | 1374 void SSLClientSocketOpenSSL::OnHandshakeIOComplete(int result) { |
1366 int rv = DoHandshakeLoop(result); | 1375 int rv = DoHandshakeLoop(result); |
1367 if (rv != ERR_IO_PENDING) { | 1376 if (rv != ERR_IO_PENDING) { |
1368 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); | 1377 net_log_.EndEventWithNetErrorCode(NetLog::TYPE_SSL_CONNECT, rv); |
1369 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(rv)); | 1378 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error", std::abs(rv)); |
| 1379 if (ssl_config_.fastradio_padding_eligible) |
| 1380 UMA_HISTOGRAM_SPARSE_SLOWLY("Net.SSL_Connection_Error_ClientPadding", |
| 1381 std::abs(rv)); |
1370 DoConnectCallback(rv); | 1382 DoConnectCallback(rv); |
1371 } | 1383 } |
1372 } | 1384 } |
1373 | 1385 |
1374 void SSLClientSocketOpenSSL::OnSendComplete(int result) { | 1386 void SSLClientSocketOpenSSL::OnSendComplete(int result) { |
1375 if (next_handshake_state_ == STATE_HANDSHAKE) { | 1387 if (next_handshake_state_ == STATE_HANDSHAKE) { |
1376 // In handshake phase. | 1388 // In handshake phase. |
1377 OnHandshakeIOComplete(result); | 1389 OnHandshakeIOComplete(result); |
1378 return; | 1390 return; |
1379 } | 1391 } |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2023 ct::SCT_STATUS_LOG_UNKNOWN)); | 2035 ct::SCT_STATUS_LOG_UNKNOWN)); |
2024 } | 2036 } |
2025 } | 2037 } |
2026 | 2038 |
2027 scoped_refptr<X509Certificate> | 2039 scoped_refptr<X509Certificate> |
2028 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 2040 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
2029 return server_cert_; | 2041 return server_cert_; |
2030 } | 2042 } |
2031 | 2043 |
2032 } // namespace net | 2044 } // namespace net |
OLD | NEW |