2011-03-28 Jeff Miller <jeffm@apple.com>
authorjeffm@apple.com <jeffm@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2011 18:16:18 +0000 (18:16 +0000)
committerjeffm@apple.com <jeffm@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2011 18:16:18 +0000 (18:16 +0000)
        Reviewed by Adam Roben.

        Include certificate when sending a WebCore::ResourceError to UI process on Windows
        https://bugs.webkit.org/show_bug.cgi?id=57195

        Rename wkGetSSLPeerCertificateData() to wkGetSSLPeerCertificateDataBytePtr(), since it returns a void*, and
        implement wkGetSSLPeerCertificateData() to return a CFDataRef.  Add wkSetSSLPeerCertificateData() so
        WebCore::ResourceError can set the certificate in the user info dictionary.

        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
        * win/lib/WebKitSystemInterface.lib:
2011-03-28  Jeff Miller  <jeffm@apple.com>

        Reviewed by Adam Roben.

        Include certificate when sending a WebCore::ResourceError to UI process on Windows
        https://bugs.webkit.org/show_bug.cgi?id=57195

        Rename callers of wkGetSSLPeerCertificateData() to use wkGetSSLPeerCertificateDataBytePtr(), since it returns a void*.

        * WebError.cpp:
        (WebError::sslPeerCertificate):
        * WebURLResponse.cpp:
        (WebURLResponse::sslPeerCertificate):
2011-03-28  Jeff Miller  <jeffm@apple.com>

        Reviewed by Adam Roben.

        Include certificate when sending a WebCore::ResourceError to UI process on Windows
        https://bugs.webkit.org/show_bug.cgi?id=57195

        Add support for tracking the certificate in WebCore::ResourceError.

        * platform/network/ResourceErrorBase.cpp:
        (WebCore::ResourceErrorBase::copy): Call platformCopy() to copy platform-specific fields.
        * platform/network/ResourceErrorBase.h:
        (WebCore::ResourceErrorBase::platformCopy): Added.
        * platform/network/cf/ResourceError.h: Added constructor that takes certificate data, shadowed platformCopy, added m_certificate.
        (WebCore::ResourceError::certificate): Added.
        * platform/network/cf/ResourceErrorCF.cpp:
        (WebCore::ResourceError::ResourceError): Added constructor that takes certificate data.
        (WebCore::ResourceError::platformLazyInit): Read any certificate from the userInfo dictionary.
        (WebCore::ResourceError::platformCopy): Copy m_certificate.
        (WebCore::ResourceError::cfError): Add any certificate data to the userInfo dictionary in the CFErrorRef.
2011-03-28  Jeff Miller  <jeffm@apple.com>

        Reviewed by Adam Roben.

        Include certificate when sending a WebCore::ResourceError to UI process on Windows
        https://bugs.webkit.org/show_bug.cgi?id=57195

        Add support for sending the certificate with the WebCore::ResourceError.

        * Shared/win/WebCoreArgumentCodersWin.cpp:
        (CoreIPC::encodeResourceError): Encode certificate data.
        (CoreIPC::deallocCertContext): Added.
        (CoreIPC::createCertContextDeallocator): Added.
        (CoreIPC::copyCert): Added.
        (CoreIPC::decodeResourceError): Decode certificate data.

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

13 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/network/ResourceErrorBase.cpp
Source/WebCore/platform/network/ResourceErrorBase.h
Source/WebCore/platform/network/cf/ResourceError.h
Source/WebCore/platform/network/cf/ResourceErrorCF.cpp
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebError.cpp
Source/WebKit/win/WebURLResponse.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/win/WebCoreArgumentCodersWin.cpp
WebKitLibraries/ChangeLog
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib

index 38c47d1..f605e87 100644 (file)
@@ -1,3 +1,24 @@
+2011-03-28  Jeff Miller  <jeffm@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Include certificate when sending a WebCore::ResourceError to UI process on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=57195
+
+        Add support for tracking the certificate in WebCore::ResourceError.
+
+        * platform/network/ResourceErrorBase.cpp:
+        (WebCore::ResourceErrorBase::copy): Call platformCopy() to copy platform-specific fields.
+        * platform/network/ResourceErrorBase.h:
+        (WebCore::ResourceErrorBase::platformCopy): Added.
+        * platform/network/cf/ResourceError.h: Added constructor that takes certificate data, shadowed platformCopy, added m_certificate.
+        (WebCore::ResourceError::certificate): Added.
+        * platform/network/cf/ResourceErrorCF.cpp:
+        (WebCore::ResourceError::ResourceError): Added constructor that takes certificate data.
+        (WebCore::ResourceError::platformLazyInit): Read any certificate from the userInfo dictionary.
+        (WebCore::ResourceError::platformCopy): Copy m_certificate.
+        (WebCore::ResourceError::cfError): Add any certificate data to the userInfo dictionary in the CFErrorRef.
+
 2011-03-28  Jessie Berlin  <jberlin@apple.com>
 
         Rubber-stamped by Adam Roben.
index 42bc0de..e1d29e0 100644 (file)
@@ -42,6 +42,7 @@ ResourceError ResourceErrorBase::copy() const
     errorCopy.m_localizedDescription = m_localizedDescription.crossThreadString();
     errorCopy.m_isNull = m_isNull;
     errorCopy.m_isCancellation = m_isCancellation;
+    platformCopy(errorCopy);
     return errorCopy;
 }
 
index a6b7c69..2d7be70 100644 (file)
@@ -74,6 +74,9 @@ protected:
     // The ResourceError subclass may "shadow" this method to lazily initialize platform specific fields
     void platformLazyInit() {}
 
+    // The ResourceError subclass may "shadow" this method to copy platform specific fields
+    void platformCopy(ResourceError&) const {}
+
     // The ResourceError subclass may "shadow" this method to compare platform specific fields
     static bool platformCompare(const ResourceError&, const ResourceError&) { return true; }
 
index 89abf51..72bedba 100644 (file)
@@ -61,6 +61,10 @@ public:
     operator CFErrorRef() const;
 
 #if USE(CFNETWORK)
+#if PLATFORM(WIN)
+    ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription, CFDataRef certificate);
+    CFDataRef certificate() const { return m_certificate.get(); }
+#endif
     ResourceError(CFStreamError error);
     CFStreamError cfStreamError() const;
     operator CFStreamError() const;
@@ -74,11 +78,15 @@ private:
     friend class ResourceErrorBase;
 
     void platformLazyInit();
+    void platformCopy(ResourceError&) const;
     static bool platformCompare(const ResourceError& a, const ResourceError& b);
 
     bool m_dataIsUpToDate;
 #if USE(CFNETWORK)
     mutable RetainPtr<CFErrorRef> m_platformError;
+#if PLATFORM(WIN)
+    RetainPtr<CFDataRef> m_certificate;
+#endif
 #else
     mutable RetainPtr<NSError> m_platformError;
 #endif
index b2f7964..73ffe01 100644 (file)
@@ -31,6 +31,9 @@
 #include "KURL.h"
 #include <CoreFoundation/CFError.h>
 #include <CFNetwork/CFNetworkErrors.h>
+#if PLATFORM(WIN)
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
+#endif
 #include <WTF/RetainPtr.h>
 
 namespace WebCore {
@@ -42,6 +45,15 @@ ResourceError::ResourceError(CFErrorRef cfError)
     m_isNull = !cfError;
 }
 
+#if PLATFORM(WIN)
+ResourceError::ResourceError(const String& domain, int errorCode, const String& failingURL, const String& localizedDescription, CFDataRef certificate)
+    : ResourceErrorBase(domain, errorCode, failingURL, localizedDescription)
+    , m_dataIsUpToDate(true)
+    , m_certificate(certificate)
+{
+}
+#endif // PLATFORM(WIN)
+
 const CFStringRef failingURLStringKey = CFSTR("NSErrorFailingURLStringKey");
 const CFStringRef failingURLKey = CFSTR("NSErrorFailingURLKey");
 
@@ -83,11 +95,22 @@ void ResourceError::platformLazyInit()
             }
         }
         m_localizedDescription = (CFStringRef) CFDictionaryGetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey);
+        
+#if PLATFORM(WIN)
+        m_certificate = wkGetSSLPeerCertificateData(userInfo.get());
+#endif
     }
 
     m_dataIsUpToDate = true;
 }
 
