<rdar://problem/12890242> [WK2 NetworkProcess] Client doesn't receive SSL...
authorap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 00:58:25 +0000 (00:58 +0000)
committerap@apple.com <ap@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Dec 2012 00:58:25 +0000 (00:58 +0000)
        https://bugs.webkit.org/show_bug.cgi?id=105467

        Reviewed by Brady Eidson.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@138206 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.exp.in
Source/WebCore/platform/mac/WebCoreSystemInterface.h
Source/WebCore/platform/mac/WebCoreSystemInterface.mm
Source/WebCore/platform/network/cf/ResourceResponse.h
Source/WebCore/platform/network/mac/ResourceResponseMac.mm
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/Shared/mac/PlatformCertificateInfo.mm
Source/WebKit2/WebProcess/Network/WebResourceLoader.cpp
Source/WebKit2/WebProcess/Network/WebResourceLoader.h
Source/WebKit2/WebProcess/Network/WebResourceLoader.messages.in
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm

index 00bb50f..ea52fad 100644 (file)
@@ -1,3 +1,21 @@
+2012-12-19  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/12890242> [WK2 NetworkProcess] Client doesn't receive SSL certificates
+        https://bugs.webkit.org/show_bug.cgi?id=105467
+
+        Reviewed by Brady Eidson.
+
+        Implement a way to store certificate chain in ResourceResponse separately from
+        NSURLResponse. There is no way to re-add it to a deserialized NSURLResponse.
+
+        * WebCore.exp.in:
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+        * platform/network/cf/ResourceResponse.h:
+        * platform/network/mac/ResourceResponseMac.mm:
+        (WebCore::ResourceResponse::setCertificateChain):
+        (WebCore::ResourceResponse::certificateChain):
+
 2012-12-19  Gustavo Noronha Silva  <gns@gnome.org>
 
         Unreviewed. Add new strings to GTK+'s implementation of
index 2b18bab..7927150 100644 (file)
@@ -468,6 +468,7 @@ __ZN7WebCore16NavigationActionC1ERKNS_15ResourceRequestE
 __ZN7WebCore16NavigationActionC1ERKNS_15ResourceRequestENS_13FrameLoadTypeEb
 __ZN7WebCore16NavigationActionC1ERKNS_15ResourceRequestENS_14NavigationTypeE
 __ZN7WebCore16NavigationActionC1Ev
+__ZN7WebCore16ResourceResponse19setCertificateChainEPK9__CFArray
 __ZN7WebCore16ScriptController10initScriptEPNS_15DOMWrapperWorldE
 __ZN7WebCore16ScriptController11createWorldEv
 __ZN7WebCore16ScriptController13executeScriptERKN3WTF6StringEb
@@ -1289,6 +1290,7 @@ __ZNK7WebCore16HTMLInputElement15isPasswordFieldEv
 __ZNK7WebCore16HTMLInputElement18shouldAutocompleteEv
 __ZNK7WebCore16IconDatabaseBase12databasePathEv
 __ZNK7WebCore16ResourceResponse13nsURLResponseEv
+__ZNK7WebCore16ResourceResponse16certificateChainEv
 __ZNK7WebCore16VisibleSelection17isContentEditableEv
 __ZNK7WebCore16VisibleSelection17toNormalizedRangeEv
 __ZNK7WebCore16VisibleSelection19rootEditableElementEv
@@ -1517,6 +1519,7 @@ _wkCopyCFURLResponseSuggestedFilename
 _wkCopyCONNECTProxyResponse
 _wkCopyHTTPCookieStorage
 _wkCopyNSURLResponseStatusLine
+_wkCopyNSURLResponseCertificateChain
 _wkCopyRequestWithStorageSession
 _wkCreateCTLineWithUniCharProvider
 _wkCreateCustomCFReadStream
index aa6a7ff..277c268 100644 (file)
@@ -135,6 +135,7 @@ extern CFReadStreamRef (*wkCreateCustomCFReadStream)(void *(*formCreate)(CFReadS
     void *context);
 extern CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
 extern NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
+extern CFArrayRef (*wkCopyNSURLResponseCertificateChain)(NSURLResponse*);
 extern id (*wkCreateNSURLConnectionDelegateProxy)(void);
 extern void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
 extern void (*wkDrawTextFieldCellFocusRing)(NSTextFieldCell*, NSRect);
index d2b4036..b54628c 100644 (file)
@@ -39,6 +39,7 @@ bool (*wkCGContextDrawsWithCorrectShadowOffsets)(CGContextRef);
 CGPatternRef (*wkCGPatternCreateWithImageAndTransform)(CGImageRef, CGAffineTransform, int);
 CFStringRef (*wkCopyCFLocalizationPreferredName)(CFStringRef);
 NSString* (*wkCopyNSURLResponseStatusLine)(NSURLResponse*);
+CFArrayRef (*wkCopyNSURLResponseCertificateChain)(NSURLResponse*);
 NSString* (*wkCreateURLPasteboardFlavorTypeName)(void);
 NSString* (*wkCreateURLNPasteboardFlavorTypeName)(void);
 void (*wkDrawBezeledTextFieldCell)(NSRect, BOOL enabled);
index d83a661..888add9 100644 (file)
@@ -88,6 +88,11 @@ public:
     NSURLResponse *nsURLResponse() const;
 #endif
 
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    void setCertificateChain(CFArrayRef);
+    RetainPtr<CFArrayRef> certificateChain() const;
+#endif
+
 private:
     friend class ResourceResponseBase;
 
@@ -106,6 +111,10 @@ private:
 #if PLATFORM(MAC)
     mutable RetainPtr<NSURLResponse> m_nsResponse;
 #endif
+#if PLATFORM(MAC) || USE(CFNETWORK)
+    // Certificate chain is normally part of NS/CFURLResponse, but there is no way to re-add it to a deserialized response after IPC.
+    RetainPtr<CFArrayRef> m_externalCertificateChain;
+#endif
     InitLevel m_initLevel;
 };
 
