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 <openssl/err.h> | 10 #include <openssl/err.h> |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 return SSL_CONNECTION_VERSION_TLS1_1; | 82 return SSL_CONNECTION_VERSION_TLS1_1; |
83 case 0x0303: | 83 case 0x0303: |
84 return SSL_CONNECTION_VERSION_TLS1_2; | 84 return SSL_CONNECTION_VERSION_TLS1_2; |
85 default: | 85 default: |
86 return SSL_CONNECTION_VERSION_UNKNOWN; | 86 return SSL_CONNECTION_VERSION_UNKNOWN; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 // Compute a unique key string for the SSL session cache. |socket| is an | 90 // Compute a unique key string for the SSL session cache. |socket| is an |
91 // input socket object. Return a string. | 91 // input socket object. Return a string. |
92 std::string GetSocketSessionCacheKey(const SSLClientSocketOpenSSL& socket) { | 92 std::string GetSocketSessionCacheKey(const SSLClientSocketOpenSSL& socket) { |
wtc
2014/06/27 00:36:49
Nit: this function probably should become a method
mshelley
2014/07/01 02:35:22
Done.
| |
93 std::string result = socket.host_and_port().ToString(); | 93 std::string result = socket.host_and_port().ToString(); |
94 result.append("/"); | 94 result.append("/"); |
95 result.append(socket.ssl_session_cache_shard()); | 95 result.append(socket.ssl_session_cache_shard()); |
96 return result; | 96 return result; |
97 } | 97 } |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 | 100 |
101 class SSLClientSocketOpenSSL::SSLContext { | 101 class SSLClientSocketOpenSSL::SSLContext { |
102 public: | 102 public: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 next_handshake_state_(STATE_NONE), | 359 next_handshake_state_(STATE_NONE), |
360 npn_status_(kNextProtoUnsupported), | 360 npn_status_(kNextProtoUnsupported), |
361 channel_id_request_return_value_(ERR_UNEXPECTED), | 361 channel_id_request_return_value_(ERR_UNEXPECTED), |
362 channel_id_xtn_negotiated_(false), | 362 channel_id_xtn_negotiated_(false), |
363 net_log_(transport_->socket()->NetLog()) {} | 363 net_log_(transport_->socket()->NetLog()) {} |
364 | 364 |
365 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { | 365 SSLClientSocketOpenSSL::~SSLClientSocketOpenSSL() { |
366 Disconnect(); | 366 Disconnect(); |
367 } | 367 } |
368 | 368 |
369 bool SSLClientSocketOpenSSL::InSessionCache() const { | |
370 SSLContext* context = SSLContext::GetInstance(); | |
371 std::string cache_key = GetSocketSessionCacheKey(*this); | |
372 return context->session_cache()->SSLSessionIsInCache(cache_key); | |
373 } | |
374 | |
375 void SSLClientSocketOpenSSL::OnSessionComplete(const base::Closure& cb) const { | |
376 SSLContext* context = SSLContext::GetInstance(); | |
377 context->session_cache()->NotifyOnSessionAdded(ssl_, cb); | |
378 } | |
379 | |
380 void SSLClientSocketOpenSSL::OnSocketFailure(const base::Closure& cb) { | |
381 error_callback_ = cb; | |
wtc
2014/06/27 00:36:49
IMPORTANT: the error_callback_ member is not being
mshelley
2014/07/01 02:35:22
Done.
| |
382 } | |
383 | |
369 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( | 384 void SSLClientSocketOpenSSL::GetSSLCertRequestInfo( |
370 SSLCertRequestInfo* cert_request_info) { | 385 SSLCertRequestInfo* cert_request_info) { |
371 cert_request_info->host_and_port = host_and_port_; | 386 cert_request_info->host_and_port = host_and_port_; |
372 cert_request_info->cert_authorities = cert_authorities_; | 387 cert_request_info->cert_authorities = cert_authorities_; |
373 cert_request_info->cert_key_types = cert_key_types_; | 388 cert_request_info->cert_key_types = cert_key_types_; |
374 } | 389 } |
375 | 390 |
376 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( | 391 SSLClientSocket::NextProtoStatus SSLClientSocketOpenSSL::GetNextProto( |
377 std::string* proto, std::string* server_protos) { | 392 std::string* proto, std::string* server_protos) { |
378 *proto = npn_proto_; | 393 *proto = npn_proto_; |
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1430 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; | 1445 DVLOG(2) << "next protocol: '" << npn_proto_ << "' status: " << npn_status_; |
1431 return SSL_TLSEXT_ERR_OK; | 1446 return SSL_TLSEXT_ERR_OK; |
1432 } | 1447 } |
1433 | 1448 |
1434 scoped_refptr<X509Certificate> | 1449 scoped_refptr<X509Certificate> |
1435 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1450 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
1436 return server_cert_; | 1451 return server_cert_; |
1437 } | 1452 } |
1438 | 1453 |
1439 } // namespace net | 1454 } // namespace net |
OLD | NEW |