1 // Copyright 2012 The Chromium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "net/ssl/ssl_config_service.h" 6 7 #include <tuple> 8 9 #include "base/feature_list.h" 10 #include "base/observer_list.h" 11 #include "net/base/features.h" 12 #include "net/ssl/ssl_config_service_defaults.h" 13 14 namespace net { 15 16 SSLContextConfig::SSLContextConfig() = default; 17 SSLContextConfig::SSLContextConfig(const SSLContextConfig&) = default; 18 SSLContextConfig::SSLContextConfig(SSLContextConfig&&) = default; 19 SSLContextConfig::~SSLContextConfig() = default; 20 SSLContextConfig& SSLContextConfig::operator=(const SSLContextConfig&) = 21 default; 22 SSLContextConfig& SSLContextConfig::operator=(SSLContextConfig&&) = default; 23 bool SSLContextConfig::operator==(const SSLContextConfig&) const = default; 24 EncryptedClientHelloEnabled() const25bool SSLContextConfig::EncryptedClientHelloEnabled() const { 26 return ech_enabled && 27 base::FeatureList::IsEnabled(features::kEncryptedClientHello); 28 } 29 InsecureHashesInTLSHandshakesEnabled() const30bool SSLContextConfig::InsecureHashesInTLSHandshakesEnabled() const { 31 return insecure_hash_override.value_or( 32 base::FeatureList::IsEnabled(features::kSHA1ServerSignature)); 33 } 34 PostQuantumKeyAgreementEnabled() const35bool SSLContextConfig::PostQuantumKeyAgreementEnabled() const { 36 return post_quantum_override.value_or( 37 base::FeatureList::IsEnabled(features::kPostQuantumKyber)); 38 } 39 SSLConfigService()40SSLConfigService::SSLConfigService() 41 : observer_list_(base::ObserverListPolicy::EXISTING_ONLY) {} 42 43 SSLConfigService::~SSLConfigService() = default; 44 AddObserver(Observer * observer)45void SSLConfigService::AddObserver(Observer* observer) { 46 observer_list_.AddObserver(observer); 47 } 48 RemoveObserver(Observer * observer)49void SSLConfigService::RemoveObserver(Observer* observer) { 50 observer_list_.RemoveObserver(observer); 51 } 52 NotifySSLContextConfigChange()53void SSLConfigService::NotifySSLContextConfigChange() { 54 for (auto& observer : observer_list_) 55 observer.OnSSLContextConfigChanged(); 56 } 57 ProcessConfigUpdate(const SSLContextConfig & old_config,const SSLContextConfig & new_config,bool force_notification)58void SSLConfigService::ProcessConfigUpdate(const SSLContextConfig& old_config, 59 const SSLContextConfig& new_config, 60 bool force_notification) { 61 // Do nothing if the configuration hasn't changed. 62 if (old_config != new_config || force_notification) { 63 NotifySSLContextConfigChange(); 64 } 65 } 66 67 } // namespace net 68