Title: [224395] trunk/Source/WebCore
Revision
224395
Author
fred.w...@free.fr
Date
2017-11-03 08:01:44 -0700 (Fri, 03 Nov 2017)

Log Message

Add USE(APPLE_INTERNAL_SDK)-guards around SPI in ResourceHandle code
https://bugs.webkit.org/show_bug.cgi?id=136107

Based on patch by Daniel Bates <daba...@apple.com>
Patch by Frederic Wang <fw...@igalia.com> on 2017-11-03
Reviewed by Darin Adler.

No new tests, behavior unchanged.

* platform/network/ResourceHandleClient.h: Replace includes of private headers with CFNetworkSPI.h.
* platform/network/ResourceHandleInternal.h: Ditto.
* platform/network/ios/ResourceHandleIOS.mm: Add USE(APPLE_INTERNAL_SDK)-guard around SPI
headers and forward declare NSURLRequest SPI and constant _kCFStreamSSLTrustedLeafCertificates
for clients that build without the internal SDK. Add BSD license block to file.
(WebCore::ResourceHandle::createSSLPropertiesFromNSURLRequest): Fix code style issues; use
nullptr instead of 0, use reinterpret_cast instead of C-style cast, remove unnecessary
"using namespace WebCore"
and rename variables to improve readability.
* platform/network/mac/ResourceErrorMac.mm: Add USE(APPLE_INTERNAL_SDK)-guard around private
headers and add typedef for CFCachedURLResponseRef for clients that build without the
internal SDK.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (224394 => 224395)


--- trunk/Source/WebCore/ChangeLog	2017-11-03 14:46:17 UTC (rev 224394)
+++ trunk/Source/WebCore/ChangeLog	2017-11-03 15:01:44 UTC (rev 224395)
@@ -1,3 +1,26 @@
+2017-11-03  Frederic Wang  <fw...@igalia.com>
+
+        Add USE(APPLE_INTERNAL_SDK)-guards around SPI in ResourceHandle code
+        https://bugs.webkit.org/show_bug.cgi?id=136107
+
+        Based on patch by Daniel Bates <daba...@apple.com>
+        Reviewed by Darin Adler.
+
+        No new tests, behavior unchanged.
+
+        * platform/network/ResourceHandleClient.h: Replace includes of private headers with CFNetworkSPI.h.
+        * platform/network/ResourceHandleInternal.h: Ditto.
+        * platform/network/ios/ResourceHandleIOS.mm: Add USE(APPLE_INTERNAL_SDK)-guard around SPI
+        headers and forward declare NSURLRequest SPI and constant _kCFStreamSSLTrustedLeafCertificates
+        for clients that build without the internal SDK. Add BSD license block to file.
+        (WebCore::ResourceHandle::createSSLPropertiesFromNSURLRequest): Fix code style issues; use
+        nullptr instead of 0, use reinterpret_cast instead of C-style cast, remove unnecessary
+        "using namespace WebCore"
+        and rename variables to improve readability.
+        * platform/network/mac/ResourceErrorMac.mm: Add USE(APPLE_INTERNAL_SDK)-guard around private
+        headers and add typedef for CFCachedURLResponseRef for clients that build without the
+        internal SDK.
+
 2017-11-03  Antti Koivisto  <an...@apple.com>
 
         Crash in WebCore::RenderStyle::overflowX with display:contents

Modified: trunk/Source/WebCore/platform/network/ResourceHandleClient.h (224394 => 224395)


--- trunk/Source/WebCore/platform/network/ResourceHandleClient.h	2017-11-03 14:46:17 UTC (rev 224394)
+++ trunk/Source/WebCore/platform/network/ResourceHandleClient.h	2017-11-03 15:01:44 UTC (rev 224395)
@@ -30,8 +30,7 @@
 #include <wtf/Ref.h>
 
 #if USE(CFURLCONNECTION)
-#include <CFNetwork/CFURLCachePriv.h>
-#include <CFNetwork/CFURLResponsePriv.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 #if PLATFORM(IOS) || USE(CFURLCONNECTION)

Modified: trunk/Source/WebCore/platform/network/ResourceHandleInternal.h (224394 => 224395)


