Changeset 255522 in webkit


Ignore:
Timestamp:
Jan 31, 2020, 3:16:47 PM (6 years ago)
Author:
commit-queue@webkit.org
Message:

Add KVO SPI WKWebView._negotiatedLegacyTLS
https://bugs.webkit.org/show_bug.cgi?id=207067

Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-31
Reviewed by Andy Estes.

Source/WebKit:

Covered by API tests.

  • NetworkProcess/NetworkDataTask.cpp:

(WebKit::NetworkDataTask::negotiatedLegacyTLS const):

  • NetworkProcess/NetworkDataTask.h:

(WebKit::NetworkDataTaskClient::negotiatedLegacyTLS const):

  • NetworkProcess/NetworkLoad.cpp:

(WebKit::NetworkLoad::negotiatedLegacyTLS const):

  • NetworkProcess/NetworkLoad.h:
  • NetworkProcess/cocoa/NetworkSessionCocoa.mm:

(-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):

  • Shared/Authentication/AuthenticationManager.cpp:

(WebKit::AuthenticationManager::negotiatedLegacyTLS const):

  • Shared/Authentication/AuthenticationManager.h:
  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView _negotiatedLegacyTLS]):

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
  • UIProcess/Cocoa/NavigationState.h:
  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::NavigationState::willChangeNegotiatedLegacyTLS):
(WebKit::NavigationState::didChangeNegotiatedLegacyTLS):

  • UIProcess/Network/NetworkProcessProxy.cpp:

(WebKit::NetworkProcessProxy::negotiatedLegacyTLS):

  • UIProcess/Network/NetworkProcessProxy.h:
  • UIProcess/Network/NetworkProcessProxy.messages.in:
  • UIProcess/PageLoadState.cpp:

(WebKit::PageLoadState::commitChanges):
(WebKit::PageLoadState::hasNegotiatedLegacyTLS const):
(WebKit::PageLoadState::negotiatedLegacyTLS):
(WebKit::PageLoadState::didCommitLoad):

  • UIProcess/PageLoadState.h:

(WebKit::PageLoadState::Observer::willChangeNegotiatedLegacyTLS):
(WebKit::PageLoadState::Observer::didChangeNegotiatedLegacyTLS):
(WebKit::PageLoadState::Data::Data): Deleted.

  • UIProcess/WebPageProxy.cpp:
  • UIProcess/WebPageProxy.h:

Tools:

  • TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:

