<rdar://problem/5074612> Added SPI to retrieve certificate info from a WebError.
authoradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2007 19:58:22 +0000 (19:58 +0000)
committeradachan <adachan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 29 Aug 2007 19:58:22 +0000 (19:58 +0000)
        Reviewed by Steve.

        * Interfaces/IWebErrorPrivate.idl: Added IWebErrorPrivate
        * WebError.cpp:
        (WebError::QueryInterface): WebError now also implements IWebErrorPrivate
        (WebError::sslPeerCertificate): retrieves certificate info from CFError's user info.
        * WebError.h:
        * WebKit.vcproj/WebKitGUID.vcproj: Added IWebErrorPrivate_i.c

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

WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebErrorPrivate.idl
WebKit/win/WebError.cpp
WebKit/win/WebError.h
WebKit/win/WebKit.vcproj/WebKitGUID.vcproj

index bbcd88eeb467ed7235a46561793e4ecac0980ac4..ce670b691f93b6302ede51cc44dda5c4b0fec70e 100644 (file)
@@ -1,3 +1,16 @@
+2007-08-29  Ada Chan  <adachan@apple.com>
+
+        <rdar://problem/5074612> Added SPI to retrieve certificate info from a WebError.
+
+        Reviewed by Steve.
+
+        * Interfaces/IWebErrorPrivate.idl: Added IWebErrorPrivate
+        * WebError.cpp:
+        (WebError::QueryInterface): WebError now also implements IWebErrorPrivate
+        (WebError::sslPeerCertificate): retrieves certificate info from CFError's user info.
+        * WebError.h:
+        * WebKit.vcproj/WebKitGUID.vcproj: Added IWebErrorPrivate_i.c
+
 2007-08-28  Steve Falkenburg  <sfalken@apple.com>
 
         <rdar://problem/5079253> Cannot set different margins for the page
index b5614842d5f20f547e1b513176bc1fc2e9dd6d10..e3148044b4b494bc839eee151d95cb2076826fb8 100644 (file)
@@ -53,3 +53,18 @@ cpp_quote("// FIXME: WebKitErrorPlugInWillHandleLoad is used for the cancel we d
 cpp_quote("#define WebKitErrorPlugInWillHandleLoad 204")
 
 cpp_quote("#define WebErrorFailingURLKey TEXT(\"WebErrorFailingURLKey\")")
+
+import "oaidl.idl";
+import "ocidl.idl";
+
+[
+    object,
+    oleautomation,
+    uuid(19FED49C-7016-48a6-B5C6-07ADE116531B),
+    pointer_default(unique)
+]
+
+interface IWebErrorPrivate : IUnknown
+{
+    HRESULT sslPeerCertificate([out, retval] OLE_HANDLE* result);
+}
index 9d4664465575761176c9ff6fc1b2d514228ef26d..1b6a660f03b197e71c913eeb9a164aa74f6ee7ec 100644 (file)
@@ -28,6 +28,7 @@
 #include "WebError.h"
 #include "WebKit.h"
 
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #pragma warning(push, 0)
 #include <WebCore/BString.h>
 #pragma warning(pop)
@@ -62,11 +63,13 @@ HRESULT STDMETHODCALLTYPE WebError::QueryInterface(REFIID riid, void** ppvObject
 {
     *ppvObject = 0;
     if (IsEqualGUID(riid, IID_IUnknown))
-        *ppvObject = static_cast<IUnknown*>(this);
+        *ppvObject = static_cast<IWebError*>(this);
     else if (IsEqualGUID(riid, CLSID_WebError))
         *ppvObject = static_cast<WebError*>(this);
     else if (IsEqualGUID(riid, IID_IWebError))
         *ppvObject = static_cast<IWebError*>(this);
+    else if (IsEqualGUID(riid, IID_IWebErrorPrivate))
+        *ppvObject = static_cast<IWebErrorPrivate*>(this);
     else
         return E_NOINTERFACE;
 
@@ -189,6 +192,29 @@ HRESULT STDMETHODCALLTYPE WebError::isPolicyChangeError(
     return S_OK;
 }
 
+HRESULT STDMETHODCALLTYPE WebError::sslPeerCertificate( 
+    /* [retval][out] */ OLE_HANDLE* result)
+{
+    if (!result)
+        return E_POINTER;
+    *result = 0;
+
+    if (!m_cfErrorUserInfoDict) {
+        // copy userinfo from CFErrorRef
+        CFErrorRef cfError = m_error;
+        m_cfErrorUserInfoDict.adoptCF(CFErrorCopyUserInfo(cfError));
+    }
+
+    if (!m_cfErrorUserInfoDict)
+        return E_FAIL;
+
+    void* data = wkGetSSLPeerCertificateData(m_cfErrorUserInfoDict.get());
+    if (!data)
+        return E_FAIL;
+    *result = (OLE_HANDLE)(ULONG64)data;
+    return *result ? S_OK : E_FAIL;
+}
+
 const ResourceError& WebError::resourceError() const
 {
     return m_error;
index 05ec26ee36bd0f2f16a49146eca0e4ea67138a43..189d998cd7a32edc2787b85be96fc012cb67615a 100644 (file)
 #define WebError_h
 
 #include "IWebError.h"
+#include "IWebErrorPrivate.h"
 
 #pragma warning(push, 0)
 #include <WebCore/COMPtr.h>
 #include <WebCore/ResourceError.h>
 #pragma warning(pop)
 
-class WebError : public IWebError {
+class WebError : public IWebError, IWebErrorPrivate {
 public:
     static WebError* createInstance(const WebCore::ResourceError&, IPropertyBag* userInfo = 0);
 protected:
@@ -82,11 +83,16 @@ public:
     virtual HRESULT STDMETHODCALLTYPE isPolicyChangeError( 
         /* [retval][out] */ BOOL *result);
 
+    // IWebErrorPrivate
+    virtual HRESULT STDMETHODCALLTYPE sslPeerCertificate( 
+        /* [retval][out] */ OLE_HANDLE *result);
+
     const WebCore::ResourceError& resourceError() const;
 
 private:
     ULONG m_refCount;
     COMPtr<IPropertyBag> m_userInfo;
+    RetainPtr<CFDictionaryRef> m_cfErrorUserInfoDict;
     WebCore::ResourceError m_error;
 };
 
index 28310e27ee0156fd4b0de7371b3b72fce5ae8f44..0b19c70fe9a137cf1f28925a9cea5671c3d6e2fc 100644 (file)
                        RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebError_i.c"
                        >
                </File>
+               <File
+                       RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebErrorPrivate_i.c"
+                       >
+               </File>
                <File
                        RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebFormDelegate_i.c"
                        >