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
+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.
errorCopy.m_localizedDescription = m_localizedDescription.crossThreadString();
errorCopy.m_isNull = m_isNull;
errorCopy.m_isCancellation = m_isCancellation;
+ platformCopy(errorCopy);
return errorCopy;
}
// 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; }
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;
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
#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 {
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");
}
}
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();
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()));
}
+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
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;
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;
+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.
#if USE(CFNETWORK)
#include "ArgumentCodersCF.h"
+#include "PlatformCertificateInfo.h"
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#endif
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;
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;
}
+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.
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();