[go: nahoru, domu]

Add commandline switch to enable DTLS 1.2 for WebRTC.

This CL adds the commandline switch "--enable-webrtc-dtls12" to enable
negotiation of DTLS 1.2 for WebRTC peerconnections.

BUG=428343

Review URL: https://codereview.chromium.org/1157093007

Cr-Commit-Position: refs/heads/master@{#332381}
diff --git a/AUTHORS b/AUTHORS
index 481689a..1a42189f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -257,6 +257,7 @@
 Jinwoo Song <jinwoo7.song@samsung.com>
 Jitendra Kumar Sahoo <jitendra.ks@samsung.com>
 Joachim Bauch <mail@joachim-bauch.de>
+Joachim Bauch <jbauch@webrtc.org>
 Joe Knoll <joe.knoll@workday.com>
 Joe Thomas <mhx348@motorola.com>
 Joel Stanley <joel@jms.id.au>
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 231050b..b0e30920 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -5920,6 +5920,12 @@
       <message name="IDS_FLAGS_DISABLE_WEBRTC_HW_ENCODING_DESCRIPTION" desc="Description of chrome:flags option to turn off WebRTC hardware video encoding support.">
         This option disables support in WebRTC for encoding video streams using platform hardware.
       </message>
+      <message name="IDS_FLAGS_ENABLE_WEBRTC_DTLS12_NAME" desc="Name of chrome:flags option to enable DTLS 1.2 for WebRTC">
+        Enable negotiation with DTLS 1.2 for WebRTC.
+      </message>
+      <message name="IDS_FLAGS_ENABLE_WEBRTC_DTLS12_DESCRIPTION" desc="Description of chrome:flags option to enable DTLS 1.2 for WebRTC">
+        When enabled, WebRTC will try to negotiate DTLS 1.2.
+      </message>
       <message name="IDS_FLAGS_ENABLE_WEBRTC_STUN_ORIGIN_NAME" desc="Name of chrome:flags option to turn on Origin header for WebRTC STUN messages">
         Enable support for WebRTC Stun origin header.
       </message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index dc8f732..80122fd 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2380,6 +2380,15 @@
     kOsAll,
     SINGLE_VALUE_TYPE(switches::kEmphasizeTitlesInOmniboxDropdown)
   },
+#if defined(ENABLE_WEBRTC)
+  {
+    "enable-webrtc-dtls12",
+    IDS_FLAGS_ENABLE_WEBRTC_DTLS12_NAME,
+    IDS_FLAGS_ENABLE_WEBRTC_DTLS12_DESCRIPTION,
+    kOsAll,
+    SINGLE_VALUE_TYPE(switches::kEnableWebRtcDtls12)
+  },
+#endif
   // NOTE: Adding new command-line switches requires adding corresponding
   // entries to enum "LoginCustomFlags" in histograms.xml. See note in
   // histograms.xml and don't forget to run AboutFlagsHistogramTest unit test.
diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc
index 1417f0f..8f90764a 100644
--- a/content/browser/renderer_host/render_process_host_impl.cc
+++ b/content/browser/renderer_host/render_process_host_impl.cc
@@ -1364,6 +1364,7 @@
 #if defined(ENABLE_WEBRTC)
     switches::kDisableWebRtcHWDecoding,
     switches::kDisableWebRtcHWEncoding,
+    switches::kEnableWebRtcDtls12,
     switches::kEnableWebRtcHWH264Encoding,
     switches::kEnableWebRtcStunOrigin,
     switches::kWebRtcMaxCaptureFramerate,
diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc
index 2dbba59..77e501d 100644
--- a/content/public/common/content_switches.cc
+++ b/content/public/common/content_switches.cc
@@ -904,6 +904,9 @@
 // Disables HW encode acceleration for WebRTC.
 const char kDisableWebRtcHWEncoding[]       = "disable-webrtc-hw-encoding";
 
+// Enables negotiation of DTLS 1.2 for WebRTC.
+const char kEnableWebRtcDtls12[]            = "enable-webrtc-dtls12";
+
 // Enables H264 HW encode acceleration for WebRTC.
 const char kEnableWebRtcHWH264Encoding[]    = "enable-webrtc-hw-h264-encoding";
 
diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h
index 0b192f6..c86bff1 100644
--- a/content/public/common/content_switches.h
+++ b/content/public/common/content_switches.h
@@ -251,6 +251,7 @@
 CONTENT_EXPORT extern const char kDisableWebRtcHWDecoding[];
 CONTENT_EXPORT extern const char kDisableWebRtcEncryption[];
 CONTENT_EXPORT extern const char kDisableWebRtcHWEncoding[];
+CONTENT_EXPORT extern const char kEnableWebRtcDtls12[];
 CONTENT_EXPORT extern const char kEnableWebRtcHWH264Encoding[];
 CONTENT_EXPORT extern const char kEnableWebRtcStunOrigin[];
 extern const char kWebRtcMaxCaptureFramerate[];
diff --git a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
index 35f5a31..dad2937f 100644
--- a/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
+++ b/content/renderer/media/webrtc/peer_connection_dependency_factory.cc
@@ -387,6 +387,8 @@
   factory_options.disable_sctp_data_channels = false;
   factory_options.disable_encryption =
       cmd_line->HasSwitch(switches::kDisableWebRtcEncryption);
+  if (cmd_line->HasSwitch(switches::kEnableWebRtcDtls12))
+    factory_options.ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
   pc_factory_->SetOptions(factory_options);
 
   event->Signal();
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 82381cc2..785f32e 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -57574,6 +57574,7 @@
   <int value="-2137755780" label="enable-reader-mode-toolbar-icon"/>
   <int value="-2132591642" label="enable-input-view"/>
   <int value="-2119827860" label="ash-disable-maximize-mode-window-backdrop"/>
+  <int value="-2119530966" label="enable-webrtc-dtls12"/>
   <int value="-2117201726" label="disable-gpu-rasterization"/>
   <int value="-2114831248" label="disable-new-ntp"/>
   <int value="-2099035488" label="enable-data-reduction-proxy-bypass-warning"/>