]> khamidou — GitHub mirrors - electron.git/commitdiff
browser: flag to diable specified cipher suites
authorRobo <hop2deep@gmail.com>
Mon, 19 Oct 2015 20:56:01 +0000 (02:26 +0530)
committerRobo <hop2deep@gmail.com>
Mon, 19 Oct 2015 21:21:56 +0000 (02:51 +0530)
atom/browser/atom_ssl_config_service.cc
atom/common/options_switches.cc
atom/common/options_switches.h
docs/api/chrome-command-line-switches.md

index f19dbacf7dd317457988841cdcefd1026b39e366..0a47067b0a6884143c7d6088ff3b0ca94302a469 100644 (file)
@@ -5,11 +5,14 @@
 #include "atom/browser/atom_ssl_config_service.h"
 
 #include <string>
+#include <vector>
 
 #include "base/command_line.h"
+#include "base/strings/string_split.h"
 #include "atom/common/options_switches.h"
 #include "content/public/browser/browser_thread.h"
 #include "net/socket/ssl_client_socket.h"
+#include "net/ssl/ssl_cipher_suite_names.h"
 
 namespace atom {
 
@@ -26,6 +29,23 @@ uint16 GetSSLProtocolVersion(const std::string& version_string) {
   return version;
 }
 
+std::vector<uint16> ParseCipherSuites(
+    const std::vector<std::string>& cipher_strings) {
+  std::vector<uint16> cipher_suites;
+  cipher_suites.reserve(cipher_strings.size());
+
+  for (auto& cipher_string : cipher_strings) {
+    uint16 cipher_suite = 0;
+    if (!net::ParseSSLCipherString(cipher_string, &cipher_suite)) {
+      LOG(ERROR) << "Ignoring unrecognised cipher suite : "
+                 << cipher_string;
+      continue;
+    }
+    cipher_suites.push_back(cipher_suite);
+  }
+  return cipher_suites;
+}
+
 }  // namespace
 
 AtomSSLConfigService::AtomSSLConfigService() {
@@ -35,6 +55,13 @@ AtomSSLConfigService::AtomSSLConfigService() {
         cmd_line->GetSwitchValueASCII(switches::kSSLVersionFallbackMin);
     config_.version_fallback_min = GetSSLProtocolVersion(version_string);
   }
+
+  if (cmd_line->HasSwitch(switches::kCipherSuiteBlacklist)) {
+    auto cipher_strings = base::SplitString(
+        cmd_line->GetSwitchValueASCII(switches::kCipherSuiteBlacklist),
+        ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY);
+    config_.disabled_cipher_suites = ParseCipherSuites(cipher_strings);
+  }
 }
 
 AtomSSLConfigService::~AtomSSLConfigService() {
index 46687becf84a28a8843b363a2ac146cbd90f02a3..84d63c29a0a7a7746357eaccf0e4fbbbc2f0ae3e 100644 (file)
@@ -117,6 +117,9 @@ const char kRegisterStandardSchemes[] = "register-standard-schemes";
 // TLS fallback will accept.
 const char kSSLVersionFallbackMin[] = "ssl-version-fallback-min";
 
+// Comma-separated list of SSL cipher suites to disable.
+const char kCipherSuiteBlacklist[] = "cipher-suite-blacklist";
+
 // The browser process app model ID
 const char kAppUserModelId[] = "app-user-model-id";
 
index 16046d19c82224c33f8b33e698a7f4183df9fb21..73312d028d3461369f161048073add23f0ae6a92 100644 (file)
@@ -60,6 +60,7 @@ extern const char kPageVisibility[];
 extern const char kDisableHttpCache[];
 extern const char kRegisterStandardSchemes[];
 extern const char kSSLVersionFallbackMin[];
+extern const char kCipherSuiteBlacklist[];
 
 extern const char kAppUserModelId[];
 
index c2a39126f63e17b07d33818230c3d79c372d9af3..abf8726b684d7a8c470ae02cc42df5f39d76ed47 100644 (file)
@@ -92,6 +92,10 @@ Enables net log events to be saved and writes them to `path`.
 Sets the minimum SSL/TLS version ("tls1", "tls1.1" or "tls1.2") that TLS
 fallback will accept.
 
+## --cipher-suite-blacklist=`cipher_suites`
+
+Specify comma-separated list of SSL cipher suites to disable.
+
 ## --enable-logging
 
 Prints Chromium's logging into console.