Title: [260658] trunk
Revision
260658
Author
[email protected]
Date
2020-04-24 11:23:43 -0700 (Fri, 24 Apr 2020)

Log Message

SPI clients using fastServerTrustEvaluationEnabled need SPI to inform them of modern TLS negotiation
https://bugs.webkit.org/show_bug.cgi?id=210533

Patch by Alex Christensen <[email protected]> on 2020-04-24
Reviewed by Brady Eidson.

Source/WebKit:

* NetworkProcess/NetworkDataTask.h:
(WebKit::NetworkDataTaskClient::didNegotiateModernTLS):
* NetworkProcess/NetworkLoad.cpp:
(WebKit::NetworkLoad::didNegotiateModernTLS):
* NetworkProcess/NetworkLoad.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
* NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
(WebKit::NetworkDataTaskCocoa::didNegotiateModernTLS):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
* UIProcess/API/APINavigationClient.h:
(API::NavigationClient::didNegotiateModernTLS):
* UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
* UIProcess/Cocoa/NavigationState.h:
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::setNavigationDelegate):
(WebKit::NavigationState::NavigationClient::didNegotiateModernTLS):
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didNegotiateModernTLS):
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.messages.in:
* UIProcess/WebPageProxy.cpp:
* UIProcess/WebPageProxy.h:

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
(-[TLSNavigationDelegate waitForDidNegotiateModernTLS]):
(-[TLSNavigationDelegate _webView:didNegotiateModernTLS:]):
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260657 => 260658)


--- trunk/Source/WebKit/ChangeLog	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/ChangeLog	2020-04-24 18:23:43 UTC (rev 260658)
@@ -1,3 +1,34 @@
+2020-04-24  Alex Christensen  <[email protected]>
+
+        SPI clients using fastServerTrustEvaluationEnabled need SPI to inform them of modern TLS negotiation
+        https://bugs.webkit.org/show_bug.cgi?id=210533
+
+        Reviewed by Brady Eidson.
+
+        * NetworkProcess/NetworkDataTask.h:
+        (WebKit::NetworkDataTaskClient::didNegotiateModernTLS):
+        * NetworkProcess/NetworkLoad.cpp:
+        (WebKit::NetworkLoad::didNegotiateModernTLS):
+        * NetworkProcess/NetworkLoad.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.h:
+        * NetworkProcess/cocoa/NetworkDataTaskCocoa.mm:
+        (WebKit::NetworkDataTaskCocoa::didNegotiateModernTLS):
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
+        * UIProcess/API/APINavigationClient.h:
+        (API::NavigationClient::didNegotiateModernTLS):
+        * UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h:
+        * UIProcess/Cocoa/NavigationState.h:
+        * UIProcess/Cocoa/NavigationState.mm:
+        (WebKit::NavigationState::setNavigationDelegate):
+        (WebKit::NavigationState::NavigationClient::didNegotiateModernTLS):
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didNegotiateModernTLS):
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.messages.in:
+        * UIProcess/WebPageProxy.cpp:
+        * UIProcess/WebPageProxy.h:
+
 2020-04-24  Brian Burg  <[email protected]>
 
         Web Automation: timeout underneath Automation.evaluateJavaScriptFunction in Selenium test frame_switching_tests.py::testShouldNotBeAbleToDoAnythingTheFrameIsDeletedFromUnderUs[Safari]

Modified: trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h (260657 => 260658)


--- trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/NetworkProcess/NetworkDataTask.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -72,6 +72,8 @@
 
     virtual bool shouldCaptureExtraNetworkLoadMetrics() const { return false; }
 
+    virtual void didNegotiateModernTLS(const WebCore::AuthenticationChallenge&) { }
+
     void didCompleteWithError(const WebCore::ResourceError& error)
     {
         WebCore::NetworkLoadMetrics emptyMetrics;

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp (260657 => 260658)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.cpp	2020-04-24 18:23:43 UTC (rev 260658)
@@ -30,6 +30,7 @@
 #include "AuthenticationManager.h"
 #include "NetworkDataTaskBlob.h"
 #include "NetworkProcess.h"
+#include "NetworkProcessProxyMessages.h"
 #include "NetworkSession.h"
 #include "WebErrors.h"
 #include <WebCore/ResourceRequest.h>
@@ -285,6 +286,12 @@
     m_client.get().didFailLoading(wasBlockedByRestrictionsError(m_currentRequest));
 }
 
+void NetworkLoad::didNegotiateModernTLS(const WebCore::AuthenticationChallenge& challenge)
+{
+    if (m_parameters.webPageProxyID)
+        m_networkProcess->send(Messages::NetworkProcessProxy::DidNegotiateModernTLS(m_parameters.webPageProxyID, challenge));
+}
+
 String NetworkLoad::description() const
 {
     if (m_task.get())

Modified: trunk/Source/WebKit/NetworkProcess/NetworkLoad.h (260657 => 260658)


--- trunk/Source/WebKit/NetworkProcess/NetworkLoad.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/NetworkProcess/NetworkLoad.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -81,6 +81,7 @@
     void wasBlocked() final;
     void cannotShowURL() final;
     void wasBlockedByRestrictions() final;
+    void didNegotiateModernTLS(const WebCore::AuthenticationChallenge&) final;
 
     void notifyDidReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&);
     void throttleDelayCompleted();

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h (260657 => 260658)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -53,6 +53,7 @@
 
     void didSendData(uint64_t totalBytesSent, uint64_t totalBytesExpectedToSend);
     void didReceiveChallenge(WebCore::AuthenticationChallenge&&, NegotiatedLegacyTLS, ChallengeCompletionHandler&&);
+    void didNegotiateModernTLS(const WebCore::AuthenticationChallenge&);
     void didCompleteWithError(const WebCore::ResourceError&, const WebCore::NetworkLoadMetrics&);
     void didReceiveResponse(WebCore::ResourceResponse&&, NegotiatedLegacyTLS, ResponseCompletionHandler&&);
     void didReceiveData(Ref<WebCore::SharedBuffer>&&);

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm (260657 => 260658)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkDataTaskCocoa.mm	2020-04-24 18:23:43 UTC (rev 260658)
@@ -318,6 +318,12 @@
     }
 }
 
