Enable a debug WebRTC mode without any encryption
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jul 2019 18:59:19 +0000 (18:59 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Jul 2019 18:59:19 +0000 (18:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=199177
<rdar://problem/52074986>

Reviewed by Eric Carlson.

Source/JavaScriptCore:

* inspector/protocol/Page.json:

Source/ThirdParty/libwebrtc:

* Configurations/libwebrtc.iOS.exp:
* Configurations/libwebrtc.iOSsim.exp:
* Configurations/libwebrtc.mac.exp:

Source/WebCore:

For every RTCPeerConnection, first set whether to use encryption or not
based on page settings.
If encryption is disabled, log it.
Add internals API to toggle the switch from tests.
Test: webrtc/disable-encryption.html

* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::RTCPeerConnection):
* Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
(WebCore::createLibWebRTCPeerConnectionBackend):
* inspector/agents/InspectorPageAgent.cpp:
* page/Settings.yaml:
* platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
(WebCore::LibWebRTCProvider::setEnableWebRTCEncryption):
* platform/mediastream/libwebrtc/LibWebRTCProvider.h:
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):
(WebCore::Internals::setEnableWebRTCEncryption):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Base/Main.js:

LayoutTests:

* webrtc/disable-encryption-expected.txt: Added.
* webrtc/disable-encryption.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247438 268f45cc-cd09-0410-ab3c-d52691b4dbfc

22 files changed:
LayoutTests/ChangeLog
LayoutTests/webrtc/disable-encryption-expected.txt [new file with mode: 0644]
LayoutTests/webrtc/disable-encryption.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Page.json
Source/ThirdParty/libwebrtc/ChangeLog
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp
Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp
Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Source/WebCore/page/Settings.yaml
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.cpp
Source/WebCore/platform/mediastream/libwebrtc/LibWebRTCProvider.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js

index cbf7b88..8fcb678 100644 (file)
@@ -1,5 +1,16 @@
 2019-07-15  Youenn Fablet  <youenn@apple.com>
 
+        Enable a debug WebRTC mode without any encryption
+        https://bugs.webkit.org/show_bug.cgi?id=199177
+        <rdar://problem/52074986>
+
+        Reviewed by Eric Carlson.
+
+        * webrtc/disable-encryption-expected.txt: Added.
+        * webrtc/disable-encryption.html: Added.
+
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
         Filter SDP c lines
         https://bugs.webkit.org/show_bug.cgi?id=199791
 
diff --git a/LayoutTests/webrtc/disable-encryption-expected.txt b/LayoutTests/webrtc/disable-encryption-expected.txt
new file mode 100644 (file)
index 0000000..ddd4b8c
--- /dev/null
@@ -0,0 +1,5 @@
+
+
+PASS Basic data channel exchange without encryption 
+PASS Make sure a pc with encryption and a pc without encryption cannot talk 
+
diff --git a/LayoutTests/webrtc/disable-encryption.html b/LayoutTests/webrtc/disable-encryption.html
new file mode 100644 (file)
index 0000000..6749bf9
--- /dev/null
@@ -0,0 +1,50 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>Testing connection with and without encryption</title>
+    <script src="../resources/testharness.js"></script>
+    <script src="../resources/testharnessreport.js"></script>
+  </head>
+  <body>
+    <video id="video" autoplay playsinline></video>
+    <script src ="routines.js"></script>
+    <script>
+promise_test(async (test) => {
+    if (window.internals)
+        internals.setEnableWebRTCEncryption(false);
+    const localStream = await navigator.mediaDevices.getUserMedia({video: true});
+
+    video.srcObject = await new Promise((resolve, reject) => {
+        createConnections((localConnection) => {
+            localConnection.addTrack(localStream.getVideoTracks()[0], localStream);
+        }, (remoteConnection) => {
+            remoteConnection.ontrack = (event) => {
+                resolve(event.streams[0]);
+            };
+        });
+        setTimeout(() => { reject("Test timed out"); }, 5000);
+    });
+
+    await video.play();
+}, "Basic data channel exchange without encryption");
+
+promise_test(async (test) => {
+    if (!window.internals)
+        return Promise.rejects("Test needs internals");
+
+    internals.setEnableWebRTCEncryption(false);
+    const pc1 = new RTCPeerConnection();
+
+    internals.setEnableWebRTCEncryption(true);
+    const pc2 = new RTCPeerConnection();
+
+    pc1.addTransceiver('audio');
+    const offer = await pc1.createOffer();
+    await pc1.setLocalDescription(offer);
+
+    return promise_rejects(test, 'InvalidAccessError', pc2.setRemoteDescription(offer));
+}, "Make sure a pc with encryption and a pc without encryption cannot talk");
+    </script>
+  </body>
+</html>
index 0aaec2e..73d0122 100644 (file)
@@ -1,3 +1,13 @@
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
+        Enable a debug WebRTC mode without any encryption
+        https://bugs.webkit.org/show_bug.cgi?id=199177
+        <rdar://problem/52074986>
+
+        Reviewed by Eric Carlson.
+
+        * inspector/protocol/Page.json:
+
 2019-07-15  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, attempt to fix production builds after r247403.
