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