index d2f93be..2d3f62f 100644 (file)
@@ -171,6 +171,20 @@ bool ResourceResponse::platformCompare(const ResourceResponse& a, const Resource
     return a.nsURLResponse() == b.nsURLResponse();
 }
 
+void ResourceResponse::setCertificateChain(CFArrayRef certificateChain)
+{
+    ASSERT(!wkCopyNSURLResponseCertificateChain(nsURLResponse()));
+    m_externalCertificateChain = certificateChain;
+}
+
+RetainPtr<CFArrayRef> ResourceResponse::certificateChain() const
+{
+    if (m_externalCertificateChain)
+        return m_externalCertificateChain;
+
+    return adoptCF(wkCopyNSURLResponseCertificateChain(nsURLResponse()));
+}
+
 #endif // USE(CFNETWORK)
 
 } // namespace WebCore
index d39a4ce..3d49076 100644 (file)
@@ -1,3 +1,13 @@
+2012-12-19  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/12890242> [WK2 NetworkProcess] Client doesn't receive SSL certificates
+        https://bugs.webkit.org/show_bug.cgi?id=105467
+
+        Reviewed by Brady Eidson.
+
+        * WebCoreSupport/WebSystemInterface.mm: (InitWebCoreSystemInterface): Initialize
+        a WKSI function we've been missing.
+
 2012-12-19  Alexis Menard  <alexis@webkit.org>
 
         Implement CSS parsing for CSS transitions unprefixed.
index a0318e3..0dbd13b 100644 (file)
@@ -58,6 +58,7 @@ void InitWebCoreSystemInterface(void)
     INIT(CopyCFLocalizationPreferredName);
     INIT(CopyCONNECTProxyResponse);
     INIT(CopyNSURLResponseStatusLine);
+    INIT(CopyNSURLResponseCertificateChain);
     INIT(CreateCustomCFReadStream);
     INIT(CreateNSURLConnectionDelegateProxy);
     INIT(DrawCapsLockIndicator);
index e2377ee..80553c5 100644 (file)
@@ -1,3 +1,24 @@
+2012-12-19  Alexey Proskuryakov  <ap@apple.com>
+
+        <rdar://problem/12890242> [WK2 NetworkProcess] Client doesn't receive SSL certificates
+        https://bugs.webkit.org/show_bug.cgi?id=105467
+
+        Reviewed by Brady Eidson.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::didReceiveResponse):
+        * Shared/mac/PlatformCertificateInfo.mm:
+        (WebKit::PlatformCertificateInfo::PlatformCertificateInfo):
+        * WebProcess/Network/WebResourceLoader.cpp:
+        (WebKit::WebResourceLoader::didReceiveResponseWithCertificateInfo):
+        * WebProcess/Network/WebResourceLoader.h:
+        * WebProcess/Network/WebResourceLoader.messages.in:
+        Pass certificate chain over IPC, so that we could ultimately send it to client
+        via WebPageProxy::DidCommitLoadForFrame message.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm: (InitWebCoreSystemInterface):
+        Initialize a WKSI function we've been missing.
+
 2012-12-19  Jon Lee  <jonlee@apple.com>
 
         Add a function to set the origin hash table
index b93f955..52a5b44 100644 (file)
@@ -33,6 +33,7 @@
 #include "NetworkConnectionToWebProcess.h"
 #include "NetworkProcess.h"
 #include "NetworkResourceLoadParameters.h"
+#include "PlatformCertificateInfo.h"
 #include "RemoteNetworkingContext.h"
 #include "SharedMemory.h"
 #include "WebCoreArgumentCoders.h"