+void ResourceError::platformCopy(ResourceError& errorCopy) const
+{
+#if PLATFORM(WIN)
+    errorCopy.m_certificate = m_certificate;
+#endif
+}
+
 bool ResourceError::platformCompare(const ResourceError& a, const ResourceError& b)
 {
     return a.cfError() == b.cfError();
@@ -115,6 +138,11 @@ CFErrorRef ResourceError::cfError() const
             CFDictionarySetValue(userInfo.get(), failingURLKey, url.get());
         }
 
+#if PLATFORM(WIN)
+        if (m_certificate)
+            wkSetSSLPeerCertificateData(userInfo.get(), m_certificate.get());
+#endif
+        
         RetainPtr<CFStringRef> domainString(AdoptCF, m_domain.createCFString());
         m_platformError.adoptCF(CFErrorCreate(0, domainString.get(), m_errorCode, userInfo.get()));
     }
index 8f463d9..9757115 100644 (file)
@@ -1,3 +1,17 @@
+2011-03-28  Jeff Miller  <jeffm@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Include certificate when sending a WebCore::ResourceError to UI process on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=57195
+        
+        Rename callers of wkGetSSLPeerCertificateData() to use wkGetSSLPeerCertificateDataBytePtr(), since it returns a void*.
+
+        * WebError.cpp:
+        (WebError::sslPeerCertificate):
+        * WebURLResponse.cpp:
+        (WebURLResponse::sslPeerCertificate):
+
 2011-03-28  Darin Adler  <darin@apple.com>
 
         Set eol-style to native on more files. I noticed the last check-in had an entire file
