Commit cf65b803 authored by weinig@apple.com's avatar weinig@apple.com

Add Windows implementation of PlatformCertificateInfo

Part of < rdar://problem/8350189>
https://bugs.webkit.org/show_bug.cgi?id=46450

Reviewed by Adam Roben.

* Shared/win/PlatformCertificateInfo.cpp: Added.
(WebKit::PlatformCertificateInfo::PlatformCertificateInfo):
(WebKit::PlatformCertificateInfo::~PlatformCertificateInfo):
(WebKit::PlatformCertificateInfo::encode):
(WebKit::PlatformCertificateInfo::decode):
(WebKit::organizationNameForCertificate):
* Shared/win/PlatformCertificateInfo.h:
(WebKit::PlatformCertificateInfo::certificateContext):
* UIProcess/API/C/win/WKCertificateInfoWin.cpp: Added.
(WKCertificateInfoGetCertificateContext):
* UIProcess/API/C/win/WKCertificateInfoWin.h: Added.
* win/WebKit2.vcproj:
* win/WebKit2Generated.make:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@68260 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4bee913b
2010-09-23 Sam Weinig <sam@webkit.org>
Reviewed by Adam Roben.
Add Windows implementation of PlatformCertificateInfo
Part of < rdar://problem/8350189>
https://bugs.webkit.org/show_bug.cgi?id=46450
* Shared/win/PlatformCertificateInfo.cpp: Added.
(WebKit::PlatformCertificateInfo::PlatformCertificateInfo):
(WebKit::PlatformCertificateInfo::~PlatformCertificateInfo):
(WebKit::PlatformCertificateInfo::encode):
(WebKit::PlatformCertificateInfo::decode):
(WebKit::organizationNameForCertificate):
* Shared/win/PlatformCertificateInfo.h:
(WebKit::PlatformCertificateInfo::certificateContext):
* UIProcess/API/C/win/WKCertificateInfoWin.cpp: Added.
(WKCertificateInfoGetCertificateContext):
* UIProcess/API/C/win/WKCertificateInfoWin.h: Added.
* win/WebKit2.vcproj:
* win/WebKit2Generated.make:
2010-09-23 Kenneth Rohde Christiansen <kenneth.christiansen@openbossa.org>
Reviewed by Sam Weinig.
......
/*
* Copyright (C) 2010 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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.
*/
#include "PlatformCertificateInfo.h"
#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
#include <WebCore/ResourceResponse.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
using namespace WebCore;
namespace WebKit {
PlatformCertificateInfo::PlatformCertificateInfo()
: m_certificateContext(0)
{
}
PlatformCertificateInfo::PlatformCertificateInfo(const ResourceResponse& response)
: m_certificateContext(0)
{
CFURLResponseRef cfResponse = response.cfURLResponse();
if (!cfResponse)
return;
CFDictionaryRef certificateInfo = wkGetSSLCertificateInfo(cfResponse);
if (!certificateInfo)
return;
void* data = wkGetSSLPeerCertificateData(certificateInfo.get());
if (!data)
return;
m_certificateContext = ::CertDuplicateCertificateContext(static_cast<PCCERT_CONTEXT>(data));
}
PlatformCertificateInfo::~PlatformCertificateInfo()
{
if (m_certificateContext)
::CertFreeCertificateContext(m_certificateContext);
}
void PlatformCertificateInfo::encode(CoreIPC::ArgumentEncoder* encoder) const
{
// FIXME: We should encode the no certificate context case in the
// number of the bytes.
if (!m_certificateContext) {
encoder->encodeBool(true);
return;
}
encoder->encodeBool(false);
encoder->encodeBytes(static_cast<uint8_t*>(m_certificateContext->pbCertEncoded), m_certificateContext->cbCertEncoded);
}
bool PlatformCertificateInfo::decode(CoreIPC::ArgumentDecoder* decoder, PlatformCertificateInfo& c)
{
bool noCertificate;
if (!decoder->decode(noCertificate))
return false;
if (noCertificate)
return true;
Vector<uint8_t> bytes;
if (!decoder->decodeBytes(bytes))
return false;
PCCERT_CONTEXT certificateContext = ::CertCreateCertificateContext(PKCS_7_ASN_ENCODING | X509_ASN_ENCODING, bytes.data(), bytes.size());
if (!certificateContext)
return false;
c.m_certificateContext = certificateContext;
return true;
}
} // namespace WebKit
......@@ -26,30 +26,30 @@
#ifndef PlatformCertificateInfo_h
#define PlatformCertificateInfo_h
#include "ArgumentDecoder.h"
#include "ArgumentEncoder.h"
#include <WebCore/ResourceResponse.h>
namespace CoreIPC {
class ArgumentDecoder;
class ArgumentEncoder;
}
namespace WebCore {
class ResourceResponse;
}
namespace WebKit {
class PlatformCertificateInfo {
public:
PlatformCertificateInfo()
{
}
explicit PlatformCertificateInfo(const WebCore::ResourceResponse&)
{
}
void encode(CoreIPC::ArgumentEncoder*) const
{
}
static bool decode(CoreIPC::ArgumentDecoder*, PlatformCertificateInfo&)
{
return true;
}
PlatformCertificateInfo();
explicit PlatformCertificateInfo(const WebCore::ResourceResponse&);
~PlatformCertificateInfo();
PCCERT_CONTEXT certificateContext() const { return m_certificateContext; }
void encode(CoreIPC::ArgumentEncoder* encoder) const;
static bool decode(CoreIPC::ArgumentDecoder* decoder, PlatformCertificateInfo& t);
private:
PCCERT_CONTEXT m_certificateContext;
};
} // namespace WebKit
......
/*
* Copyright (C) 2010 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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.
*/
#include "WKCertificateInfoWin.h"
#include "WKAPICast.h"
#include "WebCertificateInfo.h"
using namespace WebKit;
PCCERT_CONTEXT WKCertificateInfoGetCertificateContext(WKCertificateInfoRef certificateInfoRef)
{
return toWK(certificateInfoRef)->platformCertificateInfo().certificateContext();
}
/*
* Copyright (C) 2010 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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.
*/
#ifndef WKCertificateInfoWin_h
#define WKCertificateInfoWin_h
#include <WebKit2/WKBase.h>
#include <Wincrypt.h>
#ifdef __cplusplus
extern "C" {
#endif
WK_EXPORT PCCERT_CONTEXT WKCertificateInfoGetCertificateContext(WKCertificateInfoRef certificateInfo);
#ifdef __cplusplus
}
#endif
#endif /* WKCertificateInfoWin_h */
......@@ -1832,7 +1832,6 @@
isa = PBXProject;
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "WebKit2" */;
compatibilityVersion = "Xcode 3.1";
developmentRegion = English;
hasScannedForEncodings = 1;
knownRegions = (
English,
......
......@@ -555,6 +555,10 @@
RelativePath="..\Shared\win\CommandLineWin.cpp"
>
</File>
<File
RelativePath="..\Shared\win\PlatformCertificateInfo.cpp"
>
</File>
<File
RelativePath="..\Shared\win\PlatformCertificateInfo.h"
>
......@@ -1350,6 +1354,14 @@
RelativePath="..\UIProcess\API\C\WKCertificateInfo.h"
>
</File>
<File
RelativePath="..\UIProcess\API\C\win\WKCertificateInfoWin.cpp"
>
</File>
<File
RelativePath="..\UIProcess\API\C\win\WKCertificateInfoWin.h"
>
</File>
<File
RelativePath="..\UIProcess\API\C\WKContext.cpp"
>
......
......@@ -32,6 +32,7 @@ all:
xcopy /y /d "..\UIProcess\API\C\cf\WKURLCF.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\cf\WKURLRequestCF.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\cf\WKURLResponseCF.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\win\WKCertificateInfoWin.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
xcopy /y /d "..\UIProcess\API\C\win\WKContextPrivateWin.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
xcopy /y /d "..\UIProcess\API\cpp\WKRetainPtr.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
xcopy /y /d "..\UIProcess\API\win\WKBaseWin.h" "$(WEBKITOUTPUTDIR)\include\WebKit2"
......
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