| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 #ifndef NET_BASE_SSL_CONFIG_SERVICE_H_ | 5 #ifndef NET_BASE_SSL_CONFIG_SERVICE_H_ |
| 6 #define NET_BASE_SSL_CONFIG_SERVICE_H_ | 6 #define NET_BASE_SSL_CONFIG_SERVICE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
| 12 #include "base/ref_counted.h" | 12 #include "base/ref_counted.h" |
| 13 #include "net/base/x509_certificate.h" | 13 #include "net/base/x509_certificate.h" |
| 14 | 14 |
| 15 namespace net { | 15 namespace net { |
| 16 | 16 |
| 17 // A collection of SSL-related configuration settings. | 17 // A collection of SSL-related configuration settings. |
| 18 struct SSLConfig { | 18 struct SSLConfig { |
| 19 // Default to revocation checking. | 19 // Default to revocation checking. |
| 20 // Default to SSL 2.0 off, SSL 3.0 on, and TLS 1.0 on. | 20 // Default to SSL 2.0 off, SSL 3.0 on, and TLS 1.0 on. |
| 21 SSLConfig() | 21 SSLConfig(); |
| 22 : rev_checking_enabled(true), ssl2_enabled(false), ssl3_enabled(true), | 22 ~SSLConfig(); |
| 23 tls1_enabled(true), dnssec_enabled(false), mitm_proxies_allowed(false), | |
| 24 false_start_enabled(true), send_client_cert(false), | |
| 25 verify_ev_cert(false), ssl3_fallback(false) { | |
| 26 } | |
| 27 | 23 |
| 28 bool rev_checking_enabled; // True if server certificate revocation | 24 bool rev_checking_enabled; // True if server certificate revocation |
| 29 // checking is enabled. | 25 // checking is enabled. |
| 30 bool ssl2_enabled; // True if SSL 2.0 is enabled. | 26 bool ssl2_enabled; // True if SSL 2.0 is enabled. |
| 31 bool ssl3_enabled; // True if SSL 3.0 is enabled. | 27 bool ssl3_enabled; // True if SSL 3.0 is enabled. |
| 32 bool tls1_enabled; // True if TLS 1.0 is enabled. | 28 bool tls1_enabled; // True if TLS 1.0 is enabled. |
| 33 bool dnssec_enabled; // True if we'll accept DNSSEC chains in certificates. | 29 bool dnssec_enabled; // True if we'll accept DNSSEC chains in certificates. |
| 34 | 30 |
| 35 // True if we allow this connection to be MITM attacked. This sounds a little | 31 // True if we allow this connection to be MITM attacked. This sounds a little |
| 36 // worse than it is: large networks sometimes MITM attack all SSL connections | 32 // worse than it is: large networks sometimes MITM attack all SSL connections |
| 37 // on egress. We want to know this because we might not have the end-to-end | 33 // on egress. We want to know this because we might not have the end-to-end |
| 38 // connection that we believe that we have based on the hostname. Therefore, | 34 // connection that we believe that we have based on the hostname. Therefore, |
| 39 // certain certificate checks can't be performed and we can't use outside | 35 // certain certificate checks can't be performed and we can't use outside |
| 40 // knowledge about whether the server has the renegotiation extension. | 36 // knowledge about whether the server has the renegotiation extension. |
| 41 bool mitm_proxies_allowed; | 37 bool mitm_proxies_allowed; |
| 42 | 38 |
| 43 bool false_start_enabled; // True if we'll use TLS False Start. | 39 bool false_start_enabled; // True if we'll use TLS False Start. |
| 44 | 40 |
| 45 // TODO(wtc): move the following members to a new SSLParams structure. They | 41 // TODO(wtc): move the following members to a new SSLParams structure. They |
| 46 // are not SSL configuration settings. | 42 // are not SSL configuration settings. |
| 47 | 43 |
| 48 struct CertAndStatus { | 44 struct CertAndStatus { |
| 49 scoped_refptr<X509Certificate> cert; | 45 scoped_refptr<X509Certificate> cert; |
| 50 int cert_status; | 46 int cert_status; |
| 51 }; | 47 }; |
| 52 | 48 |
| 53 // Returns true if |cert| is one of the certs in |allowed_bad_certs|. | 49 // Returns true if |cert| is one of the certs in |allowed_bad_certs|. |
| 54 // TODO(wtc): Move this to a .cc file. ssl_config_service.cc is Windows | 50 bool IsAllowedBadCert(X509Certificate* cert) const; |
| 55 // only right now, so I can't move it there. | |
| 56 bool IsAllowedBadCert(X509Certificate* cert) const { | |
| 57 for (size_t i = 0; i < allowed_bad_certs.size(); ++i) { | |
| 58 if (cert == allowed_bad_certs[i].cert) | |
| 59 return true; | |
| 60 } | |
| 61 return false; | |
| 62 } | |
| 63 | 51 |
| 64 // Add any known-bad SSL certificate (with its cert status) to | 52 // Add any known-bad SSL certificate (with its cert status) to |
| 65 // |allowed_bad_certs| that should not trigger an ERR_CERT_* error when | 53 // |allowed_bad_certs| that should not trigger an ERR_CERT_* error when |
| 66 // calling SSLClientSocket::Connect. This would normally be done in | 54 // calling SSLClientSocket::Connect. This would normally be done in |
| 67 // response to the user explicitly accepting the bad certificate. | 55 // response to the user explicitly accepting the bad certificate. |
| 68 std::vector<CertAndStatus> allowed_bad_certs; | 56 std::vector<CertAndStatus> allowed_bad_certs; |
| 69 | 57 |
| 70 // True if we should send client_cert to the server. | 58 // True if we should send client_cert to the server. |
| 71 bool send_client_cert; | 59 bool send_client_cert; |
| 72 | 60 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 101 // rev_checking_enabled | 89 // rev_checking_enabled |
| 102 // ssl2_enabled | 90 // ssl2_enabled |
| 103 // ssl3_enabled | 91 // ssl3_enabled |
| 104 // tls1_enabled | 92 // tls1_enabled |
| 105 virtual void OnSSLConfigChanged() = 0; | 93 virtual void OnSSLConfigChanged() = 0; |
| 106 | 94 |
| 107 protected: | 95 protected: |
| 108 virtual ~Observer() {} | 96 virtual ~Observer() {} |
| 109 }; | 97 }; |
| 110 | 98 |
| 111 SSLConfigService() | 99 SSLConfigService(); |
| 112 : observer_list_(ObserverList<Observer>::NOTIFY_EXISTING_ONLY) {} | |
| 113 | 100 |
| 114 // Create an instance of SSLConfigService which retrieves the configuration | 101 // Create an instance of SSLConfigService which retrieves the configuration |
| 115 // from the system SSL configuration, or an instance of | 102 // from the system SSL configuration, or an instance of |
| 116 // SSLConfigServiceDefaults if the current system does not have a system SSL | 103 // SSLConfigServiceDefaults if the current system does not have a system SSL |
| 117 // configuration. Note: this does not handle SSLConfigService implementations | 104 // configuration. Note: this does not handle SSLConfigService implementations |
| 118 // that are not native to their platform, such as preference-backed ones. | 105 // that are not native to their platform, such as preference-backed ones. |
| 119 static SSLConfigService* CreateSystemSSLConfigService(); | 106 static SSLConfigService* CreateSystemSSLConfigService(); |
| 120 | 107 |
| 121 // May not be thread-safe, should only be called on the IO thread. | 108 // May not be thread-safe, should only be called on the IO thread. |
| 122 virtual void GetSSLConfig(SSLConfig* config) = 0; | 109 virtual void GetSSLConfig(SSLConfig* config) = 0; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 150 | 137 |
| 151 // Add an observer of this service. | 138 // Add an observer of this service. |
| 152 void AddObserver(Observer* observer); | 139 void AddObserver(Observer* observer); |
| 153 | 140 |
| 154 // Remove an observer of this service. | 141 // Remove an observer of this service. |
| 155 void RemoveObserver(Observer* observer); | 142 void RemoveObserver(Observer* observer); |
| 156 | 143 |
| 157 protected: | 144 protected: |
| 158 friend class base::RefCountedThreadSafe<SSLConfigService>; | 145 friend class base::RefCountedThreadSafe<SSLConfigService>; |
| 159 | 146 |
| 160 virtual ~SSLConfigService() {} | 147 virtual ~SSLConfigService(); |
| 161 | 148 |
| 162 // SetFlags sets the values of several flags based on global configuration. | 149 // SetFlags sets the values of several flags based on global configuration. |
| 163 static void SetSSLConfigFlags(SSLConfig*); | 150 static void SetSSLConfigFlags(SSLConfig*); |
| 164 | 151 |
| 165 // Process before/after config update. | 152 // Process before/after config update. |
| 166 void ProcessConfigUpdate(const SSLConfig& orig_config, | 153 void ProcessConfigUpdate(const SSLConfig& orig_config, |
| 167 const SSLConfig& new_config); | 154 const SSLConfig& new_config); |
| 168 | 155 |
| 169 private: | 156 private: |
| 170 ObserverList<Observer> observer_list_; | 157 ObserverList<Observer> observer_list_; |
| 171 }; | 158 }; |
| 172 | 159 |
| 173 } // namespace net | 160 } // namespace net |
| 174 | 161 |
| 175 #endif // NET_BASE_SSL_CONFIG_SERVICE_H_ | 162 #endif // NET_BASE_SSL_CONFIG_SERVICE_H_ |
| OLD | NEW |