| 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 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 781 |
| 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( |
| 792 "!aECDH:!AESGCM+AES256"); | 792 "DEFAULT:!NULL:!aNULL:!SHA256:!SHA384:!aECDH:!AESGCM+AES256:!aPSK"); |
| 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 Loading... |
| 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 // Get list of ciphers that are enabled. |
| 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 |
| 841 std::vector<uint8_t> wire_protos = | 851 std::vector<uint8_t> wire_protos = |
| 842 SerializeNextProtos(ssl_config_.next_protos); | 852 SerializeNextProtos(ssl_config_.next_protos, |
| 853 HasCipherAdequateForHTTP2(enabled_ciphers_vector) && |
| 854 IsTLSVersionAdequateForHTTP2(ssl_config_)); |
| 843 SSL_set_alpn_protos(ssl_, wire_protos.empty() ? NULL : &wire_protos[0], | 855 SSL_set_alpn_protos(ssl_, wire_protos.empty() ? NULL : &wire_protos[0], |
| 844 wire_protos.size()); | 856 wire_protos.size()); |
| 845 } | 857 } |
| 846 | 858 |
| 847 if (ssl_config_.signed_cert_timestamps_enabled) { | 859 if (ssl_config_.signed_cert_timestamps_enabled) { |
| 848 SSL_enable_signed_cert_timestamps(ssl_); | 860 SSL_enable_signed_cert_timestamps(ssl_); |
| 849 SSL_enable_ocsp_stapling(ssl_); | 861 SSL_enable_ocsp_stapling(ssl_); |
| 850 } | 862 } |
| 851 | 863 |
| 852 if (IsOCSPStaplingSupported()) | 864 if (IsOCSPStaplingSupported()) |
| (...skipping 1058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1911 ct::SCT_STATUS_LOG_UNKNOWN)); | 1923 ct::SCT_STATUS_LOG_UNKNOWN)); |
| 1912 } | 1924 } |
| 1913 } | 1925 } |
| 1914 | 1926 |
| 1915 scoped_refptr<X509Certificate> | 1927 scoped_refptr<X509Certificate> |
| 1916 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { | 1928 SSLClientSocketOpenSSL::GetUnverifiedServerCertificateChain() const { |
| 1917 return server_cert_; | 1929 return server_cert_; |
| 1918 } | 1930 } |
| 1919 | 1931 |
| 1920 } // namespace net | 1932 } // namespace net |
| OLD | NEW |