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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 handshake_succeeded_(false), | 367 handshake_succeeded_(false), |
368 marked_session_as_good_(false), | 368 marked_session_as_good_(false), |
369 transport_security_state_(context.transport_security_state), | 369 transport_security_state_(context.transport_security_state), |
370 net_log_(transport_->socket()->NetLog()) { | 370 net_log_(transport_->socket()->NetLog()) { |
371 } | 371 } |
372 | 372 |
373 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { | 373 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { |
374 Disconnect(); | 374 Disconnect(); |
375 } | 375 } |
376 | 376 |
| 377 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { |
| 378 std::string result = host_and_port_.ToString(); |
| 379 result.append("/"); |
| 380 result.append(ssl_session_cache_shard_); |
| 381 return result; |
| 382 } |
| 383 |
377 bool SSLClientSocketOpenSSL::InSessionCache() const { | 384 bool SSLClientSocketOpenSSL::InSessionCache() const { |
378 SSLContext* context = SSLContext::GetInstance(); | 385 SSLContext* context = SSLContext::GetInstance(); |
379 std::string cache_key = GetSessionCacheKey(); | 386 std::string cache_key = GetSessionCacheKey(); |
380 return context->session_cache()->SSLSessionIsInCache(cache_key); | 387 return context->session_cache()->SSLSessionIsInCache(cache_key); |
381 } | 388 } |
382 | 389 |
383 void SSLClientSocketOpenSSL::SetHandshakeCompletionCallback( | 390 void SSLClientSocketOpenSSL::SetHandshakeCompletionCallback( |
384 const base::Closure& callback) { | 391 const base::Closure& callback) { |
385 handshake_completion_callback_ = callback; | 392 handshake_completion_callback_ = callback; |
386 } | 393 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 user_write_buf_ = NULL; | 845 user_write_buf_ = NULL; |
839 user_write_buf_len_ = 0; | 846 user_write_buf_len_ = 0; |
840 if (rv < 0) { | 847 if (rv < 0) { |
841 // Failure of a write attempt may indicate a failed false start | 848 // Failure of a write attempt may indicate a failed false start |
842 // connection. | 849 // connection. |
843 OnHandshakeCompletion(); | 850 OnHandshakeCompletion(); |
844 } | 851 } |
845 base::ResetAndReturn(&user_write_callback_).Run(rv); | 852 base::ResetAndReturn(&user_write_callback_).Run(rv); |
846 } | 853 } |
847 | 854 |
848 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
849 return CreateSessionCacheKey(host_and_port_, ssl_session_cache_shard_); | |
850 } | |
851 | |
852 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { | 855 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { |
853 if (!handshake_completion_callback_.is_null()) | 856 if (!handshake_completion_callback_.is_null()) |
854 base::ResetAndReturn(&handshake_completion_callback_).Run(); | 857 base::ResetAndReturn(&handshake_completion_callback_).Run(); |
855 } | 858 } |
856 | 859 |
857 bool SSLClientSocketOpenSSL::DoTransportIO() { | 860 bool SSLClientSocketOpenSSL::DoTransportIO() { |
858 bool network_moved = false; | 861 bool network_moved = false; |
859 int rv; | 862 int rv; |
860 // Read and write as much data as possible. The loop is necessary because | 863 // Read and write as much data as possible. The loop is necessary because |
861 // Write() may return synchronously. | 864 // Write() may return synchronously. |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 if (handshake_succeeded_ && marked_session_as_good_) | 1638 if (handshake_succeeded_ && marked_session_as_good_) |
1636 OnHandshakeCompletion(); | 1639 OnHandshakeCompletion(); |
1637 } | 1640 } |
1638 | 1641 |
1639 scoped_refptr<X509Certificate> | 1642 scoped_refptr<X509Certificate> |
1640 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1643 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1641 return server_cert_; | 1644 return server_cert_; |
1642 } | 1645 } |
1643 | 1646 |
1644 } // namespace net | 1647 } // namespace net |
OLD | NEW |