| 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/ssl.h> | 10 #include <openssl/ssl.h> |
| 11 #include <openssl/err.h> | 11 #include <openssl/err.h> |
| 12 #include <openssl/opensslv.h> |
| 12 | 13 |
| 13 #include "base/bind.h" | 14 #include "base/bind.h" |
| 14 #include "base/memory/singleton.h" | 15 #include "base/memory/singleton.h" |
| 15 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 16 #include "base/synchronization/lock.h" | 17 #include "base/synchronization/lock.h" |
| 17 #include "crypto/openssl_util.h" | 18 #include "crypto/openssl_util.h" |
| 18 #include "net/base/cert_verifier.h" | 19 #include "net/base/cert_verifier.h" |
| 19 #include "net/base/net_errors.h" | 20 #include "net/base/net_errors.h" |
| 20 #include "net/base/openssl_private_key_store.h" | 21 #include "net/base/openssl_private_key_store.h" |
| 21 #include "net/base/single_request_cert_verifier.h" | 22 #include "net/base/single_request_cert_verifier.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 #endif | 40 #endif |
| 40 | 41 |
| 41 const size_t kMaxRecvBufferSize = 4096; | 42 const size_t kMaxRecvBufferSize = 4096; |
| 42 const int kSessionCacheTimeoutSeconds = 60 * 60; | 43 const int kSessionCacheTimeoutSeconds = 60 * 60; |
| 43 const size_t kSessionCacheMaxEntires = 1024; | 44 const size_t kSessionCacheMaxEntires = 1024; |
| 44 | 45 |
| 45 // If a client doesn't have a list of protocols that it supports, but | 46 // If a client doesn't have a list of protocols that it supports, but |
| 46 // the server supports NPN, choosing "http/1.1" is the best answer. | 47 // the server supports NPN, choosing "http/1.1" is the best answer. |
| 47 const char kDefaultSupportedNPNProtocol[] = "http/1.1"; | 48 const char kDefaultSupportedNPNProtocol[] = "http/1.1"; |
| 48 | 49 |
| 49 // This method doesn't seemed to have made it into the OpenSSL headers. | 50 #if OPENSSL_VERSION_NUMBER < 0x1000103fL |
| 51 // This method doesn't seem to have made it into the OpenSSL headers. |
| 50 unsigned long SSL_CIPHER_get_id(const SSL_CIPHER* cipher) { return cipher->id; } | 52 unsigned long SSL_CIPHER_get_id(const SSL_CIPHER* cipher) { return cipher->id; } |
| 53 #endif |
| 51 | 54 |
| 52 // Used for encoding the |connection_status| field of an SSLInfo object. | 55 // Used for encoding the |connection_status| field of an SSLInfo object. |
| 53 int EncodeSSLConnectionStatus(int cipher_suite, | 56 int EncodeSSLConnectionStatus(int cipher_suite, |
| 54 int compression, | 57 int compression, |
| 55 int version) { | 58 int version) { |
| 56 return ((cipher_suite & SSL_CONNECTION_CIPHERSUITE_MASK) << | 59 return ((cipher_suite & SSL_CONNECTION_CIPHERSUITE_MASK) << |
| 57 SSL_CONNECTION_CIPHERSUITE_SHIFT) | | 60 SSL_CONNECTION_CIPHERSUITE_SHIFT) | |
| 58 ((compression & SSL_CONNECTION_COMPRESSION_MASK) << | 61 ((compression & SSL_CONNECTION_COMPRESSION_MASK) << |
| 59 SSL_CONNECTION_COMPRESSION_SHIFT) | | 62 SSL_CONNECTION_COMPRESSION_SHIFT) | |
| 60 ((version & SSL_CONNECTION_VERSION_MASK) << | 63 ((version & SSL_CONNECTION_VERSION_MASK) << |
| (...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, | 1321 net_log_.AddByteTransferEvent(NetLog::TYPE_SSL_SOCKET_BYTES_SENT, rv, |
| 1319 user_write_buf_->data()); | 1322 user_write_buf_->data()); |
| 1320 return rv; | 1323 return rv; |
| 1321 } | 1324 } |
| 1322 | 1325 |
| 1323 int err = SSL_get_error(ssl_, rv); | 1326 int err = SSL_get_error(ssl_, rv); |
| 1324 return MapOpenSSLError(err, err_tracer); | 1327 return MapOpenSSLError(err, err_tracer); |
| 1325 } | 1328 } |
| 1326 | 1329 |
| 1327 } // namespace net | 1330 } // namespace net |
| OLD | NEW |