--- trunk/Source/WebCore/platform/network/ResourceHandleInternal.h	2017-11-03 14:46:17 UTC (rev 224394)
+++ trunk/Source/WebCore/platform/network/ResourceHandleInternal.h	2017-11-03 15:01:44 UTC (rev 224395)
@@ -34,7 +34,7 @@
 
 #if USE(CFURLCONNECTION)
 #include "ResourceHandleCFURLConnectionDelegate.h"
-#include <CFNetwork/CFURLConnectionPriv.h>
+#include <pal/spi/cf/CFNetworkSPI.h>
 #endif
 
 #if USE(CURL) && PLATFORM(WIN)

Modified: trunk/Source/WebCore/platform/network/ios/ResourceHandleIOS.mm (224394 => 224395)


--- trunk/Source/WebCore/platform/network/ios/ResourceHandleIOS.mm	2017-11-03 14:46:17 UTC (rev 224394)
+++ trunk/Source/WebCore/platform/network/ios/ResourceHandleIOS.mm	2017-11-03 15:01:44 UTC (rev 224395)
@@ -1,9 +1,27 @@
-//
-//  ResourceHandleIPhone.mm
-//  WebCore
-//
-//  Copyright 2011 Apple Inc. All rights reserved.
-//
+/*
+ * Copyright (C) 2011-2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
 
 #import "config.h"
 #import "ResourceHandleInternal.h"
@@ -10,10 +28,18 @@
 
 #if USE(CFURLCONNECTION)
 
+#if USE(APPLE_INTERNAL_SDK)
 #import <CFNetwork/CFSocketStreamPriv.h>
 #import <Foundation/NSURLRequestPrivate.h>
+#else
+#import <Foundation/NSURLRequest.h>
+@interface NSURLRequest (Details)
++ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host;
++ (NSArray*)allowsSpecificHTTPSCertificateForHost:(NSString *)host;
+@end
+#endif
 
-using namespace WebCore;
+extern "C" const CFStringRef _kCFStreamSSLTrustedLeafCertificates;
 
 namespace WebCore {
 
@@ -20,18 +46,18 @@
 CFMutableDictionaryRef ResourceHandle::createSSLPropertiesFromNSURLRequest(const ResourceRequest& request)
 {
     NSString *host = request.url().host();
-    NSArray *certArray = [NSURLRequest allowsSpecificHTTPSCertificateForHost:host];
+    NSArray *certificateChain = [NSURLRequest allowsSpecificHTTPSCertificateForHost:host];
     BOOL allowsAnyCertificate = [NSURLRequest allowsAnyHTTPSCertificateForHost:host];
-    if (!certArray && !allowsAnyCertificate)
-        return 0;
+    if (!certificateChain && !allowsAnyCertificate)
+        return nullptr;
 
-    CFMutableDictionaryRef sslProps = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
-    if (certArray)
-        CFDictionarySetValue(sslProps, _kCFStreamSSLTrustedLeafCertificates, (CFTypeRef) certArray);
+    CFMutableDictionaryRef sslProperties = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    if (certificateChain)
+        CFDictionarySetValue(sslProperties, _kCFStreamSSLTrustedLeafCertificates, reinterpret_cast<CFTypeRef>(certificateChain));
 
     if (allowsAnyCertificate)
-        CFDictionarySetValue(sslProps, kCFStreamSSLValidatesCertificateChain, kCFBooleanFalse);
-    return sslProps;
+        CFDictionarySetValue(sslProperties, kCFStreamSSLValidatesCertificateChain, kCFBooleanFalse);
+    return sslProperties;
 }
 
 }

Modified: trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm (224394 => 224395)


--- trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm	2017-11-03 14:46:17 UTC (rev 224394)
+++ trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm	2017-11-03 15:01:44 UTC (rev 224395)
@@ -31,10 +31,17 @@
 #import <Foundation/Foundation.h>
 #import <wtf/BlockObjCExceptions.h>
 
-#if PLATFORM(IOS) && USE(CFURLCONNECTION)
+#if PLATFORM(IOS) && USE(CFURLCONNECTION) && USE(APPLE_INTERNAL_SDK)
 #import <CFNetwork/CFSocketStreamPriv.h>
 #endif
 
+#if USE(CFURLCONNECTION)
+extern "C" {
+const CFStringRef _kCFStreamPropertySSLClientCertificates;
+const CFStringRef _kCFStreamPropertySSLClientCertificateState;
+}
+#endif
+
 @interface NSError (WebExtras)
 - (NSString *)_web_localizedDescription;
 @end
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to