Add callback for custom certificate selection (issue #1824)

This commit is contained in:
Marshall Greenblatt
2016-10-27 13:57:12 -04:00
parent e006ec0ab5
commit 676cb1f07d
23 changed files with 613 additions and 67 deletions

View File

@ -20,6 +20,8 @@
#include "libcef_dll/ctocpp/request_callback_ctocpp.h"
#include "libcef_dll/ctocpp/response_ctocpp.h"
#include "libcef_dll/ctocpp/sslinfo_ctocpp.h"
#include "libcef_dll/ctocpp/select_client_certificate_callback_ctocpp.h"
#include "libcef_dll/ctocpp/x509certificate_ctocpp.h"
namespace {
@ -466,6 +468,56 @@ int CEF_CALLBACK request_handler_on_certificate_error(
return _retval;
}
int CEF_CALLBACK request_handler_on_select_client_certificate(
struct _cef_request_handler_t* self, cef_browser_t* browser, int isProxy,
const cef_string_t* host, int port, size_t certificatesCount,
struct _cef_x509certificate_t* const* certificates,
cef_select_client_certificate_callback_t* callback) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return 0;
// Verify param: browser; type: refptr_diff
DCHECK(browser);
if (!browser)
return 0;
// Verify param: host; type: string_byref_const
DCHECK(host);
if (!host)
return 0;
// Verify param: certificates; type: refptr_vec_diff_byref_const
DCHECK(certificatesCount == 0 || certificates);
if (certificatesCount > 0 && !certificates)
return 0;
// Verify param: callback; type: refptr_diff
DCHECK(callback);
if (!callback)
return 0;
// Translate param: certificates; type: refptr_vec_diff_byref_const
std::vector<CefRefPtr<CefX509Certificate> > certificatesList;
if (certificatesCount > 0) {
for (size_t i = 0; i < certificatesCount; ++i) {
CefRefPtr<CefX509Certificate> certificatesVal =
CefX509CertificateCToCpp::Wrap(certificates[i]);
certificatesList.push_back(certificatesVal);
}
}
// Execute
bool _retval = CefRequestHandlerCppToC::Get(self)->OnSelectClientCertificate(
CefBrowserCToCpp::Wrap(browser),
isProxy?true:false,
CefString(host),
port,
certificatesList,
CefSelectClientCertificateCallbackCToCpp::Wrap(callback));
// Return type: bool
return _retval;
}
void CEF_CALLBACK request_handler_on_plugin_crashed(
struct _cef_request_handler_t* self, cef_browser_t* browser,
const cef_string_t* plugin_path) {
@ -546,6 +598,8 @@ CefRequestHandlerCppToC::CefRequestHandlerCppToC() {
GetStruct()->on_quota_request = request_handler_on_quota_request;
GetStruct()->on_protocol_execution = request_handler_on_protocol_execution;
GetStruct()->on_certificate_error = request_handler_on_certificate_error;
GetStruct()->on_select_client_certificate =
request_handler_on_select_client_certificate;
GetStruct()->on_plugin_crashed = request_handler_on_plugin_crashed;
GetStruct()->on_render_view_ready = request_handler_on_render_view_ready;
GetStruct()->on_render_process_terminated =

View File

@ -0,0 +1,63 @@
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#include "libcef_dll/cpptoc/select_client_certificate_callback_cpptoc.h"
#include "libcef_dll/cpptoc/x509certificate_cpptoc.h"
namespace {
// MEMBER FUNCTIONS - Body may be edited by hand.
void CEF_CALLBACK select_client_certificate_callback_select(
struct _cef_select_client_certificate_callback_t* self,
struct _cef_x509certificate_t* cert) {
// AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING
DCHECK(self);
if (!self)
return;
// Unverified params: cert
// Execute
CefSelectClientCertificateCallbackCppToC::Get(self)->Select(
CefX509CertificateCppToC::Unwrap(cert));
}
} // namespace
// CONSTRUCTOR - Do not edit by hand.
CefSelectClientCertificateCallbackCppToC::CefSelectClientCertificateCallbackCppToC(
) {
GetStruct()->select = select_client_certificate_callback_select;
}
template<> CefRefPtr<CefSelectClientCertificateCallback> CefCppToC<CefSelectClientCertificateCallbackCppToC,
CefSelectClientCertificateCallback,
cef_select_client_certificate_callback_t>::UnwrapDerived(
CefWrapperType type, cef_select_client_certificate_callback_t* s) {
NOTREACHED() << "Unexpected class type: " << type;
return NULL;
}
#if DCHECK_IS_ON()
template<> base::AtomicRefCount CefCppToC<CefSelectClientCertificateCallbackCppToC,
CefSelectClientCertificateCallback,
cef_select_client_certificate_callback_t>::DebugObjCt = 0;
#endif
template<> CefWrapperType CefCppToC<CefSelectClientCertificateCallbackCppToC,
CefSelectClientCertificateCallback,
cef_select_client_certificate_callback_t>::kWrapperType =
WT_SELECT_CLIENT_CERTIFICATE_CALLBACK;

View File

@ -0,0 +1,36 @@
// Copyright (c) 2016 The Chromium Embedded Framework Authors. All rights
// reserved. Use of this source code is governed by a BSD-style license that
// can be found in the LICENSE file.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool. If making changes by
// hand only do so within the body of existing method and function
// implementations. See the translator.README.txt file in the tools directory
// for more information.
//
#ifndef CEF_LIBCEF_DLL_CPPTOC_SELECT_CLIENT_CERTIFICATE_CALLBACK_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_SELECT_CLIENT_CERTIFICATE_CALLBACK_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_request_handler.h"
#include "include/capi/cef_request_handler_capi.h"
#include "libcef_dll/cpptoc/cpptoc.h"
// Wrap a C++ class with a C structure.
// This class may be instantiated and accessed DLL-side only.
class CefSelectClientCertificateCallbackCppToC
: public CefCppToC<CefSelectClientCertificateCallbackCppToC,
CefSelectClientCertificateCallback,
cef_select_client_certificate_callback_t> {
public:
CefSelectClientCertificateCallbackCppToC();
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_SELECT_CLIENT_CERTIFICATE_CALLBACK_CPPTOC_H_