Changeset 269094 in webkit


Ignore:
Timestamp:
Oct 27, 2020 8:03:28 PM (4 years ago)
Author:
achristensen@apple.com
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):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r269084 r269094  
     12020-10-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs
     4        https://bugs.webkit.org/show_bug.cgi?id=218269
     5        <rdar://problem/70491533>
     6
     7        Reviewed by Darin Adler.
     8
     9        r171066 introduced the use of _CFURLConnectionSetFrameworkStubs on iOS for CFNetwork to be able
     10        to get and set credentials as the UI process.  This is also needed on Apple Silicon Macs.
     11        We should eventually replace it with an even cleaner per-NSURLSession solution, but this is a step
     12        in the right direction, and I verified manually that it fixes the radar.
     13
     14        Covered by an API test that used to fail on Apple Silicon Macs.
     15
     16        * Shared/mac/SecItemShim.cpp:
     17        (WebKit::initializeSecItemShim):
     18
    1192020-10-27  Said Abou-Hallawa  <said@apple.com>
    220
  • trunk/Source/WebKit/Shared/mac/SecItemShim.cpp

    r248014 r269094  
    144144    globalNetworkProcess() = makeWeakPtr(process);
    145145
    146 #if PLATFORM(IOS_FAMILY)
     146#if PLATFORM(IOS_FAMILY) || (PLATFORM(MAC) && !CPU(X86_64))
    147147    struct _CFNFrameworksStubs stubs = {
    148148        .version = 0,
     
    156156#endif
    157157
    158 #if PLATFORM(MAC)
     158#if PLATFORM(MAC) && CPU(X86_64)
    159159    const SecItemShimCallbacks callbacks = {
    160160        webSecItemCopyMatching,
  • trunk/Tools/ChangeLog

    r269080 r269094  
     12020-10-27  Alex Christensen  <achristensen@webkit.org>
     2
     3        Use _CFURLConnectionSetFrameworkStubs for SecItemShim instead of DYLD_INTERPOSE on Apple Silicon Macs
     4        https://bugs.webkit.org/show_bug.cgi?id=218269
     5        <rdar://problem/70491533>
     6
     7        Reviewed by Darin Adler.
     8
     9        * TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm:
     10        (TEST):
     11
    1122020-10-27  Sam Weinig  <weinig@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/Challenge.mm

    r268796 r269094  
    365365    // Clear persistent credentials created by this test.
    366366    [[webView configuration].processPool _clearPermanentCredentialsForProtectionSpace:protectionSpace];
     367}
     368
     369TEST(Challenge, BasicPersistentCredential)
     370{
     371    using namespace TestWebKitAPI;
     372    HTTPServer server(HTTPServer::respondWithChallengeThenOK);
     373    auto delegate = [[TestNavigationDelegate new] autorelease];
     374    __block RetainPtr<NSURLProtectionSpace> protectionSpace;
     375    auto credentialStorage = [NSURLCredentialStorage sharedCredentialStorage];
     376    delegate.didReceiveAuthenticationChallenge = ^(WKWebView *, NSURLAuthenticationChallenge *challenge, void (^completionHandler)(NSURLSessionAuthChallengeDisposition, NSURLCredential *)) {
     377        protectionSpace = challenge.protectionSpace;
     378        NSURLCredential *existingCredential = [credentialStorage defaultCredentialForProtectionSpace:protectionSpace.get()];
     379        EXPECT_NULL(existingCredential);
     380        EXPECT_WK_STREQ(protectionSpace.get().authenticationMethod, NSURLAuthenticationMethodHTTPBasic);
     381        completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialWithUser:@"testuser" password:@"testpassword" persistence:NSURLCredentialPersistencePermanent]);
     382    };
     383    auto webView = [[WKWebView new] autorelease];
     384    webView.navigationDelegate = delegate;
     385    [webView loadRequest:server.request()];
     386    [delegate waitForDidFinishNavigation];
     387
     388    NSURLCredential *storedCredential = nil;
     389    while (!storedCredential) {
     390        storedCredential = [[NSURLCredentialStorage sharedCredentialStorage] defaultCredentialForProtectionSpace:protectionSpace.get()];
     391        Util::spinRunLoop();
     392    }
     393    EXPECT_NOT_NULL(storedCredential);
     394    EXPECT_WK_STREQ(storedCredential.user, "testuser");
     395    EXPECT_WK_STREQ(storedCredential.password, "testpassword");
     396    EXPECT_EQ(storedCredential.persistence, NSURLCredentialPersistencePermanent);
     397
     398    [credentialStorage removeCredential:storedCredential forProtectionSpace:protectionSpace.get()];
     399    NSURLCredential *removedCredential = [credentialStorage defaultCredentialForProtectionSpace:protectionSpace.get()];
     400    EXPECT_NULL(removedCredential);
    367401}
    368402
Note: See TracChangeset for help on using the changeset viewer.