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

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

Issue 757033004: Do not use HTTP/2 without adequate security. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Do not leave out TLS version check. Created 6 years 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 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 // Removing ciphers by ID from OpenSSL is a bit involved as we must use the 782 // Removing ciphers by ID from OpenSSL is a bit involved as we must use the
783 // textual name with SSL_set_cipher_list because there is no public API to 783 // textual name with SSL_set_cipher_list because there is no public API to
784 // directly remove a cipher by ID. 784 // directly remove a cipher by ID.
785 STACK_OF(SSL_CIPHER)* ciphers = SSL_get_ciphers(ssl_); 785 STACK_OF(SSL_CIPHER)* ciphers = SSL_get_ciphers(ssl_);
786 DCHECK(ciphers); 786 DCHECK(ciphers);
787 // See SSLConfig::disabled_cipher_suites for description of the suites 787 // See SSLConfig::disabled_cipher_suites for description of the suites
788 // disabled by default. Note that !SHA256 and !SHA384 only remove HMAC-SHA256 788 // disabled by default. Note that !SHA256 and !SHA384 only remove HMAC-SHA256
789 // and HMAC-SHA384 cipher suites, not GCM cipher suites with SHA256 or SHA384 789 // and HMAC-SHA384 cipher suites, not GCM cipher suites with SHA256 or SHA384
790 // as the handshake hash. 790 // as the handshake hash.
791 std::string command("DEFAULT:!NULL:!aNULL:!IDEA:!FZA:!SRP:!SHA256:!SHA384:" 791 std::string command("DEFAULT:!NULL:!aNULL:!IDEA:!FZA:!SRP:!SHA256:!SHA384:"
792 "!aECDH:!AESGCM+AES256"); 792 "!aECDH:!AESGCM+AES256");
davidben 2014/12/12 21:56:22 For more fun, BoringSSL also has some bits where t
Bence 2014/12/12 22:08:43 Done.
793 // Walk through all the installed ciphers, seeing if any need to be 793 // Walk through all the installed ciphers, seeing if any need to be
794 // appended to the cipher removal |command|. 794 // appended to the cipher removal |command|.
795 for (size_t i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) { 795 for (size_t i = 0; i < sk_SSL_CIPHER_num(ciphers); ++i) {
796 const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i); 796 const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(ciphers, i);
797 const uint16 id = static_cast<uint16>(SSL_CIPHER_get_id(cipher)); 797 const uint16 id = static_cast<uint16>(SSL_CIPHER_get_id(cipher));
798 // Remove any ciphers with a strength of less than 80 bits. Note the NSS 798 // Remove any ciphers with a strength of less than 80 bits. Note the NSS
799 // implementation uses "effective" bits here but OpenSSL does not provide 799 // implementation uses "effective" bits here but OpenSSL does not provide
800 // this detail. This only impacts Triple DES: reports 112 vs. 168 bits, 800 // this detail. This only impacts Triple DES: reports 112 vs. 168 bits,
801 // both of which are greater than 80 anyway. 801 // both of which are greater than 80 anyway.
802 bool disable = SSL_CIPHER_get_bits(cipher, NULL) < 80; 802 bool disable = SSL_CIPHER_get_bits(cipher, NULL) < 80;
(...skipping 28 matching lines...) Expand all
831 831
832 if (ssl_config_.version_fallback) 832 if (ssl_config_.version_fallback)
833 SSL_enable_fallback_scsv(ssl_); 833 SSL_enable_fallback_scsv(ssl_);
834 834
835 // TLS channel ids. 835 // TLS channel ids.
836 if (IsChannelIDEnabled(ssl_config_, channel_id_service_)) { 836 if (IsChannelIDEnabled(ssl_config_, channel_id_service_)) {
837 SSL_enable_tls_channel_id(ssl_); 837 SSL_enable_tls_channel_id(ssl_);
838 } 838 }
839 839
840 if (!ssl_config_.next_protos.empty()) { 840 if (!ssl_config_.next_protos.empty()) {
841 std::vector<uint8_t> wire_protos = 841 // Get list of ciphers that are enabled.
842 SerializeNextProtos(ssl_config_.next_protos); 842 STACK_OF(SSL_CIPHER)* enabled_ciphers = SSL_get_ciphers(ssl_);
843 DCHECK(enabled_ciphers);
844 std::vector<uint16> enabled_ciphers_vector;
845 for (size_t i = 0; i < sk_SSL_CIPHER_num(enabled_ciphers); ++i) {
846 const SSL_CIPHER* cipher = sk_SSL_CIPHER_value(enabled_ciphers, i);
847 const uint16 id = static_cast<uint16>(SSL_CIPHER_get_id(cipher));
848 enabled_ciphers_vector.push_back(id);
849 }
850
851 std::vector<uint8_t> wire_protos = SerializeNextProtos(
852 ssl_config_.next_protos, IsCipherAdequateForHTTP2(cipher_suites) &&
853 IsTLSVersionAdequateForHTTP2(ssl_config_));
843 SSL_set_alpn_protos(ssl_, wire_protos.empty() ? NULL : &wire_protos[0], 854 SSL_set_alpn_protos(ssl_, wire_protos.empty() ? NULL : &wire_protos[0],
844 wire_protos.size()); 855 wire_protos.size());
845 } 856 }
846 857
847 if (ssl_config_.signed_cert_timestamps_enabled) { 858 if (ssl_config_.signed_cert_timestamps_enabled) {
848 SSL_enable_signed_cert_timestamps(ssl_); 859 SSL_enable_signed_cert_timestamps(ssl_);
849 SSL_enable_ocsp_stapling(ssl_); 860 SSL_enable_ocsp_stapling(ssl_);
850 } 861 }
851 862
852 if (IsOCSPStaplingSupported()) 863 if (IsOCSPStaplingSupported())
(...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 ct::SCT_STATUS_LOG_UNKNOWN)); 1922 ct::SCT_STATUS_LOG_UNKNOWN));
1912 } 1923 }
1913 } 1924 }
1914 1925
1915 scoped_refptr<X509Certificate> 1926 scoped_refptr<X509Certificate>
1916 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { 1927 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const {
1917 return server_cert_; 1928 return server_cert_;
1918 } 1929 }
1919 1930
1920 } // namespace net 1931 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698