Changeset 82776 in webkit


Ignore:
Timestamp:
Apr 2, 2011 3:00:19 PM (13 years ago)
Author:
jeffm@apple.com
Message:

2011-04-02 Jeff Miller <jeffm@apple.com>

Reviewed by Dan Bernstein.

WebKit2: Specify the certificate store in WKBundleSetClientCertificate()
https://bugs.webkit.org/show_bug.cgi?id=57707

Include the name of the system certificate store that the client certificate came from in WKBundleSetClientCertificate().

The PCCERT_CONTEXT for the client certificate we create from the message from the UI process doesn't contain enough information to actually use it in a request, we need to get the real certificate from the certificate store (which is typically the "MY" store).

  • WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp: (WKBundleSetClientCertificate): Add certificateSystemStoreName to parameters.
  • WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h: Add certificateSystemStoreName to WKBundleSetClientCertificate() parameters.
  • WebProcess/InjectedBundle/InjectedBundle.h: Add certificateSystemStoreName to setClientCertificate() parameters.
  • WebProcess/InjectedBundle/win/InjectedBundleWin.cpp: (WebKit::InjectedBundle::setClientCertificate): Read the real certificate from the certificate store.
Location:
trunk/Source/WebKit2
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r82773 r82776  
     12011-04-02  Jeff Miller  <jeffm@apple.com>
     2
     3        Reviewed by Dan Bernstein.
     4
     5        WebKit2: Specify the certificate store in WKBundleSetClientCertificate()
     6        https://bugs.webkit.org/show_bug.cgi?id=57707
     7
     8        Include the name of the system certificate store that the client certificate came from in WKBundleSetClientCertificate().
     9
     10        The PCCERT_CONTEXT for the client certificate we create from the message from the UI process doesn't contain enough information to actually use it in a request, we need to get the real certificate from the certificate store (which is typically the "MY" store).
     11
     12        * WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp:
     13        (WKBundleSetClientCertificate): Add certificateSystemStoreName to parameters.
     14        * WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h: Add certificateSystemStoreName to WKBundleSetClientCertificate() parameters.
     15        * WebProcess/InjectedBundle/InjectedBundle.h: Add certificateSystemStoreName to setClientCertificate() parameters.
     16        * WebProcess/InjectedBundle/win/InjectedBundleWin.cpp:
     17        (WebKit::InjectedBundle::setClientCertificate): Read the real certificate from the certificate store.
     18
    1192011-04-02  Sam Weinig  <sam@webkit.org>
    220
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.cpp

    r82370 r82776  
    3838}
    3939
    40 void WKBundleSetClientCertificate(WKBundleRef bundleRef, WKStringRef host, WKCertificateInfoRef certificateInfoRef)
     40void WKBundleSetClientCertificate(WKBundleRef bundleRef, WKStringRef host, WKStringRef certificateSystemStoreName, WKCertificateInfoRef certificateInfoRef)
    4141{
    42     toImpl(bundleRef)->setClientCertificate(toWTFString(host), toImpl(certificateInfoRef));
     42    toImpl(bundleRef)->setClientCertificate(toWTFString(host), toWTFString(certificateSystemStoreName), toImpl(certificateInfoRef));
    4343}
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/win/WKBundlePrivateWin.h

    r82370 r82776  
    3434
    3535WK_EXPORT void WKBundleSetHostAllowsAnyHTTPSCertificate(WKBundleRef bundle, WKStringRef host);
    36 WK_EXPORT void WKBundleSetClientCertificate(WKBundleRef bundle, WKStringRef host, WKCertificateInfoRef certificateInfo);
     36WK_EXPORT void WKBundleSetClientCertificate(WKBundleRef bundle, WKStringRef host, WKStringRef certificateSystemStoreName, WKCertificateInfoRef certificateInfo);
    3737
    3838#ifdef __cplusplus
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.h

    r82710 r82776  
    8383#if PLATFORM(WIN)
    8484    void setHostAllowsAnyHTTPSCertificate(const String&);
    85     void setClientCertificate(const String&, const WebCertificateInfo*);
     85    void setClientCertificate(const String& host, const String& certificateSystemStoreName, const WebCertificateInfo*);
    8686#endif
    8787
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/win/InjectedBundleWin.cpp

    r82309 r82776  
    3232#include <WebCore/ResourceHandle.h>
    3333#include <WebCore/SimpleFontData.h>
     34#include <wtf/text/CString.h>
    3435
    3536#include <windows.h>
     
    100101}
    101102
    102 void InjectedBundle::setClientCertificate(const String& host, const WebCertificateInfo* certificateInfo)
     103void InjectedBundle::setClientCertificate(const String& host, const String& certificateSystemStoreName, const WebCertificateInfo* certificateInfo)
    103104{
    104105#if USE(CFNETWORK)
    105     ASSERT(certificateInfo);
     106    ASSERT_ARG(certificateInfo, certificateInfo);
    106107    if (!certificateInfo)
    107108        return;
     
    112113        return;
    113114   
    114     ResourceHandle::setClientCertificate(host, WebCore::copyCertificateToData(certificateChain.first()).get());
     115    ASSERT_ARG(certificateSystemStoreName, !certificateSystemStoreName.isEmpty());
     116    if (certificateSystemStoreName.isEmpty())
     117        return;
     118   
     119    // The PCCERT_CONTEXT in the WebCertificateInfo we created using the message from the UI process doesn't contain enough information
     120    // to actually use it in a request, we need to get the real certificate from the certificate store (which is typically the "MY" store).
     121    String mutableCertificateSystemStoreName = certificateSystemStoreName;
     122    HCERTSTORE certStore = ::CertOpenSystemStore(0, mutableCertificateSystemStoreName.charactersWithNullTermination());
     123    if (!certStore) {
     124        LOG_ERROR("Could not open system certificate store %s", certificateSystemStoreName.ascii().data());
     125        return;
     126    }
     127   
     128    PCCERT_CONTEXT realCert = ::CertFindCertificateInStore(certStore, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, 0, CERT_FIND_EXISTING, certificateChain.first(), 0);
     129    if (!realCert) {
     130        LOG_ERROR("Could not find certificate in system certificate store");
     131        return;
     132    }
     133
     134    ResourceHandle::setClientCertificate(host, WebCore::copyCertificateToData(realCert).get());
     135    CertFreeCertificateContext(realCert);
     136
     137    // We can't close certStore here, since the certificate is still in use.
    115138#endif
    116139}
Note: See TracChangeset for help on using the changeset viewer.