index 769bf4b..8c64cfc 100644 (file)
@@ -15,6 +15,7 @@
                 "MockCaptureDevicesEnabled",
                 "NeedsSiteSpecificQuirks",
                 "ScriptEnabled",
+                "WebRTCEncryptionEnabled",
                 "WebSecurityEnabled"
             ]
         },
index 18a01aa..03bd700 100644 (file)
@@ -1,3 +1,15 @@
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
+        Enable a debug WebRTC mode without any encryption
+        https://bugs.webkit.org/show_bug.cgi?id=199177
+        <rdar://problem/52074986>
+
+        Reviewed by Eric Carlson.
+
+        * Configurations/libwebrtc.iOS.exp:
+        * Configurations/libwebrtc.iOSsim.exp:
+        * Configurations/libwebrtc.mac.exp:
+
 2019-06-28  Dean Jackson  <dino@apple.com>
 
         unable to build WebRTC for iOS Simulator
index 2b06ca8..646d8d4 100644 (file)
@@ -247,3 +247,4 @@ __ZN6webrtc16RtpFecParametersD1Ev
 __ZN6webrtc16RtpRtxParametersC1ERKS0_
 __ZN6webrtc16RtpRtxParametersD1Ev
 __ZN3rtc10LogMessage12SetLogOutputENS_15LoggingSeverityEPFvS1_PKcE
+__ZN6webrtc13CryptoOptions5NoGcmEv
index 6c366cf..980c3f4 100644 (file)
@@ -248,3 +248,4 @@ __ZN6webrtc16RtpFecParametersD1Ev
 __ZN6webrtc16RtpRtxParametersC1ERKS0_
 __ZN6webrtc16RtpRtxParametersD1Ev
 __ZN3rtc10LogMessage12SetLogOutputENS_15LoggingSeverityEPFvS1_PKcE
+__ZN6webrtc13CryptoOptions5NoGcmEv
index 6c366cf..980c3f4 100644 (file)
@@ -248,3 +248,4 @@ __ZN6webrtc16RtpFecParametersD1Ev
 __ZN6webrtc16RtpRtxParametersC1ERKS0_
 __ZN6webrtc16RtpRtxParametersD1Ev
 __ZN3rtc10LogMessage12SetLogOutputENS_15LoggingSeverityEPFvS1_PKcE
+__ZN6webrtc13CryptoOptions5NoGcmEv
index eb1a3f7..3852c86 100644 (file)
@@ -1,3 +1,32 @@
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
+        Enable a debug WebRTC mode without any encryption
+        https://bugs.webkit.org/show_bug.cgi?id=199177
+        <rdar://problem/52074986>
+
+        Reviewed by Eric Carlson.
+
+        For every RTCPeerConnection, first set whether to use encryption or not
+        based on page settings.
+        If encryption is disabled, log it.
+        Add internals API to toggle the switch from tests.
+        Test: webrtc/disable-encryption.html
+
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::RTCPeerConnection):
+        * Modules/mediastream/libwebrtc/LibWebRTCPeerConnectionBackend.cpp:
+        (WebCore::createLibWebRTCPeerConnectionBackend):
+        * inspector/agents/InspectorPageAgent.cpp:
+        * page/Settings.yaml:
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.cpp:
+        (WebCore::LibWebRTCProvider::setEnableWebRTCEncryption):
+        * platform/mediastream/libwebrtc/LibWebRTCProvider.h:
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+        (WebCore::Internals::setEnableWebRTCEncryption):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2019-07-15  Sihui Liu  <sihui_liu@apple.com>
 
         window.openDatabase is not writable