(-[TLSObserver observeValueForKeyPath:ofObject:change:context:]):
(-[TLSObserver waitUntilNegotiatedLegacyTLSChanged]):
(TestWebKitAPI::TEST):

  • TestWebKitAPI/config.h:
Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r255519 r255522  
     12020-01-31  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add KVO SPI WKWebView._negotiatedLegacyTLS
     4        https://bugs.webkit.org/show_bug.cgi?id=207067
     5
     6        Reviewed by Andy Estes.
     7
     8        Covered by API tests.
     9
     10        * NetworkProcess/NetworkDataTask.cpp:
     11        (WebKit::NetworkDataTask::negotiatedLegacyTLS const):
     12        * NetworkProcess/NetworkDataTask.h:
     13        (WebKit::NetworkDataTaskClient::negotiatedLegacyTLS const):
     14        * NetworkProcess/NetworkLoad.cpp:
     15        (WebKit::NetworkLoad::negotiatedLegacyTLS const):
     16        * NetworkProcess/NetworkLoad.h:
     17        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
     18        (-[WKNetworkSessionDelegate URLSession:dataTask:didReceiveResponse:completionHandler:]):
     19        * Shared/Authentication/AuthenticationManager.cpp:
     20        (WebKit::AuthenticationManager::negotiatedLegacyTLS const):
     21        * Shared/Authentication/AuthenticationManager.h:
     22        * UIProcess/API/Cocoa/WKWebView.mm:
     23        (-[WKWebView _negotiatedLegacyTLS]):
     24        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     25        * UIProcess/Cocoa/NavigationState.h:
     26        * UIProcess/Cocoa/NavigationState.mm:
     27        (WebKit::NavigationState::willChangeNegotiatedLegacyTLS):
     28        (WebKit::NavigationState::didChangeNegotiatedLegacyTLS):
     29        * UIProcess/Network/NetworkProcessProxy.cpp:
     30        (WebKit::NetworkProcessProxy::negotiatedLegacyTLS):
     31        * UIProcess/Network/NetworkProcessProxy.h:
     32        * UIProcess/Network/NetworkProcessProxy.messages.in:
     33        * UIProcess/PageLoadState.cpp:
     34        (WebKit::PageLoadState::commitChanges):
     35        (WebKit::PageLoadState::hasNegotiatedLegacyTLS const):
     36        (WebKit::PageLoadState::negotiatedLegacyTLS):
     37        (WebKit::PageLoadState::didCommitLoad):
     38        * UIProcess/PageLoadState.h:
     39        (WebKit::PageLoadState::Observer::willChangeNegotiatedLegacyTLS):
     40        (WebKit::PageLoadState::Observer::didChangeNegotiatedLegacyTLS):
     41        (WebKit::PageLoadState::Data::Data): Deleted.
     42        * UIProcess/WebPageProxy.cpp:
     43        * UIProcess/WebPageProxy.h:
     44
    1452020-01-31  Chris Dumez  <cdumez@apple.com>
    246
  • trunk/Source/WebKit/NetworkProcess/NetworkDataTask.cpp

    r252185 r255522  
    117117}
    118118
     119void NetworkDataTask::negotiatedLegacyTLS() const
     120{
     121    if (m_client)
     122        m_client->negotiatedLegacyTLS();
     123}
     124
    119125bool NetworkDataTask::shouldCaptureExtraNetworkLoadMetrics() const
    120126{
  • trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h

    r255461 r255522  
    7171    virtual void wasBlockedByRestrictions() = 0;
    7272
     73    virtual void negotiatedLegacyTLS() const { }
    7374    virtual bool shouldCaptureExtraNetworkLoadMetrics() const { return false; }
    7475
     
    9394
    9495    void didReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&);
     96    void negotiatedLegacyTLS() const;
    9597    bool shouldCaptureExtraNetworkLoadMetrics() const;
    9698
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp

    r255461 r255522  
    207207}
    208208
     209void NetworkLoad::negotiatedLegacyTLS() const
     210{
     211    m_networkProcess->authenticationManager().negotiatedLegacyTLS(m_parameters.webPageProxyID);
     212}
     213
    209214void NetworkLoad::didReceiveResponse(ResourceResponse&& response, ResponseCompletionHandler&& completionHandler)
    210215{
  • trunk/Source/WebKit/NetworkProcess/NetworkLoad.h

    r255461 r255522  
    8282    void cannotShowURL() final;
    8383    void wasBlockedByRestrictions() final;
     84    void negotiatedLegacyTLS() const final;
    8485
    8586    void notifyDidReceiveResponse(WebCore::ResourceResponse&&, ResponseCompletionHandler&&);
  • trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm

    r255461 r255522  
    814814    if (auto* networkDataTask = [self existingTask:dataTask]) {
    815815        ASSERT(RunLoop::isMain());
     816
     817        bool negotiatedLegacyTLS = false;
     818#if HAVE(TLS_PROTOCOL_VERSION_T)
     819        NSURLSessionTaskTransactionMetrics *metrics = dataTask._incompleteTaskMetrics.transactionMetrics.lastObject;
     820        auto tlsVersion = reinterpret_cast<tls_protocol_version_t>(metrics.negotiatedTLSProtocolVersion.unsignedShortValue);
     821        if (tlsVersion == tls_protocol_version_TLSv10 || tlsVersion == tls_protocol_version_TLSv11)
     822            negotiatedLegacyTLS = true;
     823        UNUSED_PARAM(metrics);
     824#else // We do not need to check _TLSNegotiatedProtocolVersion if we have metrics.negotiatedTLSProtocolVersion because it works at response time even before rdar://problem/56522601
     825        ALLOW_DEPRECATED_DECLARATIONS_BEGIN
     826        if ([dataTask respondsToSelector:@selector(_TLSNegotiatedProtocolVersion)]) {
     827            SSLProtocol tlsVersion = [dataTask _TLSNegotiatedProtocolVersion];
     828            if (tlsVersion == kTLSProtocol11 || tlsVersion == kTLSProtocol1)
     829                negotiatedLegacyTLS = true;
     830        }
     831        ALLOW_DEPRECATED_DECLARATIONS_END
     832#endif
     833        if (negotiatedLegacyTLS)
     834            networkDataTask->negotiatedLegacyTLS();
    816835       
    817836        // Avoid MIME type sniffing if the response comes back as 304 Not Modified.
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.cpp

    r255461 r255522  
    150150}
    151151
     152void AuthenticationManager::negotiatedLegacyTLS(WebPageProxyIdentifier pageID) const
     153{
     154    m_process.send(Messages::NetworkProcessProxy::NegotiatedLegacyTLS(pageID));
     155}
     156
    152157} // namespace WebKit
  • trunk/Source/WebKit/Shared/Authentication/AuthenticationManager.h

    r255461 r255522  
    7676    void completeAuthenticationChallenge(uint64_t challengeID, AuthenticationChallengeDisposition, WebCore::Credential&&);
    7777
     78    void negotiatedLegacyTLS(WebPageProxyIdentifier) const;
     79
    7880private:
    7981    struct Challenge {
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm

    r255132 r255522  
    15511551}
    15521552
     1553- (BOOL)_negotiatedLegacyTLS
     1554{
     1555    return _page->pageLoadState().hasNegotiatedLegacyTLS();
     1556}
     1557
    15531558- (BOOL)_isEditable
    15541559{
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r255220 r255522  
    165165@property (nonatomic, getter=_isEditable, setter=_setEditable:) BOOL _editable WK_API_AVAILABLE(macos(10.11), ios(9.0));
    166166
     167/*! @abstract A Boolean value indicating whether any resource on the page
     168has been loaded over a connection using TLS 1.0 or TLS 1.1.
     169@discussion @link WKWebView @/link is key-value observing (KVO) compliant
     170for this property.
     171*/
     172@property (nonatomic, readonly) BOOL _negotiatedLegacyTLS WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
     173
    167174// FIXME: Remove these once nobody is using them.
    168175@property (nonatomic, readonly) NSData *_sessionStateData;
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h

    r255461 r255522  
    171171    void willChangeHasOnlySecureContent() override;
    172172    void didChangeHasOnlySecureContent() override;
     173    void willChangeNegotiatedLegacyTLS() override;
     174    void didChangeNegotiatedLegacyTLS() override;
    173175    void willChangeEstimatedProgress() override;
    174176    void didChangeEstimatedProgress() override;
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r255461 r255522  
    13221322}
    13231323
     1324void NavigationState::willChangeNegotiatedLegacyTLS()
     1325{
     1326    [m_webView willChangeValueForKey:@"_negotiatedLegacyTLS"];
     1327}
     1328
     1329void NavigationState::didChangeNegotiatedLegacyTLS()
     1330{
     1331    [m_webView didChangeValueForKey:@"_negotiatedLegacyTLS"];
     1332}
     1333
    13241334void NavigationState::willChangeEstimatedProgress()
    13251335{
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp

    r255461 r255522  
    370370}
    371371
     372void NetworkProcessProxy::negotiatedLegacyTLS(WebPageProxyIdentifier pageID)
     373{
     374    WebPageProxy* page = nullptr;
     375    if (pageID)
     376        page = WebProcessProxy::webPage(pageID);
     377    if (page)
     378        page->negotiatedLegacyTLS();
     379}
     380
    372381void NetworkProcessProxy::didFetchWebsiteData(uint64_t callbackID, const WebsiteData& websiteData)
    373382{
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h

    r255461 r255522  
    237237    void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
    238238    void didReceiveAuthenticationChallenge(PAL::SessionID, WebPageProxyIdentifier, const Optional<WebCore::SecurityOriginData>&, WebCore::AuthenticationChallenge&&, bool, uint64_t challengeID);
     239    void negotiatedLegacyTLS(WebPageProxyIdentifier);
    239240    void didFetchWebsiteData(uint64_t callbackID, const WebsiteData&);
    240241    void didDeleteWebsiteData(uint64_t callbackID);
  • trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in

    r255461 r255522  
    2323messages -> NetworkProcessProxy LegacyReceiver NotRefCounted {
    2424    DidReceiveAuthenticationChallenge(PAL::SessionID sessionID, WebKit::WebPageProxyIdentifier pageID, Optional<WebCore::SecurityOriginData> topOrigin, WebCore::AuthenticationChallenge challenge, bool negotiatedLegacyTLS, uint64_t challengeID)
     25    NegotiatedLegacyTLS(WebKit::WebPageProxyIdentifier pageID)
    2526
    2627    DidFetchWebsiteData(uint64_t callbackID, struct WebKit::WebsiteData websiteData)
  • trunk/Source/WebKit/UIProcess/PageLoadState.cpp

    r247851 r255522  
    100100    bool activeURLChanged = activeURL(m_committedState) != activeURL(m_uncommittedState);
    101101    bool hasOnlySecureContentChanged = hasOnlySecureContent(m_committedState) != hasOnlySecureContent(m_uncommittedState);
     102    bool negotiatedLegacyTLSChanged = m_committedState.negotiatedLegacyTLS != m_uncommittedState.negotiatedLegacyTLS;
    102103    bool estimatedProgressChanged = estimatedProgress(m_committedState) != estimatedProgress(m_uncommittedState);
    103104    bool networkRequestsInProgressChanged = m_committedState.networkRequestsInProgress != m_uncommittedState.networkRequestsInProgress;
     
    116117    if (hasOnlySecureContentChanged)
    117118        callObserverCallback(&Observer::willChangeHasOnlySecureContent);
     119    if (negotiatedLegacyTLSChanged)
     120        callObserverCallback(&Observer::willChangeNegotiatedLegacyTLS);
    118121    if (estimatedProgressChanged)
    119122        callObserverCallback(&Observer::willChangeEstimatedProgress);
     
    136139    if (hasOnlySecureContentChanged)
    137140        callObserverCallback(&Observer::didChangeHasOnlySecureContent);
     141    if (negotiatedLegacyTLSChanged)
     142        callObserverCallback(&Observer::didChangeNegotiatedLegacyTLS);
    138143    if (activeURLChanged)
    139144        callObserverCallback(&Observer::didChangeActiveURL);
     
    222227}
    223228
     229bool PageLoadState::hasNegotiatedLegacyTLS() const
     230{
     231    return m_committedState.negotiatedLegacyTLS;
     232}
     233
     234void PageLoadState::negotiatedLegacyTLS(const Transaction::Token& token)
     235{
     236    ASSERT_UNUSED(token, &token.m_pageLoadState == this);
     237    m_uncommittedState.negotiatedLegacyTLS = true;
     238}
     239
    224240double PageLoadState::estimatedProgress(const Data& data)
    225241{
     
    313329    m_uncommittedState.url = m_uncommittedState.provisionalURL;
    314330    m_uncommittedState.provisionalURL = String();
     331    m_uncommittedState.negotiatedLegacyTLS = false;
    315332
    316333    m_uncommittedState.title = String();
  • trunk/Source/WebKit/UIProcess/PageLoadState.h

    r254087 r255522  
    6363        virtual void didChangeHasOnlySecureContent() = 0;
    6464
     65        virtual void willChangeNegotiatedLegacyTLS() { };
     66        virtual void didChangeNegotiatedLegacyTLS() { };
     67
    6568        virtual void willChangeEstimatedProgress() = 0;
    6669        virtual void didChangeEstimatedProgress() = 0;
     
    141144
    142145    bool hasOnlySecureContent() const;
     146    bool hasNegotiatedLegacyTLS() const;
     147    void negotiatedLegacyTLS(const Transaction::Token&);
    143148
    144149    double estimatedProgress() const;
     
    201206
    202207    struct Data {
    203         Data()
    204             : state(State::Finished)
    205             , hasInsecureContent(false)
    206             , canGoBack(false)
    207             , canGoForward(false)
    208             , estimatedProgress(0)
    209             , networkRequestsInProgress(false)
    210         {
    211         }
    212 
    213         State state;
    214         bool hasInsecureContent;
     208        State state { State::Finished };
     209        bool hasInsecureContent { false };
     210        bool negotiatedLegacyTLS { false };
    215211
    216212        PendingAPIRequest pendingAPIRequest;
     
    225221        URL resourceDirectoryURL;
    226222
    227         bool canGoBack;
    228         bool canGoForward;
    229 
    230         double estimatedProgress;
    231         bool networkRequestsInProgress;
     223        bool canGoBack { false };
     224        bool canGoForward { false };
     225
     226        double estimatedProgress { 0 };
     227        bool networkRequestsInProgress { false };
    232228
    233229        RefPtr<WebCertificateInfo> certificateInfo;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r255519 r255522  
    77147714}
    77157715
     7716void WebPageProxy::negotiatedLegacyTLS()
     7717{
     7718    auto transaction = m_pageLoadState.transaction();
     7719    m_pageLoadState.negotiatedLegacyTLS(transaction);
     7720}
     7721
    77167722void WebPageProxy::exceededDatabaseQuota(FrameIdentifier frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply&& reply)
    77177723{
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r255461 r255522  
    13361336
    13371337    void didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&&, NegotiatedLegacyTLS);
     1338    void negotiatedLegacyTLS();
    13381339
    13391340    SpellDocumentTag spellDocumentTag();
  • trunk/Tools/ChangeLog

    r255513 r255522  
     12020-01-31  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add KVO SPI WKWebView._negotiatedLegacyTLS
     4        https://bugs.webkit.org/show_bug.cgi?id=207067
     5
     6        Reviewed by Andy Estes.
     7
     8        * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
     9        (-[TLSObserver observeValueForKeyPath:ofObject:change:context:]):
     10        (-[TLSObserver waitUntilNegotiatedLegacyTLSChanged]):
     11        (TestWebKitAPI::TEST):
     12        * TestWebKitAPI/config.h:
     13
    1142020-01-31  Aakash Jain  <aakash_jain@apple.com>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm

    r255461 r255522  
    4444#endif
    4545
     46#if HAVE(TLS_PROTOCOL_VERSION_T)
     47@interface TLSObserver : NSObject
     48- (void)waitUntilNegotiatedLegacyTLSChanged;
     49@end
     50
     51@implementation TLSObserver {
     52    bool _negotiatedLegacyTLSChanged;
     53}
     54
     55- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
     56{
     57    EXPECT_WK_STREQ(keyPath, "_negotiatedLegacyTLS");
     58    _negotiatedLegacyTLSChanged = true;
     59}
     60
     61- (void)waitUntilNegotiatedLegacyTLSChanged
     62{
     63    _negotiatedLegacyTLSChanged = false;
     64    while (!_negotiatedLegacyTLSChanged)
     65        TestWebKitAPI::Util::spinRunLoop();
     66}
     67
     68@end
     69#endif
     70
    4671@interface TLSNavigationDelegate : NSObject <WKNavigationDelegate>
    4772- (void)waitForDidFinishNavigation;
     
    203228}
    204229
     230#if HAVE(TLS_PROTOCOL_VERSION_T)
     231TEST(TLSVersion, NegotiatedLegacyTLS)
     232{
     233    TCPServer server(TCPServer::Protocol::HTTPS, [] (SSL *ssl) {
     234        TCPServer::respondWithOK(ssl);
     235        TCPServer::respondWithOK(ssl);
     236    }, tls1_1);
     237
     238    auto delegate = adoptNS([TestNavigationDelegate new]);
     239    auto webView = adoptNS([WKWebView new]);
     240    [webView setNavigationDelegate:delegate.get()];
     241    [delegate setDidReceiveAuthenticationChallenge:^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^callback)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
     242        EXPECT_WK_STREQ(challenge.protectionSpace.authenticationMethod, NSURLAuthenticationMethodServerTrust);
     243        callback(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
     244    }];
     245    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://127.0.0.1:%d/", server.port()]]];
     246    [webView loadRequest:request];
     247
     248    auto observer = adoptNS([TLSObserver new]);
     249    [webView addObserver:observer.get() forKeyPath:@"_negotiatedLegacyTLS" options:NSKeyValueObservingOptionNew context:nil];
     250   
     251    EXPECT_FALSE([webView _negotiatedLegacyTLS]);
     252    [observer waitUntilNegotiatedLegacyTLSChanged];
     253    EXPECT_TRUE([webView _negotiatedLegacyTLS]);
     254
     255    [webView loadRequest:[NSURLRequest requestWithURL:[[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"]]];
     256    [observer waitUntilNegotiatedLegacyTLSChanged];
     257    EXPECT_FALSE([webView _negotiatedLegacyTLS]);
     258
     259    [webView loadRequest:request];
     260    [observer waitUntilNegotiatedLegacyTLSChanged];
     261    EXPECT_TRUE([webView _negotiatedLegacyTLS]);
     262
     263    [webView removeObserver:observer.get() forKeyPath:@"_negotiatedLegacyTLS"];
     264}
     265#endif
     266
    205267// FIXME: Add some tests for WKWebView.hasOnlySecureContent
    206268
  • trunk/Tools/TestWebKitAPI/config.h

    r252476 r255522  
    123123#define HAVE_NETWORK_FRAMEWORK 1
    124124#endif
     125
     126#if PLATFORM(COCOA) && !(PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < 101500)
     127#define HAVE_TLS_PROTOCOL_VERSION_T 1
     128#endif
Note: See TracChangeset for help on using the changeset viewer.