index c9f1dff..513c51a 100644 (file)
@@ -227,7 +227,7 @@ HRESULT STDMETHODCALLTYPE WebError::sslPeerCertificate(
     if (!m_cfErrorUserInfoDict)
         return E_FAIL;
 
-    void* data = wkGetSSLPeerCertificateData(m_cfErrorUserInfoDict.get());
+    void* data = wkGetSSLPeerCertificateDataBytePtr(m_cfErrorUserInfoDict.get());
     if (!data)
         return E_FAIL;
     *result = (OLE_HANDLE)(ULONG64)data;
index 644e1d8..e812a7e 100644 (file)
@@ -410,7 +410,7 @@ HRESULT STDMETHODCALLTYPE WebURLResponse::sslPeerCertificate(
     CFDictionaryRef dict = certificateDictionary();
     if (!dict)
         return E_FAIL;
-    void* data = wkGetSSLPeerCertificateData(dict);
+    void* data = wkGetSSLPeerCertificateDataBytePtr(dict);
     if (!data)
         return E_FAIL;
     *result = (OLE_HANDLE)(ULONG64)data;
index 5631ccc..ab29fb2 100644 (file)
@@ -1,3 +1,19 @@
+2011-03-28  Jeff Miller  <jeffm@apple.com>
+
+        Reviewed by Adam Roben.
+
+        Include certificate when sending a WebCore::ResourceError to UI process on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=57195
+        
+        Add support for sending the certificate with the WebCore::ResourceError.
+
+        * Shared/win/WebCoreArgumentCodersWin.cpp:
+        (CoreIPC::encodeResourceError): Encode certificate data.
+        (CoreIPC::deallocCertContext): Added.
+        (CoreIPC::createCertContextDeallocator): Added.
+        (CoreIPC::copyCert): Added.
+        (CoreIPC::decodeResourceError): Decode certificate data.
+
 2011-03-27  Andy Estes  <aestes@apple.com>
 
         Reviewed by Maciej Stachowiak.
index 98e8612..9e02150 100644 (file)
@@ -28,6 +28,7 @@
 
 #if USE(CFNETWORK)
 #include "ArgumentCodersCF.h"
+#include "PlatformCertificateInfo.h"
 #include <WebKitSystemInterface/WebKitSystemInterface.h>
 #endif
 
@@ -120,8 +121,53 @@ bool decodeResourceResponse(ArgumentDecoder* decoder, WebCore::ResourceResponse&
 void encodeResourceError(ArgumentEncoder* encoder, const WebCore::ResourceError& resourceError)
 {
     encoder->encode(CoreIPC::In(resourceError.domain(), resourceError.errorCode(), resourceError.failingURL(), resourceError.localizedDescription()));
+
+#if USE(CFNETWORK)
+    CFErrorRef cfError = resourceError.cfError();
+    if (!cfError) {
+        encoder->encode(WebKit::PlatformCertificateInfo());
+        return;
+    }
+    
+    CFDataRef certificateData = resourceError.certificate();
+    if (!certificateData) {
+        encoder->encode(WebKit::PlatformCertificateInfo());
+        return;
+    }
+
+    PCCERT_CONTEXT certificate = reinterpret_cast<PCCERT_CONTEXT>(CFDataGetBytePtr(certificateData));
+    if (!certificate) {
+        encoder->encode(WebKit::PlatformCertificateInfo());
+        return;
+    }
+    
+    encoder->encode(WebKit::PlatformCertificateInfo(certificate));
+#endif
+}
+
+#if USE(CFNETWORK)
+static void deallocCertContext(void* ptr, void* info)
+{
+    if (ptr)
+        CertFreeCertificateContext(static_cast<PCCERT_CONTEXT>(ptr));
 }
 
+static CFAllocatorRef createCertContextDeallocator()
+{
+    CFAllocatorContext allocContext = {
+        0, 0, 0, 0, 0, 0, 0, deallocCertContext, 0
+    };
+    return CFAllocatorCreate(kCFAllocatorDefault, &allocContext);
+}
+
+static CFDataRef copyCert(PCCERT_CONTEXT cert)
+{
+    static CFAllocatorRef certDealloc = createCertContextDeallocator();
+    PCCERT_CONTEXT certCopy = CertDuplicateCertificateContext(cert);
+    return CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(certCopy), sizeof(*certCopy), certDealloc);
+}
+#endif // USE(CFNETWORK)
+
 bool decodeResourceError(ArgumentDecoder* decoder, WebCore::ResourceError& resourceError)
 {
     String domain;
@@ -130,6 +176,20 @@ bool decodeResourceError(ArgumentDecoder* decoder, WebCore::ResourceError& resou
     String localizedDescription;
     if (!decoder->decode(CoreIPC::Out(domain, errorCode, failingURL, localizedDescription)))
         return false;
+
+#if USE(CFNETWORK)
+    WebKit::PlatformCertificateInfo certificate;
+    if (!decoder->decode(certificate))
+        return false;
+    
+    const Vector<PCCERT_CONTEXT> certificateChain = certificate.certificateChain();
+    if (!certificateChain.isEmpty()) {
+        ASSERT(certificateChain.size() == 1);
+        resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription, copyCert(certificateChain.first()));
+        return true;
+    }
+#endif
+
     resourceError = WebCore::ResourceError(domain, errorCode, failingURL, localizedDescription);
     return true;
 }
index 050ec58..e81b709 100644 (file)
@@ -1,5 +1,19 @@
 2011-03-28  Jeff Miller  <jeffm@apple.com>
 
+        Reviewed by Adam Roben.
+
+        Include certificate when sending a WebCore::ResourceError to UI process on Windows
+        https://bugs.webkit.org/show_bug.cgi?id=57195
+
+        Rename wkGetSSLPeerCertificateData() to wkGetSSLPeerCertificateDataBytePtr(), since it returns a void*, and
+        implement wkGetSSLPeerCertificateData() to return a CFDataRef.  Add wkSetSSLPeerCertificateData() so
+        WebCore::ResourceError can set the certificate in the user info dictionary.
+
+        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
+        * win/lib/WebKitSystemInterface.lib:
+
+2011-03-28  Jeff Miller  <jeffm@apple.com>
+
         Rubber-stamped by Adam Roben.
 
         Remove WebKitSystemInterface_debug.lib, it hasn't been used for a few months now.
index 80f97c3..0838028 100644 (file)
@@ -86,7 +86,9 @@ CGAffineTransform wkGetUserToBaseCTM(CGContextRef);
 void wkDrawFocusRing(CGContextRef, CGColorRef, float radius);
 
 CFDictionaryRef wkGetSSLCertificateInfo(CFURLResponseRef);
-void* wkGetSSLPeerCertificateData(CFDictionaryRef);
+CFDataRef wkGetSSLPeerCertificateData(CFDictionaryRef);
+void* wkGetSSLPeerCertificateDataBytePtr(CFDictionaryRef);
+void wkSetSSLPeerCertificateData(CFMutableDictionaryRef, CFDataRef);
 void* wkGetSSLCertificateChainContext(CFDictionaryRef);
 CFHTTPCookieStorageRef wkGetDefaultHTTPCookieStorage();
 CFHTTPCookieStorageRef wkCreateInMemoryHTTPCookieStorage();
index 532555d..d212612 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