| 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 #include "net/base/ssl_config_service.h" | 5 #include "net/base/ssl_config_service.h" |
| 6 | 6 |
| 7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/synchronization/lock.h" | 9 #include "base/synchronization/lock.h" |
| 10 #include "net/base/crl_set.h" | 10 #include "net/base/crl_set.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 SSLConfig::CertAndStatus::CertAndStatus() : cert_status(0) {} | 32 SSLConfig::CertAndStatus::CertAndStatus() : cert_status(0) {} |
| 33 | 33 |
| 34 SSLConfig::CertAndStatus::~CertAndStatus() {} | 34 SSLConfig::CertAndStatus::~CertAndStatus() {} |
| 35 | 35 |
| 36 SSLConfig::SSLConfig() | 36 SSLConfig::SSLConfig() |
| 37 : rev_checking_enabled(false), | 37 : rev_checking_enabled(false), |
| 38 version_min(g_default_version_min), | 38 version_min(g_default_version_min), |
| 39 version_max(g_default_version_max), | 39 version_max(g_default_version_max), |
| 40 cached_info_enabled(false), | 40 cached_info_enabled(false), |
| 41 channel_id_enabled(false), | 41 channel_id_enabled(true), |
| 42 false_start_enabled(true), | 42 false_start_enabled(true), |
| 43 send_client_cert(false), | 43 send_client_cert(false), |
| 44 verify_ev_cert(false), | 44 verify_ev_cert(false), |
| 45 version_fallback(false), | 45 version_fallback(false), |
| 46 cert_io_enabled(true) { | 46 cert_io_enabled(true) { |
| 47 } | 47 } |
| 48 | 48 |
| 49 SSLConfig::~SSLConfig() { | 49 SSLConfig::~SSLConfig() { |
| 50 } | 50 } |
| 51 | 51 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 | 71 |
| 72 SSLConfigService::SSLConfigService() | 72 SSLConfigService::SSLConfigService() |
| 73 : observer_list_(ObserverList<Observer>::NOTIFY_EXISTING_ONLY) { | 73 : observer_list_(ObserverList<Observer>::NOTIFY_EXISTING_ONLY) { |
| 74 } | 74 } |
| 75 | 75 |
| 76 static bool g_cached_info_enabled = false; | 76 static bool g_cached_info_enabled = false; |
| 77 static bool g_channel_id_trial = false; | |
| 78 | 77 |
| 79 // GlobalCRLSet holds a reference to the global CRLSet. It simply wraps a lock | 78 // GlobalCRLSet holds a reference to the global CRLSet. It simply wraps a lock |
| 80 // around a scoped_refptr so that getting a reference doesn't race with | 79 // around a scoped_refptr so that getting a reference doesn't race with |
| 81 // updating the CRLSet. | 80 // updating the CRLSet. |
| 82 class GlobalCRLSet { | 81 class GlobalCRLSet { |
| 83 public: | 82 public: |
| 84 void Set(const scoped_refptr<CRLSet>& new_crl_set) { | 83 void Set(const scoped_refptr<CRLSet>& new_crl_set) { |
| 85 base::AutoLock locked(lock_); | 84 base::AutoLock locked(lock_); |
| 86 crl_set_ = new_crl_set; | 85 crl_set_ = new_crl_set; |
| 87 } | 86 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // static | 125 // static |
| 127 void SSLConfigService::SetDefaultVersionMax(uint16 version_max) { | 126 void SSLConfigService::SetDefaultVersionMax(uint16 version_max) { |
| 128 g_default_version_max = version_max; | 127 g_default_version_max = version_max; |
| 129 } | 128 } |
| 130 | 129 |
| 131 // static | 130 // static |
| 132 uint16 SSLConfigService::default_version_max() { | 131 uint16 SSLConfigService::default_version_max() { |
| 133 return g_default_version_max; | 132 return g_default_version_max; |
| 134 } | 133 } |
| 135 | 134 |
| 136 // static | |
| 137 void SSLConfigService::EnableChannelIDTrial() { | |
| 138 g_channel_id_trial = true; | |
| 139 } | |
| 140 | |
| 141 void SSLConfigService::AddObserver(Observer* observer) { | 135 void SSLConfigService::AddObserver(Observer* observer) { |
| 142 observer_list_.AddObserver(observer); | 136 observer_list_.AddObserver(observer); |
| 143 } | 137 } |
| 144 | 138 |
| 145 void SSLConfigService::RemoveObserver(Observer* observer) { | 139 void SSLConfigService::RemoveObserver(Observer* observer) { |
| 146 observer_list_.RemoveObserver(observer); | 140 observer_list_.RemoveObserver(observer); |
| 147 } | 141 } |
| 148 | 142 |
| 149 SSLConfigService::~SSLConfigService() { | 143 SSLConfigService::~SSLConfigService() { |
| 150 } | 144 } |
| 151 | 145 |
| 152 // static | 146 // static |
| 153 void SSLConfigService::SetSSLConfigFlags(SSLConfig* ssl_config) { | 147 void SSLConfigService::SetSSLConfigFlags(SSLConfig* ssl_config) { |
| 154 ssl_config->cached_info_enabled = g_cached_info_enabled; | 148 ssl_config->cached_info_enabled = g_cached_info_enabled; |
| 155 if (g_channel_id_trial) | |
| 156 ssl_config->channel_id_enabled = true; | |
| 157 } | 149 } |
| 158 | 150 |
| 159 void SSLConfigService::ProcessConfigUpdate(const SSLConfig& orig_config, | 151 void SSLConfigService::ProcessConfigUpdate(const SSLConfig& orig_config, |
| 160 const SSLConfig& new_config) { | 152 const SSLConfig& new_config) { |
| 161 bool config_changed = | 153 bool config_changed = |
| 162 (orig_config.rev_checking_enabled != new_config.rev_checking_enabled) || | 154 (orig_config.rev_checking_enabled != new_config.rev_checking_enabled) || |
| 163 (orig_config.version_min != new_config.version_min) || | 155 (orig_config.version_min != new_config.version_min) || |
| 164 (orig_config.version_max != new_config.version_max) || | 156 (orig_config.version_max != new_config.version_max) || |
| 165 (orig_config.disabled_cipher_suites != | 157 (orig_config.disabled_cipher_suites != |
| 166 new_config.disabled_cipher_suites) || | 158 new_config.disabled_cipher_suites) || |
| 167 (orig_config.channel_id_enabled != new_config.channel_id_enabled) || | 159 (orig_config.channel_id_enabled != new_config.channel_id_enabled) || |
| 168 (orig_config.false_start_enabled != new_config.false_start_enabled); | 160 (orig_config.false_start_enabled != new_config.false_start_enabled); |
| 169 | 161 |
| 170 if (config_changed) | 162 if (config_changed) |
| 171 FOR_EACH_OBSERVER(Observer, observer_list_, OnSSLConfigChanged()); | 163 FOR_EACH_OBSERVER(Observer, observer_list_, OnSSLConfigChanged()); |
| 172 } | 164 } |
| 173 | 165 |
| 174 // static | 166 // static |
| 175 bool SSLConfigService::IsSNIAvailable(SSLConfigService* service) { | 167 bool SSLConfigService::IsSNIAvailable(SSLConfigService* service) { |
| 176 if (!service) | 168 if (!service) |
| 177 return false; | 169 return false; |
| 178 | 170 |
| 179 SSLConfig ssl_config; | 171 SSLConfig ssl_config; |
| 180 service->GetSSLConfig(&ssl_config); | 172 service->GetSSLConfig(&ssl_config); |
| 181 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1; | 173 return ssl_config.version_max >= SSL_PROTOCOL_VERSION_TLS1; |
| 182 } | 174 } |
| 183 | 175 |
| 184 } // namespace net | 176 } // namespace net |
| OLD | NEW |