Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: net/socket/ssl_client_socket_openssl.cc

Issue 1139013002: Completely remove SSLv3 support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 ((compression & SSL_CONNECTION_COMPRESSION_MASK) << 93 ((compression & SSL_CONNECTION_COMPRESSION_MASK) <<
94 SSL_CONNECTION_COMPRESSION_SHIFT) | 94 SSL_CONNECTION_COMPRESSION_SHIFT) |
95 ((version & SSL_CONNECTION_VERSION_MASK) << 95 ((version & SSL_CONNECTION_VERSION_MASK) <<
96 SSL_CONNECTION_VERSION_SHIFT); 96 SSL_CONNECTION_VERSION_SHIFT);
97 } 97 }
98 98
99 // Returns the net SSL version number (see ssl_connection_status_flags.h) for 99 // Returns the net SSL version number (see ssl_connection_status_flags.h) for
100 // this SSL connection. 100 // this SSL connection.
101 int GetNetSSLVersion(SSL* ssl) { 101 int GetNetSSLVersion(SSL* ssl) {
102 switch (SSL_version(ssl)) { 102 switch (SSL_version(ssl)) {
103 case SSL2_VERSION:
104 return SSL_CONNECTION_VERSION_SSL2;
105 case SSL3_VERSION:
106 return SSL_CONNECTION_VERSION_SSL3;
107 case TLS1_VERSION: 103 case TLS1_VERSION:
108 return SSL_CONNECTION_VERSION_TLS1; 104 return SSL_CONNECTION_VERSION_TLS1;
109 case TLS1_1_VERSION: 105 case TLS1_1_VERSION:
110 return SSL_CONNECTION_VERSION_TLS1_1; 106 return SSL_CONNECTION_VERSION_TLS1_1;
111 case TLS1_2_VERSION: 107 case TLS1_2_VERSION:
112 return SSL_CONNECTION_VERSION_TLS1_2; 108 return SSL_CONNECTION_VERSION_TLS1_2;
113 default: 109 default:
110 NOTREACHED();
114 return SSL_CONNECTION_VERSION_UNKNOWN; 111 return SSL_CONNECTION_VERSION_UNKNOWN;
115 } 112 }
116 } 113 }
117 114
118 ScopedX509 OSCertHandleToOpenSSL( 115 ScopedX509 OSCertHandleToOpenSSL(
119 X509Certificate::OSCertHandle os_handle) { 116 X509Certificate::OSCertHandle os_handle) {
120 #if defined(USE_OPENSSL_CERTS) 117 #if defined(USE_OPENSSL_CERTS)
121 return ScopedX509(X509Certificate::DupOSCertHandle(os_handle)); 118 return ScopedX509(X509Certificate::DupOSCertHandle(os_handle));
122 #else // !defined(USE_OPENSSL_CERTS) 119 #else // !defined(USE_OPENSSL_CERTS)
123 std::string der_encoded; 120 std::string der_encoded;
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 return ERR_UNEXPECTED; 703 return ERR_UNEXPECTED;
707 DCHECK(ssl_bio); 704 DCHECK(ssl_bio);
708 DCHECK(transport_bio_); 705 DCHECK(transport_bio_);
709 706
710 // Install a callback on OpenSSL's end to plumb transport errors through. 707 // Install a callback on OpenSSL's end to plumb transport errors through.
711 BIO_set_callback(ssl_bio, &SSLClientSocketOpenSSL::BIOCallback); 708 BIO_set_callback(ssl_bio, &SSLClientSocketOpenSSL::BIOCallback);
712 BIO_set_callback_arg(ssl_bio, reinterpret_cast<char*>(this)); 709 BIO_set_callback_arg(ssl_bio, reinterpret_cast<char*>(this));
713 710
714 SSL_set_bio(ssl_, ssl_bio, ssl_bio); 711 SSL_set_bio(ssl_, ssl_bio, ssl_bio);
715 712
713 DCHECK_LT(SSL3_VERSION, ssl_config_.version_min);
714 DCHECK_LT(SSL3_VERSION, ssl_config_.version_max);
715 SSL_set_min_version(ssl_, ssl_config_.version_min);
716 SSL_set_max_version(ssl_, ssl_config_.version_max);
davidben 2015/05/13 20:46:19 This is a newer API we added but I apparently neve
717
716 // OpenSSL defaults some options to on, others to off. To avoid ambiguity, 718 // OpenSSL defaults some options to on, others to off. To avoid ambiguity,
717 // set everything we care about to an absolute value. 719 // set everything we care about to an absolute value.
718 SslSetClearMask options; 720 SslSetClearMask options;
719 options.ConfigureFlag(SSL_OP_NO_SSLv2, true);
720 bool ssl3_enabled = (ssl_config_.version_min == SSL_PROTOCOL_VERSION_SSL3);
721 options.ConfigureFlag(SSL_OP_NO_SSLv3, !ssl3_enabled);
722 bool tls1_enabled = (ssl_config_.version_min <= SSL_PROTOCOL_VERSION_TLS1 &&
723 ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1);
724 options.ConfigureFlag(SSL_OP_NO_TLSv1, !tls1_enabled);
725 bool tls1_1_enabled =
726 (ssl_config_.version_min <= SSL_PROTOCOL_VERSION_TLS1_1 &&
727 ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1_1);
728 options.ConfigureFlag(SSL_OP_NO_TLSv1_1, !tls1_1_enabled);
729 bool tls1_2_enabled =
730 (ssl_config_.version_min <= SSL_PROTOCOL_VERSION_TLS1_2 &&
731 ssl_config_.version_max >= SSL_PROTOCOL_VERSION_TLS1_2);
732 options.ConfigureFlag(SSL_OP_NO_TLSv1_2, !tls1_2_enabled);
733
734 options.ConfigureFlag(SSL_OP_NO_COMPRESSION, true); 721 options.ConfigureFlag(SSL_OP_NO_COMPRESSION, true);
735 722
736 // TODO(joth): Set this conditionally, see http://crbug.com/55410 723 // TODO(joth): Set this conditionally, see http://crbug.com/55410
737 options.ConfigureFlag(SSL_OP_LEGACY_SERVER_CONNECT, true); 724 options.ConfigureFlag(SSL_OP_LEGACY_SERVER_CONNECT, true);
738 725
739 SSL_set_options(ssl_, options.set_mask); 726 SSL_set_options(ssl_, options.set_mask);
740 SSL_clear_options(ssl_, options.clear_mask); 727 SSL_clear_options(ssl_, options.clear_mask);
741 728
742 // Same as above, this time for the SSL mode. 729 // Same as above, this time for the SSL mode.
743 SslSetClearMask mode; 730 SslSetClearMask mode;
(...skipping 1129 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 1860
1874 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const { 1861 std::string SSLClientSocketOpenSSL::GetSessionCacheKey() const {
1875 std::string result = host_and_port_.ToString(); 1862 std::string result = host_and_port_.ToString();
1876 result.append("/"); 1863 result.append("/");
1877 result.append(ssl_session_cache_shard_); 1864 result.append(ssl_session_cache_shard_);
1878 1865
1879 // Shard the session cache based on maximum protocol version. This causes 1866 // Shard the session cache based on maximum protocol version. This causes
1880 // fallback connections to use a separate session cache. 1867 // fallback connections to use a separate session cache.
1881 result.append("/"); 1868 result.append("/");
1882 switch (ssl_config_.version_max) { 1869 switch (ssl_config_.version_max) {
1883 case SSL_PROTOCOL_VERSION_SSL3:
1884 result.append("ssl3");
1885 break;
1886 case SSL_PROTOCOL_VERSION_TLS1: 1870 case SSL_PROTOCOL_VERSION_TLS1:
1887 result.append("tls1"); 1871 result.append("tls1");
1888 break; 1872 break;
1889 case SSL_PROTOCOL_VERSION_TLS1_1: 1873 case SSL_PROTOCOL_VERSION_TLS1_1:
1890 result.append("tls1.1"); 1874 result.append("tls1.1");
1891 break; 1875 break;
1892 case SSL_PROTOCOL_VERSION_TLS1_2: 1876 case SSL_PROTOCOL_VERSION_TLS1_2:
1893 result.append("tls1.2"); 1877 result.append("tls1.2");
1894 break; 1878 break;
1895 default: 1879 default:
(...skipping 18 matching lines...) Expand all
1914 } 1898 }
1915 return false; 1899 return false;
1916 } 1900 }
1917 1901
1918 scoped_refptr<X509Certificate> 1902 scoped_refptr<X509Certificate>
1919 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1903 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1920 return server_cert_; 1904 return server_cert_;
1921 } 1905 }
1922 1906
1923 } // namespace net 1907 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698