index 8713fdd..e439186 100644 (file)
@@ -52,6 +52,7 @@
 #include "RTCIceCandidate.h"
 #include "RTCPeerConnectionIceEvent.h"
 #include "RTCSessionDescription.h"
+#include "Settings.h"
 #include <wtf/CryptographicallyRandomNumber.h>
 #include <wtf/IsoMallocInlines.h>
 #include <wtf/MainThread.h>
@@ -89,6 +90,13 @@ RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context)
     , m_backend(PeerConnectionBackend::create(*this))
 {
     ALWAYS_LOG(LOGIDENTIFIER);
+
+#if !RELEASE_LOG_DISABLED
+    auto* page = downcast<Document>(context).page();
+    if (page && !page->settings().webRTCEncryptionEnabled())
+        ALWAYS_LOG(LOGIDENTIFIER, "encryption is disabled");
+#endif
+
     if (!m_backend)
         m_connectionState = RTCPeerConnectionState::Closed;
 }
index 851fdde..207f15e 100644 (file)
@@ -46,6 +46,7 @@
 #include "RealtimeOutgoingAudioSource.h"
 #include "RealtimeOutgoingVideoSource.h"
 #include "RuntimeEnabledFeatures.h"
+#include "Settings.h"
 
 namespace WebCore {
 
@@ -58,6 +59,8 @@ static std::unique_ptr<PeerConnectionBackend> createLibWebRTCPeerConnectionBacke
     if (!page)
         return nullptr;
 
+    page->libWebRTCProvider().setEnableWebRTCEncryption(page->settings().webRTCEncryptionEnabled());
+
     return std::make_unique<LibWebRTCPeerConnectionBackend>(peerConnection, page->libWebRTCProvider());
 }
 
index c6762e6..a0f4ad8 100644 (file)
@@ -93,6 +93,7 @@ using namespace Inspector;
     macro(MockCaptureDevicesEnabled) \
     macro(NeedsSiteSpecificQuirks) \
     macro(ScriptEnabled) \
+    macro(WebRTCEncryptionEnabled) \
     macro(WebSecurityEnabled)
 
 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEncodingName, String* result)
index 8a74147..e097408 100644 (file)
@@ -850,6 +850,10 @@ shouldDispatchSyntheticMouseOutAfterSyntheticClick:
 allowViewportShrinkToFitContent:
   initial: true
 
+webRTCEncryptionEnabled:
+  initial: true
+  inspectorOverride: true
+
 # Deprecated
 
 iceCandidateFilteringEnabled:
index ffe50e6..3aa90cf 100644 (file)
@@ -297,6 +297,17 @@ rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPee
     return createPeerConnection(observer, *factoryAndThreads.networkManager, *factoryAndThreads.packetSocketFactory, WTFMove(configuration), nullptr);
 }
 
