Title: [269094] trunk
Revision
269094
Author
[email protected]
Date
2020-10-27 20:03:28 -0700 (Tue, 27 Oct 2020)

Log Message

Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs
https://bugs.webkit.org/show_bug.cgi?id=218269
<rdar://problem/70491533>

Reviewed by Darin Adler.

Source/WebKit:

r171066 introduced the use of _CFURLConnectionSetFrameworkStubs on iOS for CFNetwork to be able
to get and set credentials as the UI process.  This is also needed on Apple Silicon Macs.
We should eventually replace it with an even cleaner per-NSURLSession solution, but this is a step
in the right direction, and I verified manually that it fixes the radar.

Covered by an API test that used to fail on Apple Silicon Macs.

* Shared/mac/SecItemShim.cpp:
(WebKit::initializeSecItemShim):

Tools:

* TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (269093 => 269094)


--- trunk/Source/WebKit/ChangeLog	2020-10-28 02:25:56 UTC (rev 269093)
+++ trunk/Source/WebKit/ChangeLog	2020-10-28 03:03:28 UTC (rev 269094)
@@ -1,3 +1,21 @@
+2020-10-27  Alex Christensen  <[email protected]>
+
+        Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs
+        https://bugs.webkit.org/show_bug.cgi?id=218269
+        <rdar://problem/70491533>
+
+        Reviewed by Darin Adler.
+
+        r171066 introduced the use of _CFURLConnectionSetFrameworkStubs on iOS for CFNetwork to be able
+        to get and set credentials as the UI process.  This is also needed on Apple Silicon Macs.
+        We should eventually replace it with an even cleaner per-NSURLSession solution, but this is a step
+        in the right direction, and I verified manually that it fixes the radar.
+
+        Covered by an API test that used to fail on Apple Silicon Macs.
+
+        * Shared/mac/SecItemShim.cpp:
+        (WebKit::initializeSecItemShim):
+
 2020-10-27  Said Abou-Hallawa  <[email protected]>
 
         Make RenderingMode a bool enum and remove ShouldAccelerate

Modified: trunk/Source/WebKit/Shared/mac/SecItemShim.cpp (269093 => 269094)


--- trunk/Source/WebKit/Shared/mac/SecItemShim.cpp	2020-10-28 02:25:56 UTC (rev 269093)
+++ trunk/Source/WebKit/Shared/mac/SecItemShim.cpp	2020-10-28 03:03:28 UTC (rev 269094)
@@ -143,7 +143,7 @@
 {
     globalNetworkProcess() = makeWeakPtr(process);
 
-#if PLATFORM(IOS_FAMILY)
+#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && !CPU(X86_64))
     struct _CFNFrameworksStubs stubs = {
         .version = 0,
         .SecItem_stub_CopyMatching = webSecItemCopyMatching,
@@ -155,7 +155,7 @@
     _CFURLConnectionSetFrameworkStubs(&stubs);
 #endif
 
-#if PLATFORM(MAC)
+#if PLATFORM(MAC) && CPU(X86_64)
     const SecItemShimCallbacks callbacks = {
         webSecItemCopyMatching,
         webSecItemAdd,

Modified: trunk/Tools/ChangeLog (269093 => 269094)


--- trunk/Tools/ChangeLog	2020-10-28 02:25:56 UTC (rev 269093)
+++ trunk/Tools/ChangeLog	2020-10-28 03:03:28 UTC (rev 269094)
@@ -1,3 +1,14 @@
+2020-10-27  Alex Christensen  <[email protected]>
+
+        Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs
+        https://bugs.webkit.org/show_bug.cgi?id=218269
+        <rdar://problem/70491533>
+
+        Reviewed by Darin Adler.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
+        (TEST):
+
 2020-10-27  Sam Weinig  <[email protected]>
 
         DumpRenderTree spams stderr with CFNetwork warnings about null diskcache path

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm (269093 => 269094)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm	2020-10-28 02:25:56 UTC (rev 269093)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm	2020-10-28 03:03:28 UTC (rev 269094)
@@ -366,6 +366,40 @@
     [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace];
 }
 
+TEST(Challenge, BasicPersistentCredential)
+{
+    using namespace TestWebKitAPI;
+    HTTPServer server(HTTPServer::respondWithChallengeThenOK);
+    auto delegate = [[TestNavigationDelegate new] autorelease];
+    __block RetainPtr<NSURLProtectionSpace> protectionSpace;
+    auto credentialStorage = [NSURLCredentialStorage sharedCredentialStorage];
+    delegate.didReceiveAuthenticationChallenge = ^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
+        protectionSpace = challenge.protectionSpace;
+        NSURLCredential *existingCredential = [credentialStorage defaultCredentialForProtectionSpace:protectionSpace.get()];
+        EXPECT_NULL(existingCredential);
+        EXPECT_WK_STREQ(protectionSpace.get().authenticationMethod, NSURLAuthenticationMethodHTTPBasic);
+        completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialWithUser:@"testuser" password:@"testpassword" persistence:NSURLCredentialPersistencePermanent]);
+    };
+    auto webView = [[WKWebView new] autorelease];
+    webView.navigationDelegate = delegate;
+    [webView loadRequest:server.request()];
+    [delegate waitForDidFinishNavigation];
+
+    NSURLCredential *storedCredential = nil;
+    while (!storedCredential) {
+        storedCredential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace.get()];
+        Util::spinRunLoop();
+    }
+    EXPECT_NOT_NULL(storedCredential);
+    EXPECT_WK_STREQ(storedCredential.user, "testuser");
+    EXPECT_WK_STREQ(storedCredential.password, "testpassword");
+    EXPECT_EQ(storedCredential.persistence, NSURLCredentialPersistencePermanent);
+
+    [credentialStorage removeCredential:storedCredential forProtectionSpace:protectionSpace.get()];
+    NSURLCredential *removedCredential = [credentialStorage defaultCredentialForProtectionSpace:protectionSpace.get()];
+    EXPECT_NULL(removedCredential);
+}
+
 #if HAVE(SSL)
 static void verifyCertificateAndPublicKey(SecTrustRef trust)
 {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to