@@ -151,7 +152,7 @@ void NetworkResourceLoader::didReceiveResponse(ResourceHandle*, const ResourceRe
     // FIXME (NetworkProcess): Cache the response.
     if (FormData* formData = m_requestParameters.request().httpBody())
         formData->removeGeneratedFilesIfNeeded();
-    send(Messages::WebResourceLoader::DidReceiveResponse(response));
+    send(Messages::WebResourceLoader::DidReceiveResponseWithCertificateInfo(response, PlatformCertificateInfo(response)));
 }
 
 void NetworkResourceLoader::didReceiveData(ResourceHandle*, const char* data, int length, int encodedDataLength)
index ecffbe6..6eb1b16 100644 (file)
@@ -29,7 +29,6 @@
 #import "ArgumentCodersCF.h"
 #import "ArgumentDecoder.h"
 #import "ArgumentEncoder.h"
-#import <WebKitSystemInterface.h>
 
 using namespace WebCore;
 
@@ -40,7 +39,7 @@ PlatformCertificateInfo::PlatformCertificateInfo()
 }
 
 PlatformCertificateInfo::PlatformCertificateInfo(const ResourceResponse& response)
-    : m_certificateChain(AdoptCF, WKCopyNSURLResponseCertificateChain(response.nsURLResponse()))
+    : m_certificateChain(response.certificateChain())
 {
 }
 
index 10c5209..ce5cbf0 100644 (file)
@@ -33,6 +33,7 @@
 #include "NetworkConnectionToWebProcessMessages.h"
 #include "NetworkProcessConnection.h"
 #include "NetworkResourceLoaderMessages.h"
+#include "PlatformCertificateInfo.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebProcess.h"
 #include <WebCore/ResourceLoader.h>
@@ -75,10 +76,12 @@ void WebResourceLoader::willSendRequest(uint64_t requestID, const ResourceReques
     send(Messages::NetworkResourceLoader::WillSendRequestHandled(requestID, newRequest));
 }
 
-void WebResourceLoader::didReceiveResponse(const WebCore::ResourceResponse& response)
+void WebResourceLoader::didReceiveResponseWithCertificateInfo(const ResourceResponse& response, const PlatformCertificateInfo& certificateInfo)
 {
-    LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResponse for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode());
-    m_coreLoader->didReceiveResponse(response);
+    LOG(Network, "(WebProcess) WebResourceLoader::didReceiveResponseWithCertificateInfo for '%s'. Status %d.", m_coreLoader->url().string().utf8().data(), response.httpStatusCode());
+    ResourceResponse responseCopy(response);
+    responseCopy.setCertificateChain(certificateInfo.certificateChain());
+    m_coreLoader->didReceiveResponse(responseCopy);
 }
 
 void WebResourceLoader::didReceiveData(const CoreIPC::DataReference& data, int64_t encodedDataLength, bool allAtOnce)
index fa3783c..bdc6c07 100644 (file)
@@ -52,6 +52,7 @@ class ResourceResponse;
 
 namespace WebKit {
 
+class PlatformCertificateInfo;
 typedef uint64_t ResourceLoadIdentifier;
 
 class WebResourceLoader : public RefCounted<WebResourceLoader>, public CoreIPC::MessageSender<WebResourceLoader>, public WebCore::AuthenticationClient {
@@ -77,7 +78,7 @@ private:
     WebResourceLoader(PassRefPtr<WebCore::ResourceLoader>);
 
     void willSendRequest(uint64_t requestID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse& redirectResponse);
-    void didReceiveResponse(const WebCore::ResourceResponse&);
+    void didReceiveResponseWithCertificateInfo(const WebCore::ResourceResponse&, const PlatformCertificateInfo&);
     void didReceiveData(const CoreIPC::DataReference&, int64_t encodedDataLength, bool allAtOnce);
     void didFinishResourceLoad(double finishTime);
     void didFailResourceLoad(const WebCore::ResourceError&);
index 96b30b0..11c1b49 100644 (file)
@@ -24,7 +24,7 @@ messages -> WebResourceLoader {
 
     // FIXME (NetworkProcess): We'll need much more granularity for response messages.
     WillSendRequest(uint64_t requestID, WebCore::ResourceRequest request, WebCore::ResourceResponse redirectResponse)
-    DidReceiveResponse(WebCore::ResourceResponse response)
+    DidReceiveResponseWithCertificateInfo(WebCore::ResourceResponse response, WebKit::PlatformCertificateInfo certificateInfo)
     DidReceiveData(CoreIPC::DataReference data, int64_t encodedDataLength, bool allAtOnce)
     DidFinishResourceLoad(double finishTime)
     DidFailResourceLoad(WebCore::ResourceError error)
index d9cb97b..42c98bc 100644 (file)
@@ -50,6 +50,7 @@ void InitWebCoreSystemInterface(void)
 #endif
         INIT(CopyCONNECTProxyResponse);
         INIT(CopyNSURLResponseStatusLine);
+        INIT(CopyNSURLResponseCertificateChain);
         INIT(CreateCTLineWithUniCharProvider);
         INIT(CreateCustomCFReadStream);
         INIT(CreateNSURLConnectionDelegateProxy);