+void LibWebRTCProvider::setEnableWebRTCEncryption(bool enableWebRTCEncryption)
+{
+    auto* factory = this->factory();
+    if (!factory)
+        return;
+
+    webrtc::PeerConnectionFactoryInterface::Options options;
+    options.disable_encryption = !enableWebRTCEncryption;
+    m_factory->SetOptions(options);
+}
+
 rtc::scoped_refptr<webrtc::PeerConnectionInterface> LibWebRTCProvider::createPeerConnection(webrtc::PeerConnectionObserver& observer, rtc::NetworkManager& networkManager, rtc::PacketSocketFactory& packetSocketFactory, webrtc::PeerConnectionInterface::RTCConfiguration&& configuration, std::unique_ptr<webrtc::AsyncResolverFactory>&& asyncResolveFactory)
 {
     auto& factoryAndThreads = getStaticFactoryAndThreads(m_useNetworkThreadWithSocketServer);
index 1a18431..248572f 100644 (file)
@@ -116,6 +116,7 @@ public:
     void clearFactory() { m_factory = nullptr; }
 
     void setEnableLogging(bool);
+    void setEnableWebRTCEncryption(bool);
 
 protected:
     LibWebRTCProvider() = default;
index e147d59..e5047c2 100644 (file)
@@ -527,6 +527,7 @@ void Internals::resetToConsistentState(Page& page)
     WebCore::useRealRTCPeerConnectionFactory(rtcProvider);
     rtcProvider.disableNonLocalhostConnections();
     RuntimeEnabledFeatures::sharedFeatures().setWebRTCVP8CodecEnabled(true);
+    page.settings().setWebRTCEncryptionEnabled(true);
 #endif
 
     page.settings().setStorageAccessAPIEnabled(false);
@@ -1506,6 +1507,14 @@ void Internals::applyRotationForOutgoingVideoSources(RTCPeerConnection& connecti
 {
     connection.applyRotationForOutgoingVideoSources();
 }
+
+void Internals::setEnableWebRTCEncryption(bool value)
+{
+#if USE(LIBWEBRTC)
+    if (auto* page = contextDocument()->page())
+        page->settings().setWebRTCEncryptionEnabled(value);
+#endif
+}
 #endif
 
 #if ENABLE(MEDIA_STREAM)
index 91a7e00..b7f2580 100644 (file)
@@ -535,6 +535,7 @@ public:
     void stopPeerConnection(RTCPeerConnection&);
     void clearPeerConnectionFactory();
     void applyRotationForOutgoingVideoSources(RTCPeerConnection&);
+    void setEnableWebRTCEncryption(bool);
 #endif
 
     String getImageSourceURL(Element&);
index dc9752e..0eb589f 100644 (file)
@@ -607,6 +607,7 @@ enum CompositingPolicy {
     [Conditional=WEB_RTC] void setEnumeratingAllNetworkInterfacesEnabled(boolean enabled);
     [Conditional=WEB_RTC] void stopPeerConnection(RTCPeerConnection connection);
     [Conditional=WEB_RTC] void clearPeerConnectionFactory();
+    [Conditional=WEB_RTC] void setEnableWebRTCEncryption(boolean enabled);
 
     [Conditional=VIDEO] void simulateSystemSleep();
     [Conditional=VIDEO] void simulateSystemWake();
index bb26c4b..95a71e1 100644 (file)
@@ -1,3 +1,14 @@
+2019-07-15  Youenn Fablet  <youenn@apple.com>
+
+        Enable a debug WebRTC mode without any encryption
+        https://bugs.webkit.org/show_bug.cgi?id=199177
+        <rdar://problem/52074986>
+
+        Reviewed by Eric Carlson.
+
+        * Localizations/en.lproj/localizedStrings.js:
+        * UserInterface/Base/Main.js:
+
 2019-07-15  Greg Doolittle <gr3g@apple.com>
 
         Web Inspector: AXI: Audit: Typos in Accessibility audits
index 2e350d9..4958dfb 100644 (file)
@@ -335,6 +335,7 @@ localizedStrings["Dimensions"] = "Dimensions";
 localizedStrings["Disable Breakpoint"] = "Disable Breakpoint";
 localizedStrings["Disable Breakpoints"] = "Disable Breakpoints";
 localizedStrings["Disable Descendant Breakpoints"] = "Disable Descendant Breakpoints";
+localizedStrings["Disable Encryption"] = "Disable Encryption";
 localizedStrings["Disable Event Listener"] = "Disable Event Listener";
 localizedStrings["Disable ICE Candidate Restrictions"] = "Disable ICE Candidate Restrictions";
 localizedStrings["Disable Program"] = "Disable Program";
index f244434..52db86d 100644 (file)
@@ -2258,6 +2258,7 @@ WI._handleDeviceSettingsToolbarButtonClicked = function(event)
                     {name: WI.UIString("Allow Media Capture on Insecure Sites"), setting: PageAgent.Setting.MediaCaptureRequiresSecureConnection, value: false},
                     {name: WI.UIString("Disable ICE Candidate Restrictions"), setting: PageAgent.Setting.ICECandidateFilteringEnabled, value: false},
                     {name: WI.UIString("Use Mock Capture Devices"), setting: PageAgent.Setting.MockCaptureDevicesEnabled, value: true},
+                    {name: WI.UIString("Disable Encryption"), setting: PageAgent.Setting.WebRTCEncryptionEnabled, value: false},
                 ],
             ],
         },