Changeset 270626 in webkit


Ignore:
Timestamp:
Dec 10, 2020 7:37:49 AM (20 months ago)
Author:
youenn@apple.com
Message:

ICE does not resolve for turns relay candidates rooted in LetsEncrypt CA
https://bugs.webkit.org/show_bug.cgi?id=219274

Reviewed by Eric Carlson.

Source/ThirdParty/libwebrtc:

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

Source/WebCore:

Introduce a new runtime flag that is used to control whether using the new webrtc socket code path or not.

  • page/RuntimeEnabledFeatures.h:

(WebCore::RuntimeEnabledFeatures::webRTCPlatformSocketsEnabled const):
(WebCore::RuntimeEnabledFeatures::setWebRTCPlatformSocketsEnabled):

Source/WebKit:

Use NWConnection for client TCP sockets.
This allows piggy-backing on this API for things such as proxies or certificate validation.
Implementation does opening a TCP socket with TLS using NWConnection:

  • If the socket is created for STUN/TURN, it is sending packets as is. For receiving data, the socket

will make sure to split received data in meaningful messages that WebProcess will process.

  • If the socket is TCP for data, sent data is prefixed with the size of the data. For received data,

the length of the message is read and we wait to receive the whole message data to send it to WebProcess.

We enable that new code path based on an experimental feature.
Tested manually with TURNS servers and TCP-only connections.

  • NetworkProcess/webrtc/NetworkRTCProvider.cpp:

(WebKit::NetworkRTCProvider::createClientTCPSocket):

  • NetworkProcess/webrtc/NetworkRTCProvider.h:

(WebKit::NetworkRTCProvider::setPlatformSocketsEnabled):

  • NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
  • NetworkProcess/webrtc/NetworkRTCSocketSocketCocoa.h: Added.
  • NetworkProcess/webrtc/NetworkRTCSocketSocketCocoa.mm: Added.

(WebKit::socketQueue):
(WebKit::NetworkRTCSocketSocketCocoa::createClientTCPSocket):
(WebKit::isStunMessage):
(WebKit::getSTUNOrTURNMessageLength):
(WebKit::extractSTUNOrTURNMessages):
(WebKit::extractMessages):
(WebKit::processMessage):
(WebKit::NetworkRTCSocketSocketCocoa::NetworkRTCSocketSocketCocoa):
(WebKit::NetworkRTCSocketSocketCocoa::close):
(WebKit::NetworkRTCSocketSocketCocoa::setOption):
(WebKit::dataFromVector):
(WebKit::NetworkRTCSocketSocketCocoa::sendTo):

  • SourcesCocoa.txt:
  • WebKit.xcodeproj/project.pbxproj:
  • WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:

(WebKit::LibWebRTCSocketFactory::setConnection):

Source/WTF:

  • Scripts/Preferences/WebPreferencesExperimental.yaml:
