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 // Compute a unique string for the SSL session cache. | |
wtc
2014/08/14 00:46:45
Nit: delete this comment -- just rely on the comme
mshelley
2014/08/14 20:01:36
Done.
| |
378 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
379 std::string result = host_and_port_.ToString(); | |
380 result.append("/"); | |
381 result.append(ssl_session_cache_shard_); | |
382 return result; | |
383 } | |
384 | |
377 bool SSLClientSocketOpenSSL::InSessionCache() const { | 385 bool SSLClientSocketOpenSSL::InSessionCache() const { |
378 SSLContext* context = SSLContext::GetInstance(); | 386 SSLContext* context = SSLContext::GetInstance(); |
379 std::string cache_key = GetSessionCacheKey(); | 387 std::string cache_key = GetSessionCacheKey(); |
380 return context->session_cache()->SSLSessionIsInCache(cache_key); | 388 return context->session_cache()->SSLSessionIsInCache(cache_key); |
381 } | 389 } |
382 | 390 |
383 void SSLClientSocketOpenSSL::SetHandshakeCompletionCallback( | 391 void SSLClientSocketOpenSSL::SetHandshakeCompletionCallback( |
384 const base::Closure& callback) { | 392 const base::Closure& callback) { |
385 handshake_completion_callback_ = callback; | 393 handshake_completion_callback_ = callback; |
386 } | 394 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
838 user_write_buf_ = NULL; | 846 user_write_buf_ = NULL; |
839 user_write_buf_len_ = 0; | 847 user_write_buf_len_ = 0; |
840 if (rv < 0) { | 848 if (rv < 0) { |
841 // Failure of a write attempt may indicate a failed false start | 849 // Failure of a write attempt may indicate a failed false start |
842 // connection. | 850 // connection. |
843 OnHandshakeCompletion(); | 851 OnHandshakeCompletion(); |
844 } | 852 } |
845 base::ResetAndReturn(&user_write_callback_).Run(rv); | 853 base::ResetAndReturn(&user_write_callback_).Run(rv); |
846 } | 854 } |
847 | 855 |
848 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { | |
849 return CreateSessionCacheKey(host_and_port_, ssl_session_cache_shard_); | |
850 } | |
851 | |
852 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { | 856 void SSLClientSocketOpenSSL::OnHandshakeCompletion() { |
853 if (!handshake_completion_callback_.is_null()) | 857 if (!handshake_completion_callback_.is_null()) |
854 base::ResetAndReturn(&handshake_completion_callback_).Run(); | 858 base::ResetAndReturn(&handshake_completion_callback_).Run(); |
855 } | 859 } |
856 | 860 |
857 bool SSLClientSocketOpenSSL::DoTransportIO() { | 861 bool SSLClientSocketOpenSSL::DoTransportIO() { |
858 bool network_moved = false; | 862 bool network_moved = false; |
859 int rv; | 863 int rv; |
860 // Read and write as much data as possible. The loop is necessary because | 864 // Read and write as much data as possible. The loop is necessary because |
861 // Write() may return synchronously. | 865 // 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_) | 1639 if (handshake_succeeded_ && marked_session_as_good_) |
1636 OnHandshakeCompletion(); | 1640 OnHandshakeCompletion(); |
1637 } | 1641 } |
1638 | 1642 |
1639 scoped_refptr<X509Certificate> | 1643 scoped_refptr<X509Certificate> |
1640 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1644 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1641 return server_cert_; | 1645 return server_cert_; |
1642 } | 1646 } |
1643 | 1647 |
1644 } // namespace net | 1648 } // namespace net |
OLD | NEW |