]> khamidou — GitHub mirrors - electron.git/commitdiff
browser: switch to set minimum version for TLS fallback
authorRobo <hop2deep@gmail.com>
Mon, 21 Sep 2015 16:43:32 +0000 (22:13 +0530)
committerRobo <hop2deep@gmail.com>
Wed, 23 Sep 2015 03:40:36 +0000 (09:10 +0530)
atom/browser/atom_browser_context.cc
atom/browser/atom_browser_context.h
atom/browser/atom_ssl_config_service.cc [new file with mode: 0644]
atom/browser/atom_ssl_config_service.h [new file with mode: 0644]
atom/common/options_switches.cc
atom/common/options_switches.h
docs/api/chrome-command-line-switches.md
filenames.gypi

index d1ef09e70ff66b70bbe27943423db2273573990b..6823fbaee90cbb5f5ee8c02aeb6a016fabfe07dc 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "atom/browser/atom_browser_main_parts.h"
 #include "atom/browser/atom_download_manager_delegate.h"
+#include "atom/browser/atom_ssl_config_service.h"
 #include "atom/browser/browser.h"
 #include "atom/browser/net/atom_url_request_job_factory.h"
 #include "atom/browser/net/asar/asar_protocol_handler.h"
@@ -156,6 +157,10 @@ content::BrowserPluginGuestManager* AtomBrowserContext::GetGuestManager() {
   return guest_manager_.get();
 }
 
+net::SSLConfigService* AtomBrowserContext::CreateSSLConfigService() {
+  return new AtomSSLConfigService;
+}
+
 void AtomBrowserContext::RegisterPrefs(PrefRegistrySimple* pref_registry) {
   pref_registry->RegisterFilePathPref(prefs::kSelectFileLastDirectory,
                                       base::FilePath());
index c99461ad9a86f3fd6ea3b182f56d90fd1cff2d69..839359c1ef50e219cd086724b13eecc5865a7c6f 100644 (file)
@@ -27,6 +27,7 @@ class AtomBrowserContext : public brightray::BrowserContext {
       content::URLRequestInterceptorScopedVector* interceptors) override;
   net::HttpCache::BackendFactory* CreateHttpCacheBackendFactory(
       const base::FilePath& base_path) override;
+  net::SSLConfigService* CreateSSLConfigService() override;
 
   // content::BrowserContext:
   content::DownloadManagerDelegate* GetDownloadManagerDelegate() override;
diff --git a/atom/browser/atom_ssl_config_service.cc b/atom/browser/atom_ssl_config_service.cc
new file mode 100644 (file)
index 0000000..f19dbac
--- /dev/null
@@ -0,0 +1,47 @@
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/atom_ssl_config_service.h"
+
+#include <string>
+
+#include "base/command_line.h"
+#include "atom/common/options_switches.h"
+#include "content/public/browser/browser_thread.h"
+#include "net/socket/ssl_client_socket.h"
+
+namespace atom {
+
+namespace {
+
+uint16 GetSSLProtocolVersion(const std::string& version_string) {
+  uint16 version = 0;  // Invalid
+  if (version_string == "tls1")
+    version = net::SSL_PROTOCOL_VERSION_TLS1;
+  else if (version_string == "tls1.1")
+    version = net::SSL_PROTOCOL_VERSION_TLS1_1;
+  else if (version_string == "tls1.2")
+    version = net::SSL_PROTOCOL_VERSION_TLS1_2;
+  return version;
+}
+
+}  // namespace
+
+AtomSSLConfigService::AtomSSLConfigService() {
+  auto cmd_line = base::CommandLine::ForCurrentProcess();
+  if (cmd_line->HasSwitch(switches::kSSLVersionFallbackMin)) {
+    auto version_string =
+        cmd_line->GetSwitchValueASCII(switches::kSSLVersionFallbackMin);
+    config_.version_fallback_min = GetSSLProtocolVersion(version_string);
+  }
+}
+
+AtomSSLConfigService::~AtomSSLConfigService() {
+}
+
+void AtomSSLConfigService::GetSSLConfig(net::SSLConfig* config) {
+  *config = config_;
+}
+
+}  // namespace atom
diff --git a/atom/browser/atom_ssl_config_service.h b/atom/browser/atom_ssl_config_service.h
new file mode 100644 (file)
index 0000000..3fa91c6
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_ATOM_SSL_CONFIG_SERVICE_H_
+#define ATOM_BROWSER_ATOM_SSL_CONFIG_SERVICE_H_
+
+#include "net/ssl/ssl_config_service.h"
+
+namespace atom {
+
+class AtomSSLConfigService : public net::SSLConfigService {
+ public:
+  AtomSSLConfigService();
+  ~AtomSSLConfigService() override;
+
+  // net::SSLConfigService:
+  void GetSSLConfig(net::SSLConfig* config) override;
+
+ private:
+  net::SSLConfig config_;
+
+  DISALLOW_COPY_AND_ASSIGN(AtomSSLConfigService);
+};
+
+}   // namespace atom
+
+#endif  // ATOM_BROWSER_ATOM_SSL_CONFIG_SERVICE_H_
index c70e1ba4afa6e362ca9605a5bae9feb01e62ef0e..46687becf84a28a8843b363a2ac146cbd90f02a3 100644 (file)
@@ -113,6 +113,10 @@ const char kDisableHttpCache[] = "disable-http-cache";
 // Register schemes to standard.
 const char kRegisterStandardSchemes[] = "register-standard-schemes";
 
+// The minimum SSL/TLS version ("tls1", "tls1.1", or "tls1.2") that
+// TLS fallback will accept.
+const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min";
+
 // The browser process app model ID
 const char kAppUserModelId[] = "app-user-model-id";
 
index e62f3116661aaba12a60cca1a3255e2120da0c6c..16046d19c82224c33f8b33e698a7f4183df9fb21 100644 (file)
@@ -59,6 +59,7 @@ extern const char kPageVisibility[];
 
 extern const char kDisableHttpCache[];
 extern const char kRegisterStandardSchemes[];
+extern const char kSSLVersionFallbackMin[];
 
 extern const char kAppUserModelId[];
 
index 2f995c99b2194e7c9049fa2bddfc83890caf7427..cd633fc0460c28991bdb91f6b9d152a3186bede1 100644 (file)
@@ -87,6 +87,11 @@ Sets the `version` of the pepper flash plugin.
 
 Enables net log events to be saved and writes them to `path`.
 
+## --ssl-version-fallback-min=`version`
+
+Set the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS
+fallback will accept.
+
 ## --v=`log_level`
 
 Gives the default maximal active V-logging level; 0 is the default. Normally
index 99d6bc6d50d3280334a172c572637f4f9a74ec04..3258a032de8e2ce5416e7c9fb031b4beb47d67e1 100644 (file)
       'atom/browser/atom_quota_permission_context.h',
       'atom/browser/atom_speech_recognition_manager_delegate.cc',
       'atom/browser/atom_speech_recognition_manager_delegate.h',
+      'atom/browser/atom_ssl_config_service.cc',
+      'atom/browser/atom_ssl_config_service.h',
       'atom/browser/bridge_task_runner.cc',
       'atom/browser/bridge_task_runner.h',
       'atom/browser/browser.cc',