+void NetworkDataTaskCocoa::didNegotiateModernTLS(const WebCore::AuthenticationChallenge& challenge)
+{
+    if (m_client)
+        m_client->didNegotiateModernTLS(challenge);
+}
+
 void NetworkDataTaskCocoa::didCompleteWithError(const WebCore::ResourceError& error, const WebCore::NetworkLoadMetrics& networkLoadMetrics)
 {
     if (error.isNull())

Modified: trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm (260657 => 260658)


--- trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm	2020-04-24 18:23:43 UTC (rev 260658)
@@ -674,8 +674,10 @@
 
         // Handle server trust evaluation at platform-level if requested, for performance reasons and to use ATS defaults.
         if (sessionCocoa->fastServerTrustEvaluationEnabled() && negotiatedLegacyTLS == NegotiatedLegacyTLS::No) {
+            auto* networkDataTask = [self existingTask:task];
+            if (networkDataTask)
+                networkDataTask->didNegotiateModernTLS(challenge);
 #if HAVE(CFNETWORK_NSURLSESSION_STRICTRUSTEVALUATE)
-            auto* networkDataTask = [self existingTask:task];
             auto decisionHandler = makeBlockPtr([weakSelf = WeakObjCPtr<WKNetworkSessionDelegate>(self), sessionCocoa = makeWeakPtr(sessionCocoa), completionHandler = makeBlockPtr(completionHandler), taskIdentifier, networkDataTask = makeRefPtr(networkDataTask), negotiatedLegacyTLS](NSURLAuthenticationChallenge *challenge, OSStatus trustResult) mutable {
                 auto strongSelf = weakSelf.get();
                 if (!strongSelf)

Modified: trunk/Source/WebKit/UIProcess/API/APINavigationClient.h (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/API/APINavigationClient.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/API/APINavigationClient.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -102,6 +102,7 @@
 
     virtual void didReceiveAuthenticationChallenge(WebKit::WebPageProxy&, WebKit::AuthenticationChallengeProxy& challenge) { challenge.listener().completeChallenge(WebKit::AuthenticationChallengeDisposition::PerformDefaultHandling); }
     virtual void shouldAllowLegacyTLS(WebKit::WebPageProxy&, WebKit::AuthenticationChallengeProxy&, CompletionHandler<void(bool)>&& completionHandler) { completionHandler(true); }
+    virtual void didNegotiateModernTLS(const WebCore::AuthenticationChallenge&) { }
     virtual bool shouldBypassContentModeSafeguards() const { return false; }
 
     // FIXME: These function should not be part of this client.

Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKNavigationDelegatePrivate.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -86,6 +86,7 @@
 - (NSData *)_webCryptoMasterKeyForWebView:(WKWebView *)webView;
 
 - (void)_webView:(WKWebView *)webView authenticationChallenge:(NSURLAuthenticationChallenge *)challenge shouldAllowLegacyTLS:(void (^)(BOOL))completionHandler WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_webView:(WKWebView *)webView didNegotiateModernTLS:(NSURLAuthenticationChallenge *)challenge WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 - (void)_webViewDidBeginNavigationGesture:(WKWebView *)webView;
 // Item is nil if the gesture ended without navigation.

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -117,6 +117,7 @@
 
         void didReceiveAuthenticationChallenge(WebPageProxy&, AuthenticationChallengeProxy&) override;
         void shouldAllowLegacyTLS(WebPageProxy&, AuthenticationChallengeProxy&, CompletionHandler<void(bool)>&&) final;
+        void didNegotiateModernTLS(const WebCore::AuthenticationChallenge&) final;
         bool processDidTerminate(WebPageProxy&, ProcessTerminationReason) override;
         void processDidBecomeResponsive(WebPageProxy&) override;
         void processDidBecomeUnresponsive(WebPageProxy&) override;
@@ -229,6 +230,7 @@
         bool webViewRenderingProgressDidChange : 1;
         bool webViewDidReceiveAuthenticationChallengeCompletionHandler : 1;
         bool webViewAuthenticationChallengeShouldAllowLegacyTLS : 1;
+        bool webViewDidNegotiateModernTLS : 1;
         bool webViewWebContentProcessDidTerminate : 1;
         bool webViewWebContentProcessDidTerminateWithReason : 1;
         bool webViewWebProcessDidCrash : 1;

Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm	2020-04-24 18:23:43 UTC (rev 260658)
@@ -70,6 +70,7 @@
 #import "_WKRenderingProgressEventsInternal.h"
 #import "_WKSameDocumentNavigationTypeInternal.h"
 #import "_WKWebsitePoliciesInternal.h"
+#import <WebCore/AuthenticationMac.h>
 #import <WebCore/ContentRuleListResults.h>
 #import <WebCore/Credential.h>
 #import <WebCore/SSLKeyGenerator.h>
@@ -178,6 +179,7 @@
     m_navigationDelegateMethods.webViewRenderingProgressDidChange = [delegate respondsToSelector:@selector(_webView:renderingProgressDidChange:)];
     m_navigationDelegateMethods.webViewDidReceiveAuthenticationChallengeCompletionHandler = [delegate respondsToSelector:@selector(webView:didReceiveAuthenticationChallenge:completionHandler:)];
     m_navigationDelegateMethods.webViewAuthenticationChallengeShouldAllowLegacyTLS = [delegate respondsToSelector:@selector(_webView:authenticationChallenge:shouldAllowLegacyTLS:)];
+    m_navigationDelegateMethods.webViewDidNegotiateModernTLS = [delegate respondsToSelector:@selector(_webView:didNegotiateModernTLS:)];
     m_navigationDelegateMethods.webViewWebContentProcessDidTerminate = [delegate respondsToSelector:@selector(webViewWebContentProcessDidTerminate:)];
     m_navigationDelegateMethods.webViewWebContentProcessDidTerminateWithReason = [delegate respondsToSelector:@selector(_webView:webContentProcessDidTerminateWithReason:)];
     m_navigationDelegateMethods.webViewWebProcessDidCrash = [delegate respondsToSelector:@selector(_webViewWebProcessDidCrash:)];
@@ -1046,6 +1048,18 @@
     }).get()];
 }
 
+void NavigationState::NavigationClient::didNegotiateModernTLS(const WebCore::AuthenticationChallenge& challenge)
+{
+    if (!m_navigationState.m_navigationDelegateMethods.webViewDidNegotiateModernTLS)
+        return;
+
+    auto navigationDelegate = m_navigationState.m_navigationDelegate.get();
+    if (!navigationDelegate)
+        return;
+
+    [static_cast<id <WKNavigationDelegatePrivate>>(navigationDelegate.get()) _webView:m_navigationState.m_webView didNegotiateModernTLS:mac(challenge)];
+}
+
 static _WKProcessTerminationReason wkProcessTerminationReason(ProcessTerminationReason reason)
 {
     switch (reason) {

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2020-04-24 18:23:43 UTC (rev 260658)
@@ -344,6 +344,12 @@
         page->negotiatedLegacyTLS();
 }
 
+void NetworkProcessProxy::didNegotiateModernTLS(WebPageProxyIdentifier pageID, const WebCore::AuthenticationChallenge& challenge)
+{
+    if (auto* page = pageID ? WebProcessProxy::webPage(pageID) : nullptr)
+        page->didNegotiateModernTLS(challenge);
+}
+
 void NetworkProcessProxy::didFetchWebsiteData(CallbackID callbackID, const WebsiteData& websiteData)
 {
     MESSAGE_CHECK(m_pendingFetchWebsiteDataCallbacks.isValidKey(callbackID));

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -251,6 +251,7 @@
     void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
     void didReceiveAuthenticationChallenge(PAL::SessionID, WebPageProxyIdentifier, const Optional<WebCore::SecurityOriginData>&, WebCore::AuthenticationChallenge&&, bool, uint64_t challengeID);
     void negotiatedLegacyTLS(WebPageProxyIdentifier);
+    void didNegotiateModernTLS(WebPageProxyIdentifier, const WebCore::AuthenticationChallenge&);
     void didFetchWebsiteData(CallbackID, const WebsiteData&);
     void didDeleteWebsiteData(CallbackID);
     void didDeleteWebsiteDataForOrigins(CallbackID);

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.messages.in	2020-04-24 18:23:43 UTC (rev 260658)
@@ -23,6 +23,7 @@
 messages -> NetworkProcessProxy LegacyReceiver NotRefCounted {
     DidReceiveAuthenticationChallenge(PAL::SessionID sessionID, WebKit::WebPageProxyIdentifier pageID, Optional<WebCore::SecurityOriginData> topOrigin, WebCore::AuthenticationChallenge challenge, bool negotiatedLegacyTLS, uint64_t challengeID)
     NegotiatedLegacyTLS(WebKit::WebPageProxyIdentifier pageID)
+    DidNegotiateModernTLS(WebKit::WebPageProxyIdentifier pageID, WebCore::AuthenticationChallenge challenge)
 
     DidFetchWebsiteData(WebKit::CallbackID callbackID, struct WebKit::WebsiteData websiteData)
     DidDeleteWebsiteData(WebKit::CallbackID callbackID)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2020-04-24 18:23:43 UTC (rev 260658)
@@ -7935,6 +7935,11 @@
     m_pageLoadState.negotiatedLegacyTLS(transaction);
 }
 
+void WebPageProxy::didNegotiateModernTLS(const WebCore::AuthenticationChallenge& challenge)
+{
+    m_navigationClient->didNegotiateModernTLS(challenge);
+}
+
 void 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)
 {
     requestStorageSpace(frameID, originIdentifier, databaseName, displayName, currentQuota, currentOriginUsage, currentDatabaseUsage, expectedUsage, [reply = WTFMove(reply)](auto quota) mutable {

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (260657 => 260658)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2020-04-24 18:23:43 UTC (rev 260658)
@@ -1368,6 +1368,7 @@
 
     void didReceiveAuthenticationChallengeProxy(Ref<AuthenticationChallengeProxy>&&, NegotiatedLegacyTLS);
     void negotiatedLegacyTLS();
+    void didNegotiateModernTLS(const WebCore::AuthenticationChallenge&);
 
     SpellDocumentTag spellDocumentTag();
 

Modified: trunk/Tools/ChangeLog (260657 => 260658)


--- trunk/Tools/ChangeLog	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Tools/ChangeLog	2020-04-24 18:23:43 UTC (rev 260658)
@@ -1,3 +1,15 @@
+2020-04-24  Alex Christensen  <[email protected]>
+
+        SPI clients using fastServerTrustEvaluationEnabled need SPI to inform them of modern TLS negotiation
+        https://bugs.webkit.org/show_bug.cgi?id=210533
+
+        Reviewed by Brady Eidson.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
+        (-[TLSNavigationDelegate waitForDidNegotiateModernTLS]):
+        (-[TLSNavigationDelegate _webView:didNegotiateModernTLS:]):
+        (TestWebKitAPI::TEST):
+
 2020-04-24  Brian Burg  <[email protected]>
 
         webkitpy: update autoinstalled mozprocess dependency to 1.1.0 (adds python3 support)

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm (260657 => 260658)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm	2020-04-24 18:08:12 UTC (rev 260657)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm	2020-04-24 18:23:43 UTC (rev 260658)
@@ -73,6 +73,7 @@
 @interface TLSNavigationDelegate : NSObject <WKNavigationDelegate>
 - (void)waitForDidFinishNavigation;
 - (void)waitForDidFailProvisionalNavigation;
+- (NSURLAuthenticationChallenge *)waitForDidNegotiateModernTLS;
 - (bool)receivedShouldAllowLegacyTLS;
 @property (nonatomic) bool shouldAllowLegacyTLS;
 @end
@@ -81,6 +82,7 @@
     bool _navigationFinished;
     bool _navigationFailed;
     bool _receivedShouldAllowLegacyTLS;
+    RetainPtr<NSURLAuthenticationChallenge> _negotiatedModernTLS;
 }
 
 - (void)waitForDidFinishNavigation
@@ -95,6 +97,13 @@
         TestWebKitAPI::Util::spinRunLoop();
 }
 
+- (NSURLAuthenticationChallenge *)waitForDidNegotiateModernTLS
+{
+    while (!_negotiatedModernTLS)
+        TestWebKitAPI::Util::spinRunLoop();
+    return _negotiatedModernTLS.autorelease();
+}
+
 - (bool)receivedShouldAllowLegacyTLS
 {
     return _receivedShouldAllowLegacyTLS;
@@ -122,6 +131,11 @@
     completionHandler([self shouldAllowLegacyTLS]);
 }
 
+- (void)_webView:(WKWebView *)webView didNegotiateModernTLS:(NSURLAuthenticationChallenge *)challenge
+{
+    _negotiatedModernTLS = challenge;
+}
+
 @end
 
 
@@ -369,6 +383,25 @@
     [webView removeObserver:observer.get() forKeyPath:@"_negotiatedLegacyTLS"];
 }
 
+TEST(TLSVersion, DidNegotiateModernTLS)
+{
+    HTTPServer server({
+        { "/", { "hello" }}
+    }, HTTPServer::Protocol::Https);
+
+    auto delegate = adoptNS([TLSNavigationDelegate new]);
+    auto configuration = adoptNS([WKWebViewConfiguration new]);
+    auto dataStoreConfiguration = adoptNS([_WKWebsiteDataStoreConfiguration new]);
+    [dataStoreConfiguration setFastServerTrustEvaluationEnabled:YES];
+    [configuration setWebsiteDataStore:[[[WKWebsiteDataStore alloc] _initWithConfiguration:dataStoreConfiguration.get()] autorelease]];
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
+    [webView setNavigationDelegate:delegate.get()];
+    [webView loadRequest:server.request()];
+    NSURLAuthenticationChallenge *challenge = [delegate waitForDidNegotiateModernTLS];
+    EXPECT_WK_STREQ(challenge.protectionSpace.host, "127.0.0.1");
+    EXPECT_EQ(challenge.protectionSpace.port, server.port());
+}
+
 TEST(TLSVersion, BackForwardHasOnlySecureContent)
 {
     HTTPServer secureServer({
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to