Location:
trunk/Source
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r270445 r270626  
     12020-12-10  Youenn Fablet  <youenn@apple.com>
     2
     3        ICE does not resolve for `turns` relay candidates rooted in LetsEncrypt CA
     4        https://bugs.webkit.org/show_bug.cgi?id=219274
     5
     6        Reviewed by Eric Carlson.
     7
     8        * Configurations/libwebrtc.iOS.exp:
     9        * Configurations/libwebrtc.iOSsim.exp:
     10        * Configurations/libwebrtc.mac.exp:
     11
    1122020-12-04  Adam Roben  <aroben@apple.com>
    213
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOS.exp

    r269764 r270626  
    8888__ZN3rtc13SocketAddress5SetIPERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
    8989__ZNK3rtc9IPAddress12ipv4_addressEv
     90__ZNK3rtc9IPAddress8ToStringEv
    9091__ZN3rtc7NetworkC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_RKNS_9IPAddressEiNS_11AdapterTypeE
    9192__ZN3rtc7Network6SetIPsERKNSt3__16vectorINS_16InterfaceAddressENS1_9allocatorIS3_EEEEb
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.iOSsim.exp

    r269764 r270626  
    8888__ZN3rtc13SocketAddress5SetIPERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
    8989__ZNK3rtc9IPAddress12ipv4_addressEv
     90__ZNK3rtc9IPAddress8ToStringEv
    9091__ZN3rtc7NetworkC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_RKNS_9IPAddressEiNS_11AdapterTypeE
    9192__ZN3rtc7Network6SetIPsERKNSt3__16vectorINS_16InterfaceAddressENS1_9allocatorIS3_EEEEb
  • trunk/Source/ThirdParty/libwebrtc/Configurations/libwebrtc.mac.exp

    r269764 r270626  
    8888__ZN3rtc13SocketAddress5SetIPERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
    8989__ZNK3rtc9IPAddress12ipv4_addressEv
     90__ZNK3rtc9IPAddress8ToStringEv
    9091__ZN3rtc7NetworkC1ERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_RKNS_9IPAddressEiNS_11AdapterTypeE
    9192__ZN3rtc7Network6SetIPsERKNSt3__16vectorINS_16InterfaceAddressENS1_9allocatorIS3_EEEEb
  • trunk/Source/WTF/ChangeLog

    r270619 r270626  
     12020-12-10  Youenn Fablet  <youenn@apple.com>
     2
     3        ICE does not resolve for `turns` relay candidates rooted in LetsEncrypt CA
     4        https://bugs.webkit.org/show_bug.cgi?id=219274
     5
     6        Reviewed by Eric Carlson.
     7
     8        * Scripts/Preferences/WebPreferencesExperimental.yaml:
     9
    1102020-12-10  Jiewen Tan  <jiewen_tan@apple.com>
    211
  • trunk/Source/WTF/Scripts/Preferences/WebPreferencesExperimental.yaml

    r270613 r270626  
    10501050      default: WebKit::defaultWebRTCCodecsInGPUProcess()
    10511051
     1052WebRTCPlatformSocketsEnabled:
     1053  type: bool
     1054  humanReadableName: "WebRTC Platform Sockets"
     1055  humanReadableDescription: "Enable WebRTC Platform Sockets"
     1056  webcoreBinding: RuntimeEnabledFeatures
     1057  condition: ENABLE(WEB_RTC)
     1058  defaultValue:
     1059    WebKit:
     1060      default: false
     1061
    10521062WebRTCVP9Profile0CodecEnabled:
    10531063  type: bool
  • trunk/Source/WebCore/ChangeLog

    r270625 r270626  
     12020-12-10  Youenn Fablet  <youenn@apple.com>
     2
     3        ICE does not resolve for `turns` relay candidates rooted in LetsEncrypt CA
     4        https://bugs.webkit.org/show_bug.cgi?id=219274
     5
     6        Reviewed by Eric Carlson.
     7
     8        Introduce a new runtime flag that is used to control whether using the new webrtc socket code path or not.
     9
     10        * page/RuntimeEnabledFeatures.h:
     11        (WebCore::RuntimeEnabledFeatures::webRTCPlatformSocketsEnabled const):
     12        (WebCore::RuntimeEnabledFeatures::setWebRTCPlatformSocketsEnabled):
     13
    1142020-12-10  Aditya Keerthi  <akeerthi@apple.com>
    215
  • trunk/Source/WebCore/page/RuntimeEnabledFeatures.h

    r270256 r270626  
    166166    bool webRTCPlatformCodecsInGPUProcessEnabled() const { return m_isWebRTCPlatformCodecsInGPUProcessEnabled; }
    167167    void setWebRTCPlatformCodecsInGPUProcessEnabled(bool isEnabled) { m_isWebRTCPlatformCodecsInGPUProcessEnabled = isEnabled; }
     168    bool webRTCPlatformSocketsEnabled() const { return m_isWebRTCPlatformSocketsEnabled; }
     169    void setWebRTCPlatformSocketsEnabled(bool isEnabled) { m_isWebRTCPlatformSocketsEnabled = isEnabled; }
    168170#endif
    169171
     
    318320    bool m_isWebRTCVP9Profile2CodecEnabled { false };
    319321    bool m_isWebRTCH264LowLatencyEncoderEnabled { false };
     322    bool m_isWebRTCPlatformSocketsEnabled { false };
    320323#endif
    321324
  • trunk/Source/WebKit/ChangeLog

    r270621 r270626  
     12020-12-10  Youenn Fablet  <youenn@apple.com>
     2
     3        ICE does not resolve for `turns` relay candidates rooted in LetsEncrypt CA
     4        https://bugs.webkit.org/show_bug.cgi?id=219274
     5
     6        Reviewed by Eric Carlson.
     7
     8        Use NWConnection for client TCP sockets.
     9        This allows piggy-backing on this API for things such as proxies or certificate validation.
     10        Implementation does opening a TCP socket with TLS using NWConnection:
     11        - If the socket is created for STUN/TURN, it is sending packets as is. For receiving data, the socket
     12        will make sure to split received data in meaningful messages that WebProcess will process.
     13        - If the socket is TCP for data, sent data is prefixed with the size of the data. For received data,
     14        the length of the message is read and we wait to receive the whole message data to send it to WebProcess.
     15
     16        We enable that new code path based on an experimental feature.
     17        Tested manually with TURNS servers and TCP-only connections.
     18
     19        * NetworkProcess/webrtc/NetworkRTCProvider.cpp:
     20        (WebKit::NetworkRTCProvider::createClientTCPSocket):
     21        * NetworkProcess/webrtc/NetworkRTCProvider.h:
     22        (WebKit::NetworkRTCProvider::setPlatformSocketsEnabled):
     23        * NetworkProcess/webrtc/NetworkRTCProvider.messages.in:
     24        * NetworkProcess/webrtc/NetworkRTCSocketSocketCocoa.h: Added.
     25        * NetworkProcess/webrtc/NetworkRTCSocketSocketCocoa.mm: Added.
     26        (WebKit::socketQueue):
     27        (WebKit::NetworkRTCSocketSocketCocoa::createClientTCPSocket):
     28        (WebKit::isStunMessage):
     29        (WebKit::getSTUNOrTURNMessageLength):
     30        (WebKit::extractSTUNOrTURNMessages):
     31        (WebKit::extractMessages):
     32        (WebKit::processMessage):
     33        (WebKit::NetworkRTCSocketSocketCocoa::NetworkRTCSocketSocketCocoa):
     34        (WebKit::NetworkRTCSocketSocketCocoa::close):
     35        (WebKit::NetworkRTCSocketSocketCocoa::setOption):
     36        (WebKit::dataFromVector):
     37        (WebKit::NetworkRTCSocketSocketCocoa::sendTo):
     38        * SourcesCocoa.txt:
     39        * WebKit.xcodeproj/project.pbxproj:
     40        * WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp:
     41        (WebKit::LibWebRTCSocketFactory::setConnection):
     42
    1432020-12-10  Antoine Quint  <graouts@webkit.org>
    244
  • trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.cpp

    r267143 r270626  
    4747#if PLATFORM(COCOA)
    4848#include "NetworkRTCResolverCocoa.h"
     49#include "NetworkRTCSocketCocoa.h"
    4950#endif
    5051
     
    176177        }
    177178        callOnRTCNetworkThread([this, identifier, localAddress = RTCNetwork::isolatedCopy(localAddress.value), remoteAddress = RTCNetwork::isolatedCopy(remoteAddress.value), proxyInfo = proxyInfoFromSession(remoteAddress, *session), userAgent = WTFMove(userAgent).isolatedCopy(), options]() mutable {
     179#if PLATFORM(COCOA)
     180            if (m_platformSocketsEnabled) {
     181                if (auto socket = NetworkRTCSocketCocoa::createClientTCPSocket(identifier, *this, remoteAddress, options, m_ipcConnection.copyRef())) {
     182                    addSocket(identifier, WTFMove(socket));
     183                    return;
     184                }
     185            }
     186#endif
    178187            rtc::PacketSocketTcpOptions tcpOptions;
    179188            tcpOptions.opts = options;
     
    352361}
    353362
    354 void NetworkRTCProvider::sendFromMainThread(Function<void(IPC::Connection&)>&& callback)
    355 {
    356     callOnMainThread([provider = makeRef(*this), callback = WTFMove(callback)]() {
    357         if (provider->m_connection)
    358             callback(provider->m_connection->connection());
    359     });
    360 }
    361 
    362363} // namespace WebKit
    363364
  • trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.h

    r268423 r270626  
    8888
    8989    void callOnRTCNetworkThread(Function<void()>&&);
    90     void sendFromMainThread(Function<void(IPC::Connection&)>&&);
    9190
    9291    void newConnection(Socket&, std::unique_ptr<rtc::AsyncPacketSocket>&&);
     
    109108    void closeSocket(WebCore::LibWebRTCSocketIdentifier);
    110109    void setSocketOption(WebCore::LibWebRTCSocketIdentifier, int option, int value);
     110    void setPlatformSocketsEnabled(bool enabled) { m_platformSocketsEnabled = enabled; }
    111111
    112112    void createResolver(LibWebRTCResolverIdentifier, String&&);
     
    138138    bool m_isListeningSocketAuthorized { true };
    139139    bool m_canLog { false };
     140    bool m_platformSocketsEnabled { false };
    140141};
    141142
  • trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCProvider.messages.in

    r263789 r270626  
    2929    WrapNewTCPConnection(WebCore::LibWebRTCSocketIdentifier identifier, WebCore::LibWebRTCSocketIdentifier newConnectionSocketIdentifier)
    3030
     31    void SetPlatformSocketsEnabled(bool enabled)
     32
    3133    CreateResolver(WebKit::LibWebRTCResolverIdentifier identifier, String address)
    3234    StopResolver(WebKit::LibWebRTCResolverIdentifier identifier)
  • trunk/Source/WebKit/SourcesCocoa.txt

    r270616 r270626  
    5555NetworkProcess/webrtc/NetworkRTCResolver.cpp
    5656NetworkProcess/webrtc/NetworkRTCResolverCocoa.cpp
     57NetworkProcess/webrtc/NetworkRTCSocketCocoa.mm
    5758
    5859GPUProcess/EntryPoint/Cocoa/XPCService/GPUServiceEntryPoint.mm
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r270616 r270626  
    35323532                410482CB1DDD2FB500F006D0 /* RTCNetwork.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCNetwork.cpp; sourceTree = "<group>"; };
    35333533                410482CC1DDD2FB500F006D0 /* RTCNetwork.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RTCNetwork.h; sourceTree = "<group>"; };
     3534                410BA139257135F2002E2F8A /* NetworkRTCSocketCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NetworkRTCSocketCocoa.mm; sourceTree = "<group>"; };
     3535                410BA13A257135F2002E2F8A /* NetworkRTCSocketCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NetworkRTCSocketCocoa.h; sourceTree = "<group>"; };
    35343536                4111436320F677B10026F912 /* InjectUserScriptImmediately.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InjectUserScriptImmediately.h; sourceTree = "<group>"; };
    35353537                411286EF21C8A90C003A8550 /* MediaUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaUtilities.h; sourceTree = "<group>"; };
     
    79907992                                4112B5471F9FD3AB00E67986 /* NetworkRTCResolverCocoa.cpp */,
    79917993                                4112B5481F9FD3AC00E67986 /* NetworkRTCResolverCocoa.h */,
     7994                                410BA13A257135F2002E2F8A /* NetworkRTCSocketCocoa.h */,
     7995                                410BA139257135F2002E2F8A /* NetworkRTCSocketCocoa.mm */,
    79927996                        );
    79937997                        path = webrtc;
  • trunk/Source/WebKit/WebProcess/Network/webrtc/LibWebRTCSocketFactory.cpp

    r264665 r270626  
    3434#include "NetworkRTCProviderMessages.h"
    3535#include "WebProcess.h"
     36#include <WebCore/RuntimeEnabledFeatures.h>
    3637#include <wtf/MainThread.h>
    3738
     
    5354    if (!m_connection)
    5455        return;
     56
     57    m_connection->send(Messages::NetworkRTCProvider::SetPlatformSocketsEnabled(RuntimeEnabledFeatures::sharedFeatures().webRTCPlatformSocketsEnabled()), 0);
    5558
    5659    while (!m_pendingMessageTasks.isEmpty())
Note: See TracChangeset for help on using the changeset viewer.