Commit c157754f authored by adachan's avatar adachan

<rdar://problem/4876242> Added SPI to fetch SSL certificate information.

        Reviewed by Adam and Steve.

        * Interfaces/IWebURLResponsePrivate.idl: Added.
        * WebKit.vcproj/Interfaces.vcproj:
        * WebKit.vcproj/WebKitGUID.vcproj:
        * WebURLResponse.cpp:
        (WebURLResponse::QueryInterface):
        (WebURLResponse::sslPeerCertificate): gets peer certificate context from CFNetwork
        (WebURLResponse::certificateDictionary): gets the dictionary that contains SSL certificate
        info from CFNetwork.  We retain the dictionary to ensure the certificate context is valid
        throughout the lifetime of the WebURLResponse.
        * WebURLResponse.h:
        


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@25272 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 289fa277
2007-08-28 Ada Chan <adachan@apple.com>
<rdar://problem/4876242> Added SPI to fetch SSL certificate information.
Reviewed by Adam and Steve.
* Interfaces/IWebURLResponsePrivate.idl: Added.
* WebKit.vcproj/Interfaces.vcproj:
* WebKit.vcproj/WebKitGUID.vcproj:
* WebURLResponse.cpp:
(WebURLResponse::QueryInterface):
(WebURLResponse::sslPeerCertificate): gets peer certificate context from CFNetwork
(WebURLResponse::certificateDictionary): gets the dictionary that contains SSL certificate
info from CFNetwork. We retain the dictionary to ensure the certificate context is valid
throughout the lifetime of the WebURLResponse.
* WebURLResponse.h:
2007-08-27 Steve Falkenburg <sfalken@apple.com>
<rdar://problem/5424801> REGRESSION (r25151): Web page area of window doesn't redraw if page isn't loaded
......
/*
* Copyright (C) 2007 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.
* 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE 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 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.
*/
cpp_quote("/*")
cpp_quote(" * Copyright (C) 2007 Apple Inc. All rights reserved.")
cpp_quote(" *")
cpp_quote(" * Redistribution and use in source and binary forms, with or without")
cpp_quote(" * modification, are permitted provided that the following conditions")
cpp_quote(" * are met:")
cpp_quote(" *")
cpp_quote(" * 1. Redistributions of source code must retain the above copyright")
cpp_quote(" * notice, this list of conditions and the following disclaimer. ")
cpp_quote(" * 2. Redistributions in binary form must reproduce the above copyright")
cpp_quote(" * notice, this list of conditions and the following disclaimer in the")
cpp_quote(" * documentation and/or other materials provided with the distribution. ")
cpp_quote(" * 3. Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of")
cpp_quote(" * its contributors may be used to endorse or promote products derived")
cpp_quote(" * from this software without specific prior written permission. ")
cpp_quote(" *")
cpp_quote(" * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY")
cpp_quote(" * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED")
cpp_quote(" * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE")
cpp_quote(" * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY")
cpp_quote(" * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES")
cpp_quote(" * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;")
cpp_quote(" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND")
cpp_quote(" * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT")
cpp_quote(" * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF")
cpp_quote(" * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.")
cpp_quote(" */")
import "oaidl.idl";
import "ocidl.idl";
[
object,
oleautomation,
uuid(18730CD8-864E-4898-B775-88905CC8E9DD),
pointer_default(unique)
]
interface IWebURLResponsePrivate : IUnknown
{
HRESULT sslPeerCertificate([out, retval] OLE_HANDLE* result);
}
......@@ -403,6 +403,10 @@
RelativePath="..\Interfaces\IWebURLResponse.idl"
>
</File>
<File
RelativePath="..\Interfaces\IWebURLResponsePrivate.idl"
>
</File>
<File
RelativePath="..\Interfaces\IWebView.idl"
>
......
......@@ -365,6 +365,10 @@
RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebURLResponse_i.c"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebURLResponsePrivate_i.c"
>
</File>
<File
RelativePath="$(WebKitOutputDir)\obj\WebKit\Interfaces\IWebView_i.c"
>
......
......@@ -30,6 +30,8 @@
#include "MarshallingHelpers.h"
#include "WebLocalizableStrings.h"
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#include <wtf/platform.h>
#pragma warning( push, 0 )
#include <WebCore/BString.h>
......@@ -243,11 +245,13 @@ HRESULT STDMETHODCALLTYPE WebURLResponse::QueryInterface(REFIID riid, void** ppv
{
*ppvObject = 0;
if (IsEqualGUID(riid, IID_IUnknown))
*ppvObject = static_cast<IUnknown*>(this);
*ppvObject = static_cast<IWebURLResponse*>(this);
else if (IsEqualGUID(riid, IID_WebURLResponse))
*ppvObject = static_cast<WebURLResponse*>(this);
else if (IsEqualGUID(riid, IID_IWebURLResponse))
*ppvObject = static_cast<IWebURLResponse*>(this);
else if (IsEqualGUID(riid, IID_IWebURLResponsePrivate))
*ppvObject = static_cast<IWebURLResponsePrivate*>(this);
else if (m_response.isHTTP() && IsEqualGUID(riid, IID_IWebHTTPURLResponse))
*ppvObject = static_cast<IWebHTTPURLResponse*>(this);
else
......@@ -381,6 +385,22 @@ HRESULT STDMETHODCALLTYPE WebURLResponse::statusCode(
return S_OK;
}
HRESULT STDMETHODCALLTYPE WebURLResponse::sslPeerCertificate(
/* [retval][out] */ OLE_HANDLE* result)
{
if (!result)
return E_POINTER;
*result = 0;
CFDictionaryRef dict = certificateDictionary();
if (!dict)
return E_FAIL;
void* data = wkGetSSLPeerCertificateData(dict);
if (!data)
return E_FAIL;
*result = (OLE_HANDLE)(ULONG64)data;
return *result ? S_OK : E_FAIL;
}
// WebURLResponse -------------------------------------------------------------
HRESULT WebURLResponse::suggestedFileExtension(BSTR *result)
......@@ -437,3 +457,14 @@ const ResourceResponse& WebURLResponse::resourceResponse() const
return m_response;
}
CFDictionaryRef WebURLResponse::certificateDictionary() const
{
if (m_SSLCertificateInfo)
return m_SSLCertificateInfo.get();
CFURLResponseRef cfResponse = m_response.cfURLResponse();
if (!cfResponse)
return 0;
m_SSLCertificateInfo = wkGetSSLCertificateInfo(cfResponse);
return m_SSLCertificateInfo.get();
}
......@@ -28,6 +28,7 @@
#include "IWebURLResponse.h"
#include "IWebHTTPURLResponse.h"
#include "IWebURLResponsePrivate.h"
#pragma warning(push, 0)
#include <WebCore/ResourceResponse.h>
......@@ -36,7 +37,7 @@
// {4E309D61-8458-49ed-A629-464E64D85505}
DEFINE_GUID(IID_WebURLResponse, 0x4e309d61, 0x8458, 0x49ed, 0xa6, 0x29, 0x46, 0x4e, 0x64, 0xd8, 0x55, 0x5);
class WebURLResponse : public IWebHTTPURLResponse
class WebURLResponse : public IWebHTTPURLResponse, IWebURLResponsePrivate
{
public:
static WebURLResponse* createInstance();
......@@ -84,14 +85,20 @@ public:
virtual HRESULT STDMETHODCALLTYPE statusCode(
/* [retval][out] */ int *statusCode);
// IWebURLResponsePrivate
virtual HRESULT STDMETHODCALLTYPE sslPeerCertificate(
/* [retval][out] */ OLE_HANDLE *result);
const WebCore::ResourceResponse& resourceResponse() const;
protected:
HRESULT suggestedFileExtension(BSTR* result);
CFDictionaryRef certificateDictionary() const;
protected:
ULONG m_refCount;
WebCore::ResourceResponse m_response;
mutable RetainPtr<CFDictionaryRef> m_SSLCertificateInfo; // this ensures certificate contexts are valid for the lifetime of this WebURLResponse.
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment