From 10c1fd6b8d32300de736268581ca83f69c966b1b Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Fri, 2 Sep 2016 13:01:33 +0300 Subject: [PATCH] Add API for SSL status and certificate retrieval (issue #1924) --- BUILD.gn | 8 +- cef_paths.gypi | 20 +- include/capi/cef_browser_capi.h | 7 + include/capi/cef_life_span_handler_capi.h | 4 +- include/capi/cef_navigation_entry_capi.h | 7 + include/capi/cef_ssl_info_capi.h | 159 +---------- include/capi/cef_ssl_status_capi.h | 95 +++++++ include/capi/cef_x509_certificate_capi.h | 208 ++++++++++++++ include/cef_browser.h | 7 + include/cef_navigation_entry.h | 8 + include/cef_ssl_info.h | 161 ++--------- include/cef_ssl_status.h | 84 ++++++ include/cef_x509_certificate.h | 188 +++++++++++++ include/internal/cef_types.h | 21 ++ libcef/browser/browser_host_impl.cc | 16 ++ libcef/browser/browser_host_impl.h | 1 + libcef/browser/navigation_entry_impl.cc | 7 + libcef/browser/navigation_entry_impl.h | 1 + libcef/browser/ssl_info_impl.cc | 111 +------- libcef/browser/ssl_info_impl.h | 23 +- libcef/browser/ssl_status_impl.cc | 45 ++++ libcef/browser/ssl_status_impl.h | 35 +++ ...al_impl.cc => x509_cert_principal_impl.cc} | 24 +- ...ipal_impl.h => x509_cert_principal_impl.h} | 22 +- libcef/browser/x509_certificate_impl.cc | 104 +++++++ libcef/browser/x509_certificate_impl.h | 45 ++++ libcef_dll/cpptoc/browser_host_cpptoc.cc | 19 ++ libcef_dll/cpptoc/navigation_entry_cpptoc.cc | 18 ++ libcef_dll/cpptoc/navigation_entry_cpptoc.h | 2 + libcef_dll/cpptoc/sslinfo_cpptoc.cc | 234 +--------------- libcef_dll/cpptoc/sslstatus_cpptoc.cc | 122 +++++++++ libcef_dll/cpptoc/sslstatus_cpptoc.h | 36 +++ ...cpptoc.cc => x509cert_principal_cpptoc.cc} | 92 +++---- libcef_dll/cpptoc/x509cert_principal_cpptoc.h | 35 +++ libcef_dll/cpptoc/x509certificate_cpptoc.cc | 254 ++++++++++++++++++ ...ipal_cpptoc.h => x509certificate_cpptoc.h} | 18 +- libcef_dll/ctocpp/browser_host_ctocpp.cc | 17 ++ libcef_dll/ctocpp/browser_host_ctocpp.h | 1 + libcef_dll/ctocpp/navigation_entry_ctocpp.cc | 15 ++ libcef_dll/ctocpp/navigation_entry_ctocpp.h | 3 + libcef_dll/ctocpp/sslinfo_ctocpp.cc | 216 +-------------- libcef_dll/ctocpp/sslinfo_ctocpp.h | 13 +- libcef_dll/ctocpp/sslstatus_ctocpp.cc | 107 ++++++++ libcef_dll/ctocpp/sslstatus_ctocpp.h | 43 +++ ...ctocpp.cc => x509cert_principal_ctocpp.cc} | 56 ++-- ...l_ctocpp.h => x509cert_principal_ctocpp.h} | 20 +- libcef_dll/ctocpp/x509certificate_ctocpp.cc | 233 ++++++++++++++++ libcef_dll/ctocpp/x509certificate_ctocpp.h | 47 ++++ libcef_dll/libcef_dll.cc | 32 ++- libcef_dll/wrapper/libcef_dll_wrapper.cc | 32 ++- libcef_dll/wrapper_types.h | 4 +- tests/cefclient/browser/client_handler.cc | 189 +++++++++---- tests/cefclient/browser/client_handler.h | 6 + 53 files changed, 2239 insertions(+), 1036 deletions(-) create mode 100644 include/capi/cef_ssl_status_capi.h create mode 100644 include/capi/cef_x509_certificate_capi.h create mode 100644 include/cef_ssl_status.h create mode 100644 include/cef_x509_certificate.h create mode 100644 libcef/browser/ssl_status_impl.cc create mode 100644 libcef/browser/ssl_status_impl.h rename libcef/browser/{ssl_cert_principal_impl.cc => x509_cert_principal_impl.cc} (62%) rename libcef/browser/{ssl_cert_principal_impl.h => x509_cert_principal_impl.h} (55%) create mode 100644 libcef/browser/x509_certificate_impl.cc create mode 100644 libcef/browser/x509_certificate_impl.h create mode 100644 libcef_dll/cpptoc/sslstatus_cpptoc.cc create mode 100644 libcef_dll/cpptoc/sslstatus_cpptoc.h rename libcef_dll/cpptoc/{sslcert_principal_cpptoc.cc => x509cert_principal_cpptoc.cc} (57%) create mode 100644 libcef_dll/cpptoc/x509cert_principal_cpptoc.h create mode 100644 libcef_dll/cpptoc/x509certificate_cpptoc.cc rename libcef_dll/cpptoc/{sslcert_principal_cpptoc.h => x509certificate_cpptoc.h} (66%) create mode 100644 libcef_dll/ctocpp/sslstatus_ctocpp.cc create mode 100644 libcef_dll/ctocpp/sslstatus_ctocpp.h rename libcef_dll/ctocpp/{sslcert_principal_ctocpp.cc => x509cert_principal_ctocpp.cc} (76%) rename libcef_dll/ctocpp/{sslcert_principal_ctocpp.h => x509cert_principal_ctocpp.h} (73%) create mode 100644 libcef_dll/ctocpp/x509certificate_ctocpp.cc create mode 100644 libcef_dll/ctocpp/x509certificate_ctocpp.h diff --git a/BUILD.gn b/BUILD.gn index b92ad2ee9..229a0d3f3 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -380,12 +380,12 @@ static_library("libcef_static") { "libcef/browser/scheme_impl.cc", "libcef/browser/speech_recognition_manager_delegate.cc", "libcef/browser/speech_recognition_manager_delegate.h", - "libcef/browser/ssl_cert_principal_impl.cc", - "libcef/browser/ssl_cert_principal_impl.h", "libcef/browser/ssl_host_state_delegate.cc", "libcef/browser/ssl_host_state_delegate.h", "libcef/browser/ssl_info_impl.cc", "libcef/browser/ssl_info_impl.h", + "libcef/browser/ssl_status_impl.cc", + "libcef/browser/ssl_status_impl.h", "libcef/browser/storage_partition_proxy.cc", "libcef/browser/storage_partition_proxy.h", "libcef/browser/stream_impl.cc", @@ -396,6 +396,10 @@ static_library("libcef_static") { "libcef/browser/thread_util.h", "libcef/browser/web_plugin_impl.cc", "libcef/browser/web_plugin_impl.h", + "libcef/browser/x509_certificate_impl.cc", + "libcef/browser/x509_certificate_impl.h", + "libcef/browser/x509_cert_principal_impl.cc", + "libcef/browser/x509_cert_principal_impl.h", "libcef/browser/xml_reader_impl.cc", "libcef/browser/xml_reader_impl.h", "libcef/browser/zip_reader_impl.cc", diff --git a/cef_paths.gypi b/cef_paths.gypi index 13338270d..edfc7c132 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -61,6 +61,7 @@ 'include/cef_response_filter.h', 'include/cef_scheme.h', 'include/cef_ssl_info.h', + 'include/cef_ssl_status.h', 'include/cef_stream.h', 'include/cef_string_visitor.h', 'include/cef_task.h', @@ -69,6 +70,7 @@ 'include/cef_v8.h', 'include/cef_values.h', 'include/cef_web_plugin.h', + 'include/cef_x509_certificate.h', 'include/cef_xml_reader.h', 'include/cef_zip_reader.h', 'include/test/cef_translator_test.h', @@ -143,6 +145,7 @@ 'include/capi/cef_response_filter_capi.h', 'include/capi/cef_scheme_capi.h', 'include/capi/cef_ssl_info_capi.h', + 'include/capi/cef_ssl_status_capi.h', 'include/capi/cef_stream_capi.h', 'include/capi/cef_string_visitor_capi.h', 'include/capi/cef_task_capi.h', @@ -151,6 +154,7 @@ 'include/capi/cef_v8_capi.h', 'include/capi/cef_values_capi.h', 'include/capi/cef_web_plugin_capi.h', + 'include/capi/cef_x509_certificate_capi.h', 'include/capi/cef_xml_reader_capi.h', 'include/capi/cef_zip_reader_capi.h', 'include/capi/test/cef_translator_test_capi.h', @@ -344,10 +348,10 @@ 'libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h', 'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.cc', 'libcef_dll/ctocpp/run_file_dialog_callback_ctocpp.h', - 'libcef_dll/cpptoc/sslcert_principal_cpptoc.cc', - 'libcef_dll/cpptoc/sslcert_principal_cpptoc.h', 'libcef_dll/cpptoc/sslinfo_cpptoc.cc', 'libcef_dll/cpptoc/sslinfo_cpptoc.h', + 'libcef_dll/cpptoc/sslstatus_cpptoc.cc', + 'libcef_dll/cpptoc/sslstatus_cpptoc.h', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.cc', 'libcef_dll/ctocpp/scheme_handler_factory_ctocpp.h', 'libcef_dll/cpptoc/scheme_registrar_cpptoc.cc', @@ -418,6 +422,10 @@ 'libcef_dll/ctocpp/views/window_delegate_ctocpp.h', 'libcef_dll/ctocpp/write_handler_ctocpp.cc', 'libcef_dll/ctocpp/write_handler_ctocpp.h', + 'libcef_dll/cpptoc/x509cert_principal_cpptoc.cc', + 'libcef_dll/cpptoc/x509cert_principal_cpptoc.h', + 'libcef_dll/cpptoc/x509certificate_cpptoc.cc', + 'libcef_dll/cpptoc/x509certificate_cpptoc.h', 'libcef_dll/cpptoc/xml_reader_cpptoc.cc', 'libcef_dll/cpptoc/xml_reader_cpptoc.h', 'libcef_dll/cpptoc/zip_reader_cpptoc.cc', @@ -592,10 +600,10 @@ 'libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h', 'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.cc', 'libcef_dll/cpptoc/run_file_dialog_callback_cpptoc.h', - 'libcef_dll/ctocpp/sslcert_principal_ctocpp.cc', - 'libcef_dll/ctocpp/sslcert_principal_ctocpp.h', 'libcef_dll/ctocpp/sslinfo_ctocpp.cc', 'libcef_dll/ctocpp/sslinfo_ctocpp.h', + 'libcef_dll/ctocpp/sslstatus_ctocpp.cc', + 'libcef_dll/ctocpp/sslstatus_ctocpp.h', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.cc', 'libcef_dll/cpptoc/scheme_handler_factory_cpptoc.h', 'libcef_dll/ctocpp/scheme_registrar_ctocpp.cc', @@ -666,6 +674,10 @@ 'libcef_dll/cpptoc/views/window_delegate_cpptoc.h', 'libcef_dll/cpptoc/write_handler_cpptoc.cc', 'libcef_dll/cpptoc/write_handler_cpptoc.h', + 'libcef_dll/ctocpp/x509cert_principal_ctocpp.cc', + 'libcef_dll/ctocpp/x509cert_principal_ctocpp.h', + 'libcef_dll/ctocpp/x509certificate_ctocpp.cc', + 'libcef_dll/ctocpp/x509certificate_ctocpp.h', 'libcef_dll/ctocpp/xml_reader_ctocpp.cc', 'libcef_dll/ctocpp/xml_reader_ctocpp.h', 'libcef_dll/ctocpp/zip_reader_ctocpp.cc', diff --git a/include/capi/cef_browser_capi.h b/include/capi/cef_browser_capi.h index 9f14e5d1b..bdc0ba714 100644 --- a/include/capi/cef_browser_capi.h +++ b/include/capi/cef_browser_capi.h @@ -700,6 +700,13 @@ typedef struct _cef_browser_host_t { /// void (CEF_CALLBACK *drag_source_system_drag_ended)( struct _cef_browser_host_t* self); + + /// + // Returns the current visible navigation entry for this browser. This + // function can only be called on the UI thread. + /// + struct _cef_navigation_entry_t* (CEF_CALLBACK *get_visible_navigation_entry)( + struct _cef_browser_host_t* self); } cef_browser_host_t; diff --git a/include/capi/cef_life_span_handler_capi.h b/include/capi/cef_life_span_handler_capi.h index 7c1f628ac..dfbe70a74 100644 --- a/include/capi/cef_life_span_handler_capi.h +++ b/include/capi/cef_life_span_handler_capi.h @@ -102,7 +102,7 @@ typedef struct _cef_life_span_handler_t { // has been fired. // // An application should handle top-level owner window close notifications by - // calling cef_browser_host_t::Tryclose_browser() or + // calling cef_browser_host_t::try_close_browser() or // cef_browser_host_t::CloseBrowser(false (0)) instead of allowing the window // to close immediately (see the examples below). This gives CEF an // opportunity to process the 'onbeforeunload' event and optionally cancel the @@ -132,7 +132,7 @@ typedef struct _cef_life_span_handler_t { // The below examples describe what should happen during window close when the // browser is parented to an application-provided top-level window. // - // Example 1: Using cef_browser_host_t::Tryclose_browser(). This is + // Example 1: Using cef_browser_host_t::try_close_browser(). This is // recommended for clients using standard close handling and windows created // on the browser process UI thread. 1. User clicks the window close button // which sends a close notification to diff --git a/include/capi/cef_navigation_entry_capi.h b/include/capi/cef_navigation_entry_capi.h index edd8d2512..ecfbda01b 100644 --- a/include/capi/cef_navigation_entry_capi.h +++ b/include/capi/cef_navigation_entry_capi.h @@ -44,6 +44,7 @@ extern "C" { #endif +struct _cef_sslstatus_t; /// // Structure used to represent an entry in navigation history. @@ -116,6 +117,12 @@ typedef struct _cef_navigation_entry_t { /// int (CEF_CALLBACK *get_http_status_code)( struct _cef_navigation_entry_t* self); + + /// + // Returns the SSL information for this navigation entry. + /// + struct _cef_sslstatus_t* (CEF_CALLBACK *get_sslstatus)( + struct _cef_navigation_entry_t* self); } cef_navigation_entry_t; diff --git a/include/capi/cef_ssl_info_capi.h b/include/capi/cef_ssl_info_capi.h index fe340de7b..e06f30240 100644 --- a/include/capi/cef_ssl_info_capi.h +++ b/include/capi/cef_ssl_info_capi.h @@ -40,83 +40,13 @@ #include "include/capi/cef_base_capi.h" #include "include/capi/cef_values_capi.h" +#include "include/capi/cef_x509_certificate_capi.h" #ifdef __cplusplus extern "C" { #endif -/// -// Structure representing the issuer or subject field of an X.509 certificate. -/// -typedef struct _cef_sslcert_principal_t { - /// - // Base structure. - /// - cef_base_t base; - - /// - // Returns a name that can be used to represent the issuer. It tries in this - // order: CN, O and OU and returns the first non-NULL one found. - /// - // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_display_name)( - struct _cef_sslcert_principal_t* self); - - /// - // Returns the common name. - /// - // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_common_name)( - struct _cef_sslcert_principal_t* self); - - /// - // Returns the locality name. - /// - // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_locality_name)( - struct _cef_sslcert_principal_t* self); - - /// - // Returns the state or province name. - /// - // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_state_or_province_name)( - struct _cef_sslcert_principal_t* self); - - /// - // Returns the country name. - /// - // The resulting string must be freed by calling cef_string_userfree_free(). - cef_string_userfree_t (CEF_CALLBACK *get_country_name)( - struct _cef_sslcert_principal_t* self); - - /// - // Retrieve the list of street addresses. - /// - void (CEF_CALLBACK *get_street_addresses)( - struct _cef_sslcert_principal_t* self, cef_string_list_t addresses); - - /// - // Retrieve the list of organization names. - /// - void (CEF_CALLBACK *get_organization_names)( - struct _cef_sslcert_principal_t* self, cef_string_list_t names); - - /// - // Retrieve the list of organization unit names. - /// - void (CEF_CALLBACK *get_organization_unit_names)( - struct _cef_sslcert_principal_t* self, cef_string_list_t names); - - /// - // Retrieve the list of domain components. - /// - void (CEF_CALLBACK *get_domain_components)( - struct _cef_sslcert_principal_t* self, cef_string_list_t components); -} cef_sslcert_principal_t; - - /// // Structure representing SSL information. /// @@ -134,85 +64,24 @@ typedef struct _cef_sslinfo_t { struct _cef_sslinfo_t* self); /// - // Returns true (1) if the certificate status has any error, major or minor. + // Returns the X.509 certificate. /// - int (CEF_CALLBACK *is_cert_status_error)(struct _cef_sslinfo_t* self); - - /// - // Returns true (1) if the certificate status represents only minor errors - // (e.g. failure to verify certificate revocation). - /// - int (CEF_CALLBACK *is_cert_status_minor_error)(struct _cef_sslinfo_t* self); - - /// - // Returns the subject of the X.509 certificate. For HTTPS server certificates - // this represents the web server. The common name of the subject should - // match the host name of the web server. - /// - struct _cef_sslcert_principal_t* (CEF_CALLBACK *get_subject)( + struct _cef_x509certificate_t* (CEF_CALLBACK *get_x509certificate)( struct _cef_sslinfo_t* self); - - /// - // Returns the issuer of the X.509 certificate. - /// - struct _cef_sslcert_principal_t* (CEF_CALLBACK *get_issuer)( - struct _cef_sslinfo_t* self); - - /// - // Returns the DER encoded serial number for the X.509 certificate. The value - // possibly includes a leading 00 byte. - /// - struct _cef_binary_value_t* (CEF_CALLBACK *get_serial_number)( - struct _cef_sslinfo_t* self); - - /// - // Returns the date before which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - /// - cef_time_t (CEF_CALLBACK *get_valid_start)(struct _cef_sslinfo_t* self); - - /// - // Returns the date after which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - /// - cef_time_t (CEF_CALLBACK *get_valid_expiry)(struct _cef_sslinfo_t* self); - - /// - // Returns the DER encoded data for the X.509 certificate. - /// - struct _cef_binary_value_t* (CEF_CALLBACK *get_derencoded)( - struct _cef_sslinfo_t* self); - - /// - // Returns the PEM encoded data for the X.509 certificate. - /// - struct _cef_binary_value_t* (CEF_CALLBACK *get_pemencoded)( - struct _cef_sslinfo_t* self); - - /// - // Returns the number of certificates in the issuer chain. If 0, the - // certificate is self-signed. - /// - size_t (CEF_CALLBACK *get_issuer_chain_size)(struct _cef_sslinfo_t* self); - - /// - // Returns the DER encoded data for the certificate issuer chain. If we failed - // to encode a certificate in the chain it is still present in the array but - // is an NULL string. - /// - void (CEF_CALLBACK *get_derencoded_issuer_chain)(struct _cef_sslinfo_t* self, - size_t* chainCount, struct _cef_binary_value_t** chain); - - /// - // Returns the PEM encoded data for the certificate issuer chain. If we failed - // to encode a certificate in the chain it is still present in the array but - // is an NULL string. - /// - void (CEF_CALLBACK *get_pemencoded_issuer_chain)(struct _cef_sslinfo_t* self, - size_t* chainCount, struct _cef_binary_value_t** chain); } cef_sslinfo_t; +/// +// Returns true (1) if the certificate status has any error, major or minor. +/// +CEF_EXPORT int cef_is_cert_status_error(cef_cert_status_t status); + +/// +// Returns true (1) if the certificate status represents only minor errors (e.g. +// failure to verify certificate revocation). +/// +CEF_EXPORT int cef_is_cert_status_minor_error(cef_cert_status_t status); + #ifdef __cplusplus } #endif diff --git a/include/capi/cef_ssl_status_capi.h b/include/capi/cef_ssl_status_capi.h new file mode 100644 index 000000000..5013c97ae --- /dev/null +++ b/include/capi/cef_ssl_status_capi.h @@ -0,0 +1,95 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * 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. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT +// OWNER OR 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct _cef_x509certificate_t; + +/// +// Structure representing the SSL information for a navigation entry. +/// +typedef struct _cef_sslstatus_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns true (1) if the status is related to a secure SSL/TLS connection. + /// + int (CEF_CALLBACK *is_secure_connection)(struct _cef_sslstatus_t* self); + + /// + // Returns a bitmask containing any and all problems verifying the server + // certificate. + /// + cef_cert_status_t (CEF_CALLBACK *get_cert_status)( + struct _cef_sslstatus_t* self); + + /// + // Returns the SSL version used for the SSL connection. + /// + cef_ssl_version_t (CEF_CALLBACK *get_sslversion)( + struct _cef_sslstatus_t* self); + + /// + // Returns a bitmask containing the page security content status. + /// + cef_ssl_content_status_t (CEF_CALLBACK *get_content_status)( + struct _cef_sslstatus_t* self); + + /// + // Returns the X.509 certificate. + /// + struct _cef_x509certificate_t* (CEF_CALLBACK *get_x509certificate)( + struct _cef_sslstatus_t* self); +} cef_sslstatus_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_SSL_STATUS_CAPI_H_ diff --git a/include/capi/cef_x509_certificate_capi.h b/include/capi/cef_x509_certificate_capi.h new file mode 100644 index 000000000..251f50a47 --- /dev/null +++ b/include/capi/cef_x509_certificate_capi.h @@ -0,0 +1,208 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * 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. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT +// OWNER OR 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. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool and should not edited +// by hand. See the translator.README.txt file in the tools directory for +// more information. +// + +#ifndef CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_ +#define CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_ +#pragma once + +#include "include/capi/cef_base_capi.h" +#include "include/capi/cef_values_capi.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +/// +// Structure representing the issuer or subject field of an X.509 certificate. +/// +typedef struct _cef_x509cert_principal_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns a name that can be used to represent the issuer. It tries in this + // order: Common Name (CN), Organization Name (O) and Organizational Unit Name + // (OU) and returns the first non-NULL one found. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_display_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the common name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_common_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the locality name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_locality_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the state or province name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_state_or_province_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Returns the country name. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_country_name)( + struct _cef_x509cert_principal_t* self); + + /// + // Retrieve the list of street addresses. + /// + void (CEF_CALLBACK *get_street_addresses)( + struct _cef_x509cert_principal_t* self, cef_string_list_t addresses); + + /// + // Retrieve the list of organization names. + /// + void (CEF_CALLBACK *get_organization_names)( + struct _cef_x509cert_principal_t* self, cef_string_list_t names); + + /// + // Retrieve the list of organization unit names. + /// + void (CEF_CALLBACK *get_organization_unit_names)( + struct _cef_x509cert_principal_t* self, cef_string_list_t names); + + /// + // Retrieve the list of domain components. + /// + void (CEF_CALLBACK *get_domain_components)( + struct _cef_x509cert_principal_t* self, cef_string_list_t components); +} cef_x509cert_principal_t; + + +/// +// Structure representing a X.509 certificate. +/// +typedef struct _cef_x509certificate_t { + /// + // Base structure. + /// + cef_base_t base; + + /// + // Returns the subject of the X.509 certificate. For HTTPS server certificates + // this represents the web server. The common name of the subject should + // match the host name of the web server. + /// + struct _cef_x509cert_principal_t* (CEF_CALLBACK *get_subject)( + struct _cef_x509certificate_t* self); + + /// + // Returns the issuer of the X.509 certificate. + /// + struct _cef_x509cert_principal_t* (CEF_CALLBACK *get_issuer)( + struct _cef_x509certificate_t* self); + + /// + // Returns the DER encoded serial number for the X.509 certificate. The value + // possibly includes a leading 00 byte. + /// + struct _cef_binary_value_t* (CEF_CALLBACK *get_serial_number)( + struct _cef_x509certificate_t* self); + + /// + // Returns the date before which the X.509 certificate is invalid. + // CefTime.GetTimeT() will return 0 if no date was specified. + /// + cef_time_t (CEF_CALLBACK *get_valid_start)( + struct _cef_x509certificate_t* self); + + /// + // Returns the date after which the X.509 certificate is invalid. + // CefTime.GetTimeT() will return 0 if no date was specified. + /// + cef_time_t (CEF_CALLBACK *get_valid_expiry)( + struct _cef_x509certificate_t* self); + + /// + // Returns the DER encoded data for the X.509 certificate. + /// + struct _cef_binary_value_t* (CEF_CALLBACK *get_derencoded)( + struct _cef_x509certificate_t* self); + + /// + // Returns the PEM encoded data for the X.509 certificate. + /// + struct _cef_binary_value_t* (CEF_CALLBACK *get_pemencoded)( + struct _cef_x509certificate_t* self); + + /// + // Returns the number of certificates in the issuer chain. If 0, the + // certificate is self-signed. + /// + size_t (CEF_CALLBACK *get_issuer_chain_size)( + struct _cef_x509certificate_t* self); + + /// + // Returns the DER encoded data for the certificate issuer chain. If we failed + // to encode a certificate in the chain it is still present in the array but + // is an NULL string. + /// + void (CEF_CALLBACK *get_derencoded_issuer_chain)( + struct _cef_x509certificate_t* self, size_t* chainCount, + struct _cef_binary_value_t** chain); + + /// + // Returns the PEM encoded data for the certificate issuer chain. If we failed + // to encode a certificate in the chain it is still present in the array but + // is an NULL string. + /// + void (CEF_CALLBACK *get_pemencoded_issuer_chain)( + struct _cef_x509certificate_t* self, size_t* chainCount, + struct _cef_binary_value_t** chain); +} cef_x509certificate_t; + + +#ifdef __cplusplus +} +#endif + +#endif // CEF_INCLUDE_CAPI_CEF_X509_CERTIFICATE_CAPI_H_ diff --git a/include/cef_browser.h b/include/cef_browser.h index 3f6e6c088..eda660f1a 100644 --- a/include/cef_browser.h +++ b/include/cef_browser.h @@ -753,6 +753,13 @@ class CefBrowserHost : public virtual CefBase { /// /*--cef()--*/ virtual void DragSourceSystemDragEnded() =0; + + /// + // Returns the current visible navigation entry for this browser. This method + // can only be called on the UI thread. + /// + /*--cef()--*/ + virtual CefRefPtr GetVisibleNavigationEntry() =0; }; #endif // CEF_INCLUDE_CEF_BROWSER_H_ diff --git a/include/cef_navigation_entry.h b/include/cef_navigation_entry.h index 211351f89..8e8e22ee6 100644 --- a/include/cef_navigation_entry.h +++ b/include/cef_navigation_entry.h @@ -40,6 +40,8 @@ #include "include/cef_base.h" +class CefSSLStatus; + /// // Class used to represent an entry in navigation history. /// @@ -108,6 +110,12 @@ class CefNavigationEntry : public virtual CefBase { /// /*--cef()--*/ virtual int GetHttpStatusCode() =0; + + /// + // Returns the SSL information for this navigation entry. + /// + /*--cef()--*/ + virtual CefRefPtr GetSSLStatus() =0; }; #endif // CEF_INCLUDE_CEF_NAVIGATION_ENTRY_H_ diff --git a/include/cef_ssl_info.h b/include/cef_ssl_info.h index 1ebc894ea..732171889 100644 --- a/include/cef_ssl_info.h +++ b/include/cef_ssl_info.h @@ -38,72 +38,10 @@ #define CEF_INCLUDE_CEF_SSL_INFO_H_ #pragma once -#include - #include "include/cef_base.h" #include "include/cef_values.h" -/// -// Class representing the issuer or subject field of an X.509 certificate. -/// -/*--cef(source=library)--*/ -class CefSSLCertPrincipal : public virtual CefBase { - public: - /// - // Returns a name that can be used to represent the issuer. It tries in this - // order: CN, O and OU and returns the first non-empty one found. - /// - /*--cef()--*/ - virtual CefString GetDisplayName() =0; - - /// - // Returns the common name. - /// - /*--cef()--*/ - virtual CefString GetCommonName() =0; - - /// - // Returns the locality name. - /// - /*--cef()--*/ - virtual CefString GetLocalityName() =0; - - /// - // Returns the state or province name. - /// - /*--cef()--*/ - virtual CefString GetStateOrProvinceName() =0; - - /// - // Returns the country name. - /// - /*--cef()--*/ - virtual CefString GetCountryName() =0; - - /// - // Retrieve the list of street addresses. - /// - /*--cef()--*/ - virtual void GetStreetAddresses(std::vector& addresses) =0; - - /// - // Retrieve the list of organization names. - /// - /*--cef()--*/ - virtual void GetOrganizationNames(std::vector& names) =0; - - /// - // Retrieve the list of organization unit names. - /// - /*--cef()--*/ - virtual void GetOrganizationUnitNames(std::vector& names) =0; - - /// - // Retrieve the list of domain components. - /// - /*--cef()--*/ - virtual void GetDomainComponents(std::vector& components) =0; -}; +#include "include/cef_x509_certificate.h" /// // Class representing SSL information. @@ -111,8 +49,6 @@ class CefSSLCertPrincipal : public virtual CefBase { /*--cef(source=library)--*/ class CefSSLInfo : public virtual CefBase { public: - typedef std::vector > IssuerChainBinaryList; - /// // Returns a bitmask containing any and all problems verifying the server // certificate. @@ -121,87 +57,24 @@ class CefSSLInfo : public virtual CefBase { virtual cef_cert_status_t GetCertStatus() =0; /// - // Returns true if the certificate status has any error, major or minor. + // Returns the X.509 certificate. /// /*--cef()--*/ - virtual bool IsCertStatusError() =0; - - /// - // Returns true if the certificate status represents only minor errors - // (e.g. failure to verify certificate revocation). - /// - /*--cef()--*/ - virtual bool IsCertStatusMinorError() =0; - - /// - // Returns the subject of the X.509 certificate. For HTTPS server - // certificates this represents the web server. The common name of the - // subject should match the host name of the web server. - /// - /*--cef()--*/ - virtual CefRefPtr GetSubject() =0; - - /// - // Returns the issuer of the X.509 certificate. - /// - /*--cef()--*/ - virtual CefRefPtr GetIssuer() =0; - - /// - // Returns the DER encoded serial number for the X.509 certificate. The value - // possibly includes a leading 00 byte. - /// - /*--cef()--*/ - virtual CefRefPtr GetSerialNumber() =0; - - /// - // Returns the date before which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - /// - /*--cef()--*/ - virtual CefTime GetValidStart() =0; - - /// - // Returns the date after which the X.509 certificate is invalid. - // CefTime.GetTimeT() will return 0 if no date was specified. - /// - /*--cef()--*/ - virtual CefTime GetValidExpiry() =0; - - /// - // Returns the DER encoded data for the X.509 certificate. - /// - /*--cef()--*/ - virtual CefRefPtr GetDEREncoded() =0; - - /// - // Returns the PEM encoded data for the X.509 certificate. - /// - /*--cef()--*/ - virtual CefRefPtr GetPEMEncoded() =0; - - /// - // Returns the number of certificates in the issuer chain. - // If 0, the certificate is self-signed. - /// - /*--cef()--*/ - virtual size_t GetIssuerChainSize() =0; - - /// - // Returns the DER encoded data for the certificate issuer chain. - // If we failed to encode a certificate in the chain it is still - // present in the array but is an empty string. - /// - /*--cef(count_func=chain:GetIssuerChainSize)--*/ - virtual void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) =0; - - /// - // Returns the PEM encoded data for the certificate issuer chain. - // If we failed to encode a certificate in the chain it is still - // present in the array but is an empty string. - /// - /*--cef(count_func=chain:GetIssuerChainSize)--*/ - virtual void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) =0; + virtual CefRefPtr GetX509Certificate() =0; }; + +/// +// Returns true if the certificate status has any error, major or minor. +/// +/*--cef()--*/ +bool CefIsCertStatusError(cef_cert_status_t status); + +/// +// Returns true if the certificate status represents only minor errors +// (e.g. failure to verify certificate revocation). +/// +/*--cef()--*/ +bool CefIsCertStatusMinorError(cef_cert_status_t status); + #endif // CEF_INCLUDE_CEF_SSL_INFO_H_ diff --git a/include/cef_ssl_status.h b/include/cef_ssl_status.h new file mode 100644 index 000000000..e46c4331e --- /dev/null +++ b/include/cef_ssl_status.h @@ -0,0 +1,84 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * 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. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT +// OWNER OR 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. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_SSL_STATUS_H_ +#define CEF_INCLUDE_CEF_SSL_STATUS_H_ +#pragma once + +#include "include/cef_base.h" +#include "include/cef_values.h" + +class CefX509Certificate; + +/// +// Class representing the SSL information for a navigation entry. +/// +/*--cef(source=library)--*/ +class CefSSLStatus : public virtual CefBase { + public: + /// + // Returns true if the status is related to a secure SSL/TLS connection. + /// + /*--cef()--*/ + virtual bool IsSecureConnection() =0; + + /// + // Returns a bitmask containing any and all problems verifying the server + // certificate. + /// + /*--cef(default_retval=CERT_STATUS_NONE)--*/ + virtual cef_cert_status_t GetCertStatus() =0; + + /// + // Returns the SSL version used for the SSL connection. + /// + /*--cef(default_retval=SSL_CONNECTION_VERSION_UNKNOWN)--*/ + virtual cef_ssl_version_t GetSSLVersion() =0; + + /// + // Returns a bitmask containing the page security content status. + /// + /*--cef(default_retval=SSL_CONTENT_NORMAL_CONTENT)--*/ + virtual cef_ssl_content_status_t GetContentStatus() =0; + + /// + // Returns the X.509 certificate. + /// + /*--cef()--*/ + virtual CefRefPtr GetX509Certificate() =0; +}; + +#endif // CEF_INCLUDE_CEF_SSL_STATUS_H_ diff --git a/include/cef_x509_certificate.h b/include/cef_x509_certificate.h new file mode 100644 index 000000000..f036ab5ed --- /dev/null +++ b/include/cef_x509_certificate.h @@ -0,0 +1,188 @@ +// Copyright (c) 2016 Marshall A. Greenblatt. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * 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. +// * Neither the name of Google Inc. nor the name Chromium Embedded +// Framework 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 THE COPYRIGHT HOLDERS AND 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 THE COPYRIGHT +// OWNER OR 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. +// +// --------------------------------------------------------------------------- +// +// The contents of this file must follow a specific format in order to +// support the CEF translator tool. See the translator.README.txt file in the +// tools directory for more information. +// + +#ifndef CEF_INCLUDE_CEF_X509_CERTIFICATE_H_ +#define CEF_INCLUDE_CEF_X509_CERTIFICATE_H_ +#pragma once + +#include + +#include "include/cef_base.h" +#include "include/cef_values.h" + +/// +// Class representing the issuer or subject field of an X.509 certificate. +/// +/*--cef(source=library)--*/ +class CefX509CertPrincipal : public virtual CefBase { + public: + /// + // Returns a name that can be used to represent the issuer. It tries in this + // order: Common Name (CN), Organization Name (O) and Organizational Unit + // Name (OU) and returns the first non-empty one found. + /// + /*--cef()--*/ + virtual CefString GetDisplayName() =0; + + /// + // Returns the common name. + /// + /*--cef()--*/ + virtual CefString GetCommonName() =0; + + /// + // Returns the locality name. + /// + /*--cef()--*/ + virtual CefString GetLocalityName() =0; + + /// + // Returns the state or province name. + /// + /*--cef()--*/ + virtual CefString GetStateOrProvinceName() =0; + + /// + // Returns the country name. + /// + /*--cef()--*/ + virtual CefString GetCountryName() =0; + + /// + // Retrieve the list of street addresses. + /// + /*--cef()--*/ + virtual void GetStreetAddresses(std::vector& addresses) =0; + + /// + // Retrieve the list of organization names. + /// + /*--cef()--*/ + virtual void GetOrganizationNames(std::vector& names) =0; + + /// + // Retrieve the list of organization unit names. + /// + /*--cef()--*/ + virtual void GetOrganizationUnitNames(std::vector& names) =0; + + /// + // Retrieve the list of domain components. + /// + /*--cef()--*/ + virtual void GetDomainComponents(std::vector& components) =0; +}; + +/// +// Class representing a X.509 certificate. +/// +/*--cef(source=library)--*/ +class CefX509Certificate : public virtual CefBase { + public: + typedef std::vector > IssuerChainBinaryList; + + /// + // Returns the subject of the X.509 certificate. For HTTPS server + // certificates this represents the web server. The common name of the + // subject should match the host name of the web server. + /// + /*--cef()--*/ + virtual CefRefPtr GetSubject() =0; + + /// + // Returns the issuer of the X.509 certificate. + /// + /*--cef()--*/ + virtual CefRefPtr GetIssuer() =0; + + /// + // Returns the DER encoded serial number for the X.509 certificate. The value + // possibly includes a leading 00 byte. + /// + /*--cef()--*/ + virtual CefRefPtr GetSerialNumber() =0; + + /// + // Returns the date before which the X.509 certificate is invalid. + // CefTime.GetTimeT() will return 0 if no date was specified. + /// + /*--cef()--*/ + virtual CefTime GetValidStart() =0; + + /// + // Returns the date after which the X.509 certificate is invalid. + // CefTime.GetTimeT() will return 0 if no date was specified. + /// + /*--cef()--*/ + virtual CefTime GetValidExpiry() =0; + + /// + // Returns the DER encoded data for the X.509 certificate. + /// + /*--cef()--*/ + virtual CefRefPtr GetDEREncoded() =0; + + /// + // Returns the PEM encoded data for the X.509 certificate. + /// + /*--cef()--*/ + virtual CefRefPtr GetPEMEncoded() =0; + + /// + // Returns the number of certificates in the issuer chain. + // If 0, the certificate is self-signed. + /// + /*--cef()--*/ + virtual size_t GetIssuerChainSize() =0; + + /// + // Returns the DER encoded data for the certificate issuer chain. + // If we failed to encode a certificate in the chain it is still + // present in the array but is an empty string. + /// + /*--cef(count_func=chain:GetIssuerChainSize)--*/ + virtual void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) =0; + + /// + // Returns the PEM encoded data for the certificate issuer chain. + // If we failed to encode a certificate in the chain it is still + // present in the array but is an empty string. + /// + /*--cef(count_func=chain:GetIssuerChainSize)--*/ + virtual void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) =0; +}; + +#endif // CEF_INCLUDE_CEF_X509_CERTIFICATE_H_ diff --git a/include/internal/cef_types.h b/include/internal/cef_types.h index f4e053b50..77d8605fc 100644 --- a/include/internal/cef_types.h +++ b/include/internal/cef_types.h @@ -2636,6 +2636,27 @@ typedef enum { CEF_MENU_ANCHOR_BOTTOMCENTER, } cef_menu_anchor_position_t; +// Supported SSL version values. See net/ssl/ssl_connection_status_flags.h +// for more information. +typedef enum { + SSL_CONNECTION_VERSION_UNKNOWN = 0, // Unknown SSL version. + SSL_CONNECTION_VERSION_SSL2 = 1, + SSL_CONNECTION_VERSION_SSL3 = 2, + SSL_CONNECTION_VERSION_TLS1 = 3, + SSL_CONNECTION_VERSION_TLS1_1 = 4, + SSL_CONNECTION_VERSION_TLS1_2 = 5, + // Reserve 6 for TLS 1.3. + SSL_CONNECTION_VERSION_QUIC = 7, +} cef_ssl_version_t; + +// Supported SSL content status flags. See content/public/common/ssl_status.h +// for more information. +typedef enum { + SSL_CONTENT_NORMAL_CONTENT = 0, + SSL_CONTENT_DISPLAYED_INSECURE_CONTENT = 1 << 0, + SSL_CONTENT_RAN_INSECURE_CONTENT = 1 << 1, +} cef_ssl_content_status_t; + #ifdef __cplusplus } #endif diff --git a/libcef/browser/browser_host_impl.cc b/libcef/browser/browser_host_impl.cc index e41023815..8911d7082 100644 --- a/libcef/browser/browser_host_impl.cc +++ b/libcef/browser/browser_host_impl.cc @@ -893,6 +893,22 @@ void CefBrowserHostImpl::GetNavigationEntries( } } +CefRefPtr CefBrowserHostImpl::GetVisibleNavigationEntry() { + if (!CEF_CURRENTLY_ON_UIT()) { + NOTREACHED() << "called on invalid thread"; + return nullptr; + } + + content::NavigationEntry* entry = nullptr; + if (web_contents()) + entry = web_contents()->GetController().GetVisibleEntry(); + + if (!entry) + return nullptr; + + return new CefNavigationEntryImpl(entry); +} + void CefBrowserHostImpl::SetMouseCursorChangeDisabled(bool disabled) { base::AutoLock lock_scope(state_lock_); mouse_cursor_change_disabled_ = disabled; diff --git a/libcef/browser/browser_host_impl.h b/libcef/browser/browser_host_impl.h index e76dfb3d9..9c8e09422 100644 --- a/libcef/browser/browser_host_impl.h +++ b/libcef/browser/browser_host_impl.h @@ -218,6 +218,7 @@ class CefBrowserHostImpl : public CefBrowserHost, void DragTargetDrop(const CefMouseEvent& event) override; void DragSourceSystemDragEnded() override; void DragSourceEndedAt(int x, int y, DragOperationsMask op) override; + CefRefPtr GetVisibleNavigationEntry() override; // CefBrowser methods. CefRefPtr GetHost() override; diff --git a/libcef/browser/navigation_entry_impl.cc b/libcef/browser/navigation_entry_impl.cc index 76215231a..74947bb30 100644 --- a/libcef/browser/navigation_entry_impl.cc +++ b/libcef/browser/navigation_entry_impl.cc @@ -4,6 +4,7 @@ #include "libcef/browser/navigation_entry_impl.h" +#include "libcef/browser/ssl_status_impl.h" #include "libcef/common/time_util.h" #include "content/public/browser/navigation_entry.h" @@ -62,3 +63,9 @@ int CefNavigationEntryImpl::GetHttpStatusCode() { CEF_VALUE_VERIFY_RETURN(false, 0); return const_value().GetHttpStatusCode(); } + +CefRefPtr CefNavigationEntryImpl::GetSSLStatus() { + CEF_VALUE_VERIFY_RETURN(false, nullptr); + return new CefSSLStatusImpl(const_value().GetSSL()); +} + diff --git a/libcef/browser/navigation_entry_impl.h b/libcef/browser/navigation_entry_impl.h index ab808e30e..23d10ceea 100644 --- a/libcef/browser/navigation_entry_impl.h +++ b/libcef/browser/navigation_entry_impl.h @@ -29,6 +29,7 @@ class CefNavigationEntryImpl bool HasPostData() override; CefTime GetCompletionTime() override; int GetHttpStatusCode() override; + CefRefPtr GetSSLStatus() override; private: DISALLOW_COPY_AND_ASSIGN(CefNavigationEntryImpl); diff --git a/libcef/browser/ssl_info_impl.cc b/libcef/browser/ssl_info_impl.cc index cfa31a205..5bd2e2b94 100644 --- a/libcef/browser/ssl_info_impl.cc +++ b/libcef/browser/ssl_info_impl.cc @@ -3,121 +3,30 @@ // can be found in the LICENSE file. #include "libcef/browser/ssl_info_impl.h" -#include "libcef/browser/ssl_cert_principal_impl.h" -#include "libcef/common/time_util.h" +#include "libcef/browser/x509_certificate_impl.h" #include "net/cert/cert_status_flags.h" -#include "net/cert/x509_certificate.h" - -namespace { - -void EncodeCertificate( - const net::X509Certificate::OSCertHandle& os_handle, - CefRefPtr& der_encoded, - CefRefPtr& pem_encoded) { - std::string encoded; - if (net::X509Certificate::GetDEREncoded(os_handle, &encoded)) { - der_encoded = CefBinaryValue::Create(encoded.c_str(), - encoded.size()); - } - encoded.clear(); - if (net::X509Certificate::GetPEMEncoded(os_handle, &encoded)) { - pem_encoded = CefBinaryValue::Create(encoded.c_str(), - encoded.size()); - } -} - -} // namespace CefSSLInfoImpl::CefSSLInfoImpl(const net::SSLInfo& value) : cert_status_(CERT_STATUS_NONE) { + cert_status_ = static_cast(value.cert_status); if (value.cert.get()) { - cert_status_ = static_cast(value.cert_status); - - subject_ = new CefSSLCertPrincipalImpl(value.cert->subject()); - issuer_ = new CefSSLCertPrincipalImpl(value.cert->issuer()); - - const std::string& serial_number = value.cert->serial_number(); - serial_number_ = CefBinaryValue::Create(serial_number.c_str(), - serial_number.size()); - - const base::Time& valid_start = value.cert->valid_start(); - if (!valid_start.is_null()) - cef_time_from_basetime(valid_start, valid_start_); - - const base::Time& valid_expiry = value.cert->valid_expiry(); - if (!valid_expiry.is_null()) - cef_time_from_basetime(valid_expiry, valid_expiry_); - - net::X509Certificate::OSCertHandle os_handle = value.cert->os_cert_handle(); - if (os_handle) - EncodeCertificate(os_handle, der_encoded_, pem_encoded_); - - const net::X509Certificate::OSCertHandles& issuer_chain = - value.cert->GetIntermediateCertificates(); - for (net::X509Certificate::OSCertHandles::const_iterator it = - issuer_chain.begin(); it != issuer_chain.end(); it++) { - CefRefPtr der_encoded, pem_encoded; - EncodeCertificate(*it, der_encoded, pem_encoded); - - // Add each to the chain, even if one conversion unexpectedly failed. - // GetIssuerChainSize depends on these being the same length. - der_encoded_issuer_chain_.push_back(der_encoded); - pem_encoded_issuer_chain_.push_back(pem_encoded); - } + cert_ = new CefX509CertificateImpl(*value.cert); } } cef_cert_status_t CefSSLInfoImpl::GetCertStatus() { - return cert_status_; + return cert_status_; } -bool CefSSLInfoImpl::IsCertStatusError() { - return net::IsCertStatusError(cert_status_); +CefRefPtr CefSSLInfoImpl::GetX509Certificate() { + return cert_; } -bool CefSSLInfoImpl::IsCertStatusMinorError() { - return net::IsCertStatusMinorError(cert_status_); +bool CefIsCertStatusError(cef_cert_status_t status) { + return net::IsCertStatusError(status); } -CefRefPtr CefSSLInfoImpl::GetSubject() { - return subject_; -} - -CefRefPtr CefSSLInfoImpl::GetIssuer() { - return issuer_; -} - -CefRefPtr CefSSLInfoImpl::GetSerialNumber() { - return serial_number_; -} - -CefTime CefSSLInfoImpl::GetValidStart() { - return valid_start_; -} - -CefTime CefSSLInfoImpl::GetValidExpiry() { - return valid_expiry_; -} - -CefRefPtr CefSSLInfoImpl::GetDEREncoded() { - return der_encoded_; -} - -CefRefPtr CefSSLInfoImpl::GetPEMEncoded() { - return pem_encoded_; -} - -size_t CefSSLInfoImpl::GetIssuerChainSize() { - return der_encoded_issuer_chain_.size(); -} - -void CefSSLInfoImpl::GetDEREncodedIssuerChain( - CefSSLInfo::IssuerChainBinaryList& chain) { - chain = der_encoded_issuer_chain_; -} - -void CefSSLInfoImpl::GetPEMEncodedIssuerChain( - CefSSLInfo::IssuerChainBinaryList& chain) { - chain = pem_encoded_issuer_chain_; +bool CefIsCertStatusMinorError(cef_cert_status_t status) { + return net::IsCertStatusMinorError(status); } diff --git a/libcef/browser/ssl_info_impl.h b/libcef/browser/ssl_info_impl.h index aa3a9c8fa..f1a912443 100644 --- a/libcef/browser/ssl_info_impl.h +++ b/libcef/browser/ssl_info_impl.h @@ -17,30 +17,11 @@ class CefSSLInfoImpl : public CefSSLInfo { // CefSSLInfo methods. cef_cert_status_t GetCertStatus() override; - bool IsCertStatusError() override; - bool IsCertStatusMinorError() override; - CefRefPtr GetSubject() override; - CefRefPtr GetIssuer() override; - CefRefPtr GetSerialNumber() override; - CefTime GetValidStart() override; - CefTime GetValidExpiry() override; - CefRefPtr GetDEREncoded() override; - CefRefPtr GetPEMEncoded() override; - size_t GetIssuerChainSize() override; - void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) override; - void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) override; + CefRefPtr GetX509Certificate() override; private: cef_cert_status_t cert_status_; - CefRefPtr subject_; - CefRefPtr issuer_; - CefRefPtr serial_number_; - CefTime valid_start_; - CefTime valid_expiry_; - CefRefPtr der_encoded_; - CefRefPtr pem_encoded_; - IssuerChainBinaryList der_encoded_issuer_chain_; - IssuerChainBinaryList pem_encoded_issuer_chain_; + CefRefPtr cert_; IMPLEMENT_REFCOUNTING(CefSSLInfoImpl); DISALLOW_COPY_AND_ASSIGN(CefSSLInfoImpl); diff --git a/libcef/browser/ssl_status_impl.cc b/libcef/browser/ssl_status_impl.cc new file mode 100644 index 000000000..1ed4a62f4 --- /dev/null +++ b/libcef/browser/ssl_status_impl.cc @@ -0,0 +1,45 @@ +// 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. + +#include "libcef/browser/ssl_status_impl.h" + +#include "libcef/browser/x509_certificate_impl.h" + +#include "content/public/browser/cert_store.h" +#include "net/ssl/ssl_connection_status_flags.h" + +CefSSLStatusImpl::CefSSLStatusImpl(const content::SSLStatus& value) { + cert_status_ = static_cast(value.cert_status); + content_status_ = static_cast(value.content_status); + ssl_version_ = static_cast( + net::SSLConnectionStatusToVersion(value.connection_status)); + cert_id_ = value.cert_id; +} + +bool CefSSLStatusImpl::IsSecureConnection() { + // Secure connection if there was a certificate ID in SSLStatus. + return (cert_id_ != 0); +} + +cef_cert_status_t CefSSLStatusImpl::GetCertStatus() { + return cert_status_; +} + +cef_ssl_version_t CefSSLStatusImpl::GetSSLVersion() { + return ssl_version_; +} + +cef_ssl_content_status_t CefSSLStatusImpl::GetContentStatus() { + return content_status_; +} + +CefRefPtr CefSSLStatusImpl::GetX509Certificate() { + if (cert_id_) { + scoped_refptr cert; + content::CertStore::GetInstance()->RetrieveCert(cert_id_, &cert); + if (cert.get()) + return new CefX509CertificateImpl(*cert); + } + return nullptr; +} diff --git a/libcef/browser/ssl_status_impl.h b/libcef/browser/ssl_status_impl.h new file mode 100644 index 000000000..5a07079e6 --- /dev/null +++ b/libcef/browser/ssl_status_impl.h @@ -0,0 +1,35 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_SSL_STATUS_IMPL_H_ +#define CEF_LIBCEF_BROWSER_SSL_STATUS_IMPL_H_ +#pragma once + +#include "include/cef_ssl_status.h" + +#include "content/public/common/ssl_status.h" + +// CefSSLStatus implementation +class CefSSLStatusImpl : public CefSSLStatus { + public: + explicit CefSSLStatusImpl(const content::SSLStatus& value); + + // CefSSLStatus methods. + bool IsSecureConnection() override; + cef_cert_status_t GetCertStatus() override; + cef_ssl_version_t GetSSLVersion() override; + cef_ssl_content_status_t GetContentStatus() override; + CefRefPtr GetX509Certificate() override; + + private: + cef_cert_status_t cert_status_; + cef_ssl_version_t ssl_version_; + cef_ssl_content_status_t content_status_; + int cert_id_; + + IMPLEMENT_REFCOUNTING(CefSSLStatusImpl); + DISALLOW_COPY_AND_ASSIGN(CefSSLStatusImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_SSL_STATUS_IMPL_H_ diff --git a/libcef/browser/ssl_cert_principal_impl.cc b/libcef/browser/x509_cert_principal_impl.cc similarity index 62% rename from libcef/browser/ssl_cert_principal_impl.cc rename to libcef/browser/x509_cert_principal_impl.cc index 62befe29b..cf2f07e4e 100644 --- a/libcef/browser/ssl_cert_principal_impl.cc +++ b/libcef/browser/x509_cert_principal_impl.cc @@ -1,8 +1,8 @@ -// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights +// 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. -#include "libcef/browser/ssl_cert_principal_impl.h" +#include "libcef/browser/x509_cert_principal_impl.h" namespace { @@ -20,47 +20,47 @@ void TransferVector(const std::vector& source, } // namespace -CefSSLCertPrincipalImpl::CefSSLCertPrincipalImpl( +CefX509CertPrincipalImpl::CefX509CertPrincipalImpl( const net::CertPrincipal& value) : value_(value) { } -CefString CefSSLCertPrincipalImpl::GetDisplayName() { +CefString CefX509CertPrincipalImpl::GetDisplayName() { return value_.GetDisplayName(); } -CefString CefSSLCertPrincipalImpl::GetCommonName() { +CefString CefX509CertPrincipalImpl::GetCommonName() { return value_.common_name; } -CefString CefSSLCertPrincipalImpl::GetLocalityName() { +CefString CefX509CertPrincipalImpl::GetLocalityName() { return value_.locality_name; } -CefString CefSSLCertPrincipalImpl::GetStateOrProvinceName() { +CefString CefX509CertPrincipalImpl::GetStateOrProvinceName() { return value_.state_or_province_name; } -CefString CefSSLCertPrincipalImpl::GetCountryName() { +CefString CefX509CertPrincipalImpl::GetCountryName() { return value_.country_name; } -void CefSSLCertPrincipalImpl::GetStreetAddresses( +void CefX509CertPrincipalImpl::GetStreetAddresses( std::vector& addresses) { TransferVector(value_.street_addresses, addresses); } -void CefSSLCertPrincipalImpl::GetOrganizationNames( +void CefX509CertPrincipalImpl::GetOrganizationNames( std::vector& names) { TransferVector(value_.organization_names, names); } -void CefSSLCertPrincipalImpl::GetOrganizationUnitNames( +void CefX509CertPrincipalImpl::GetOrganizationUnitNames( std::vector& names) { TransferVector(value_.organization_unit_names, names); } -void CefSSLCertPrincipalImpl::GetDomainComponents( +void CefX509CertPrincipalImpl::GetDomainComponents( std::vector& components) { TransferVector(value_.domain_components, components); } diff --git a/libcef/browser/ssl_cert_principal_impl.h b/libcef/browser/x509_cert_principal_impl.h similarity index 55% rename from libcef/browser/ssl_cert_principal_impl.h rename to libcef/browser/x509_cert_principal_impl.h index 3d5b95b7a..20b409e4f 100644 --- a/libcef/browser/ssl_cert_principal_impl.h +++ b/libcef/browser/x509_cert_principal_impl.h @@ -1,21 +1,21 @@ -// Copyright (c) 2015 The Chromium Embedded Framework Authors. All rights +// 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. -#ifndef CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_ -#define CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_ +#ifndef CEF_LIBCEF_BROWSER_X509_CERT_PRINCIPAL_IMPL_H_ +#define CEF_LIBCEF_BROWSER_X509_CERT_PRINCIPAL_IMPL_H_ #pragma once -#include "include/cef_ssl_info.h" +#include "include/cef_x509_certificate.h" #include "net/cert/x509_cert_types.h" -// CefSSLCertPrincipal implementation -class CefSSLCertPrincipalImpl : public CefSSLCertPrincipal { +// CefX509CertPrincipal implementation +class CefX509CertPrincipalImpl : public CefX509CertPrincipal { public: - explicit CefSSLCertPrincipalImpl(const net::CertPrincipal& value); + explicit CefX509CertPrincipalImpl(const net::CertPrincipal& value); - // CefSSLCertPrincipal methods. + // CefX509CertPrincipal methods. CefString GetDisplayName() override; CefString GetCommonName() override; CefString GetLocalityName() override; @@ -29,8 +29,8 @@ class CefSSLCertPrincipalImpl : public CefSSLCertPrincipal { private: net::CertPrincipal value_; - IMPLEMENT_REFCOUNTING(CefSSLCertPrincipalImpl); - DISALLOW_COPY_AND_ASSIGN(CefSSLCertPrincipalImpl); + IMPLEMENT_REFCOUNTING(CefX509CertPrincipalImpl); + DISALLOW_COPY_AND_ASSIGN(CefX509CertPrincipalImpl); }; -#endif // CEF_LIBCEF_BROWSER_SSL_CERT_PRINCIPAL_IMPL_H_ +#endif // CEF_LIBCEF_BROWSER_X509_CERT_PRINCIPAL_IMPL_H_ diff --git a/libcef/browser/x509_certificate_impl.cc b/libcef/browser/x509_certificate_impl.cc new file mode 100644 index 000000000..81a6e525a --- /dev/null +++ b/libcef/browser/x509_certificate_impl.cc @@ -0,0 +1,104 @@ +// 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. + +#include "libcef/browser/x509_certificate_impl.h" +#include "libcef/browser/x509_cert_principal_impl.h" +#include "libcef/common/time_util.h" + +namespace { + +void EncodeCertificate( + const net::X509Certificate::OSCertHandle& os_handle, + CefRefPtr& der_encoded, + CefRefPtr& pem_encoded) { + std::string encoded; + if (net::X509Certificate::GetDEREncoded(os_handle, &encoded)) { + der_encoded = CefBinaryValue::Create(encoded.c_str(), + encoded.size()); + } + encoded.clear(); + if (net::X509Certificate::GetPEMEncoded(os_handle, &encoded)) { + pem_encoded = CefBinaryValue::Create(encoded.c_str(), + encoded.size()); + } +} + +} // namespace + +CefX509CertificateImpl::CefX509CertificateImpl( + const net::X509Certificate& value) { + subject_ = new CefX509CertPrincipalImpl(value.subject()); + issuer_ = new CefX509CertPrincipalImpl(value.issuer()); + + const std::string& serial_number = value.serial_number(); + serial_number_ = CefBinaryValue::Create(serial_number.c_str(), + serial_number.size()); + + const base::Time& valid_start = value.valid_start(); + if (!valid_start.is_null()) + cef_time_from_basetime(valid_start, valid_start_); + + const base::Time& valid_expiry = value.valid_expiry(); + if (!valid_expiry.is_null()) + cef_time_from_basetime(valid_expiry, valid_expiry_); + + net::X509Certificate::OSCertHandle os_handle = value.os_cert_handle(); + if (os_handle) + EncodeCertificate(os_handle, der_encoded_, pem_encoded_); + + const net::X509Certificate::OSCertHandles& issuer_chain = + value.GetIntermediateCertificates(); + for (net::X509Certificate::OSCertHandles::const_iterator it = + issuer_chain.begin(); it != issuer_chain.end(); it++) { + CefRefPtr der_encoded, pem_encoded; + EncodeCertificate(*it, der_encoded, pem_encoded); + + // Add each to the chain, even if one conversion unexpectedly failed. + // GetIssuerChainSize depends on these being the same length. + der_encoded_issuer_chain_.push_back(der_encoded); + pem_encoded_issuer_chain_.push_back(pem_encoded); + } +} + +CefRefPtr CefX509CertificateImpl::GetSubject() { + return subject_; +} + +CefRefPtr CefX509CertificateImpl::GetIssuer() { + return issuer_; +} + +CefRefPtr CefX509CertificateImpl::GetSerialNumber() { + return serial_number_; +} + +CefTime CefX509CertificateImpl::GetValidStart() { + return valid_start_; +} + +CefTime CefX509CertificateImpl::GetValidExpiry() { + return valid_expiry_; +} + +CefRefPtr CefX509CertificateImpl::GetDEREncoded() { + return der_encoded_; +} + +CefRefPtr CefX509CertificateImpl::GetPEMEncoded() { + return pem_encoded_; +} + +size_t CefX509CertificateImpl::GetIssuerChainSize() { + return der_encoded_issuer_chain_.size(); +} + +void CefX509CertificateImpl::GetDEREncodedIssuerChain( + CefX509Certificate::IssuerChainBinaryList& chain) { + chain = der_encoded_issuer_chain_; +} + +void CefX509CertificateImpl::GetPEMEncodedIssuerChain( + CefX509Certificate::IssuerChainBinaryList& chain) { + chain = pem_encoded_issuer_chain_; +} diff --git a/libcef/browser/x509_certificate_impl.h b/libcef/browser/x509_certificate_impl.h new file mode 100644 index 000000000..9d0acb9bf --- /dev/null +++ b/libcef/browser/x509_certificate_impl.h @@ -0,0 +1,45 @@ +// 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. + +#ifndef CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_ +#define CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_ +#pragma once + +#include "include/cef_x509_certificate.h" + +#include "net/cert/x509_certificate.h" + +// CefX509Certificate implementation +class CefX509CertificateImpl : public CefX509Certificate { + public: + explicit CefX509CertificateImpl(const net::X509Certificate& value); + + // CefX509Certificate methods. + CefRefPtr GetSubject() override; + CefRefPtr GetIssuer() override; + CefRefPtr GetSerialNumber() override; + CefTime GetValidStart() override; + CefTime GetValidExpiry() override; + CefRefPtr GetDEREncoded() override; + CefRefPtr GetPEMEncoded() override; + size_t GetIssuerChainSize() override; + void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) override; + void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) override; + + private: + CefRefPtr subject_; + CefRefPtr issuer_; + CefRefPtr serial_number_; + CefTime valid_start_; + CefTime valid_expiry_; + CefRefPtr der_encoded_; + CefRefPtr pem_encoded_; + IssuerChainBinaryList der_encoded_issuer_chain_; + IssuerChainBinaryList pem_encoded_issuer_chain_; + + IMPLEMENT_REFCOUNTING(CefX509CertificateImpl); + DISALLOW_COPY_AND_ASSIGN(CefX509CertificateImpl); +}; + +#endif // CEF_LIBCEF_BROWSER_X509_CERTIFICATE_IMPL_H_ diff --git a/libcef_dll/cpptoc/browser_host_cpptoc.cc b/libcef_dll/cpptoc/browser_host_cpptoc.cc index 1f9e01d22..f858660df 100644 --- a/libcef_dll/cpptoc/browser_host_cpptoc.cc +++ b/libcef_dll/cpptoc/browser_host_cpptoc.cc @@ -13,6 +13,7 @@ #include "libcef_dll/cpptoc/browser_cpptoc.h" #include "libcef_dll/cpptoc/browser_host_cpptoc.h" #include "libcef_dll/cpptoc/drag_data_cpptoc.h" +#include "libcef_dll/cpptoc/navigation_entry_cpptoc.h" #include "libcef_dll/cpptoc/request_context_cpptoc.h" #include "libcef_dll/ctocpp/client_ctocpp.h" #include "libcef_dll/ctocpp/download_image_callback_ctocpp.h" @@ -938,6 +939,22 @@ void CEF_CALLBACK browser_host_drag_source_system_drag_ended( CefBrowserHostCppToC::Get(self)->DragSourceSystemDragEnded(); } +struct _cef_navigation_entry_t* CEF_CALLBACK browser_host_get_visible_navigation_entry( + struct _cef_browser_host_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefBrowserHostCppToC::Get( + self)->GetVisibleNavigationEntry(); + + // Return type: refptr_same + return CefNavigationEntryCppToC::Wrap(_retval); +} + } // namespace @@ -1003,6 +1020,8 @@ CefBrowserHostCppToC::CefBrowserHostCppToC() { GetStruct()->drag_source_ended_at = browser_host_drag_source_ended_at; GetStruct()->drag_source_system_drag_ended = browser_host_drag_source_system_drag_ended; + GetStruct()->get_visible_navigation_entry = + browser_host_get_visible_navigation_entry; } template<> CefRefPtr CefCppToC _retval = CefNavigationEntryCppToC::Get( + self)->GetSSLStatus(); + + // Return type: refptr_same + return CefSSLStatusCppToC::Wrap(_retval); +} + } // namespace @@ -168,6 +185,7 @@ CefNavigationEntryCppToC::CefNavigationEntryCppToC() { GetStruct()->has_post_data = navigation_entry_has_post_data; GetStruct()->get_completion_time = navigation_entry_get_completion_time; GetStruct()->get_http_status_code = navigation_entry_get_http_status_code; + GetStruct()->get_sslstatus = navigation_entry_get_sslstatus; } template<> CefRefPtr CefCppToC -#include "libcef_dll/cpptoc/binary_value_cpptoc.h" -#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h" #include "libcef_dll/cpptoc/sslinfo_cpptoc.h" +#include "libcef_dll/cpptoc/x509certificate_cpptoc.h" namespace { @@ -35,36 +33,7 @@ cef_cert_status_t CEF_CALLBACK sslinfo_get_cert_status( return _retval; } -int CEF_CALLBACK sslinfo_is_cert_status_error(struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - bool _retval = CefSSLInfoCppToC::Get(self)->IsCertStatusError(); - - // Return type: bool - return _retval; -} - -int CEF_CALLBACK sslinfo_is_cert_status_minor_error( - struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - bool _retval = CefSSLInfoCppToC::Get(self)->IsCertStatusMinorError(); - - // Return type: bool - return _retval; -} - -cef_sslcert_principal_t* CEF_CALLBACK sslinfo_get_subject( +struct _cef_x509certificate_t* CEF_CALLBACK sslinfo_get_x509certificate( struct _cef_sslinfo_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING @@ -73,189 +42,11 @@ cef_sslcert_principal_t* CEF_CALLBACK sslinfo_get_subject( return NULL; // Execute - CefRefPtr _retval = CefSSLInfoCppToC::Get( - self)->GetSubject(); + CefRefPtr _retval = CefSSLInfoCppToC::Get( + self)->GetX509Certificate(); // Return type: refptr_same - return CefSSLCertPrincipalCppToC::Wrap(_retval); -} - -cef_sslcert_principal_t* CEF_CALLBACK sslinfo_get_issuer( - struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - CefRefPtr _retval = CefSSLInfoCppToC::Get( - self)->GetIssuer(); - - // Return type: refptr_same - return CefSSLCertPrincipalCppToC::Wrap(_retval); -} - -struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_serial_number( - struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - CefRefPtr _retval = CefSSLInfoCppToC::Get( - self)->GetSerialNumber(); - - // Return type: refptr_same - return CefBinaryValueCppToC::Wrap(_retval); -} - -cef_time_t CEF_CALLBACK sslinfo_get_valid_start(struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return CefTime(); - - // Execute - cef_time_t _retval = CefSSLInfoCppToC::Get(self)->GetValidStart(); - - // Return type: simple - return _retval; -} - -cef_time_t CEF_CALLBACK sslinfo_get_valid_expiry(struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return CefTime(); - - // Execute - cef_time_t _retval = CefSSLInfoCppToC::Get(self)->GetValidExpiry(); - - // Return type: simple - return _retval; -} - -struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_derencoded( - struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - CefRefPtr _retval = CefSSLInfoCppToC::Get( - self)->GetDEREncoded(); - - // Return type: refptr_same - return CefBinaryValueCppToC::Wrap(_retval); -} - -struct _cef_binary_value_t* CEF_CALLBACK sslinfo_get_pemencoded( - struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return NULL; - - // Execute - CefRefPtr _retval = CefSSLInfoCppToC::Get( - self)->GetPEMEncoded(); - - // Return type: refptr_same - return CefBinaryValueCppToC::Wrap(_retval); -} - -size_t CEF_CALLBACK sslinfo_get_issuer_chain_size(struct _cef_sslinfo_t* self) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return 0; - - // Execute - size_t _retval = CefSSLInfoCppToC::Get(self)->GetIssuerChainSize(); - - // Return type: simple - return _retval; -} - -void CEF_CALLBACK sslinfo_get_derencoded_issuer_chain( - struct _cef_sslinfo_t* self, size_t* chainCount, - struct _cef_binary_value_t** chain) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: chain; type: refptr_vec_same_byref - DCHECK(chainCount && (*chainCount == 0 || chain)); - if (!chainCount || (*chainCount > 0 && !chain)) - return; - - // Translate param: chain; type: refptr_vec_same_byref - std::vector > chainList; - if (chainCount && *chainCount > 0 && chain) { - for (size_t i = 0; i < *chainCount; ++i) { - chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i])); - } - } - - // Execute - CefSSLInfoCppToC::Get(self)->GetDEREncodedIssuerChain( - chainList); - - // Restore param: chain; type: refptr_vec_same_byref - if (chainCount && chain) { - *chainCount = std::min(chainList.size(), *chainCount); - if (*chainCount > 0) { - for (size_t i = 0; i < *chainCount; ++i) { - chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]); - } - } - } -} - -void CEF_CALLBACK sslinfo_get_pemencoded_issuer_chain( - struct _cef_sslinfo_t* self, size_t* chainCount, - struct _cef_binary_value_t** chain) { - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - DCHECK(self); - if (!self) - return; - // Verify param: chain; type: refptr_vec_same_byref - DCHECK(chainCount && (*chainCount == 0 || chain)); - if (!chainCount || (*chainCount > 0 && !chain)) - return; - - // Translate param: chain; type: refptr_vec_same_byref - std::vector > chainList; - if (chainCount && *chainCount > 0 && chain) { - for (size_t i = 0; i < *chainCount; ++i) { - chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i])); - } - } - - // Execute - CefSSLInfoCppToC::Get(self)->GetPEMEncodedIssuerChain( - chainList); - - // Restore param: chain; type: refptr_vec_same_byref - if (chainCount && chain) { - *chainCount = std::min(chainList.size(), *chainCount); - if (*chainCount > 0) { - for (size_t i = 0; i < *chainCount; ++i) { - chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]); - } - } - } + return CefX509CertificateCppToC::Wrap(_retval); } } // namespace @@ -265,20 +56,7 @@ void CEF_CALLBACK sslinfo_get_pemencoded_issuer_chain( CefSSLInfoCppToC::CefSSLInfoCppToC() { GetStruct()->get_cert_status = sslinfo_get_cert_status; - GetStruct()->is_cert_status_error = sslinfo_is_cert_status_error; - GetStruct()->is_cert_status_minor_error = sslinfo_is_cert_status_minor_error; - GetStruct()->get_subject = sslinfo_get_subject; - GetStruct()->get_issuer = sslinfo_get_issuer; - GetStruct()->get_serial_number = sslinfo_get_serial_number; - GetStruct()->get_valid_start = sslinfo_get_valid_start; - GetStruct()->get_valid_expiry = sslinfo_get_valid_expiry; - GetStruct()->get_derencoded = sslinfo_get_derencoded; - GetStruct()->get_pemencoded = sslinfo_get_pemencoded; - GetStruct()->get_issuer_chain_size = sslinfo_get_issuer_chain_size; - GetStruct()->get_derencoded_issuer_chain = - sslinfo_get_derencoded_issuer_chain; - GetStruct()->get_pemencoded_issuer_chain = - sslinfo_get_pemencoded_issuer_chain; + GetStruct()->get_x509certificate = sslinfo_get_x509certificate; } template<> CefRefPtr CefCppToCIsSecureConnection(); + + // Return type: bool + return _retval; +} + +cef_cert_status_t CEF_CALLBACK sslstatus_get_cert_status( + struct _cef_sslstatus_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CERT_STATUS_NONE; + + // Execute + cef_cert_status_t _retval = CefSSLStatusCppToC::Get(self)->GetCertStatus(); + + // Return type: simple + return _retval; +} + +cef_ssl_version_t CEF_CALLBACK sslstatus_get_sslversion( + struct _cef_sslstatus_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return SSL_CONNECTION_VERSION_UNKNOWN; + + // Execute + cef_ssl_version_t _retval = CefSSLStatusCppToC::Get(self)->GetSSLVersion(); + + // Return type: simple + return _retval; +} + +cef_ssl_content_status_t CEF_CALLBACK sslstatus_get_content_status( + struct _cef_sslstatus_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return SSL_CONTENT_NORMAL_CONTENT; + + // Execute + cef_ssl_content_status_t _retval = CefSSLStatusCppToC::Get( + self)->GetContentStatus(); + + // Return type: simple + return _retval; +} + +struct _cef_x509certificate_t* CEF_CALLBACK sslstatus_get_x509certificate( + struct _cef_sslstatus_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefSSLStatusCppToC::Get( + self)->GetX509Certificate(); + + // Return type: refptr_same + return CefX509CertificateCppToC::Wrap(_retval); +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefSSLStatusCppToC::CefSSLStatusCppToC() { + GetStruct()->is_secure_connection = sslstatus_is_secure_connection; + GetStruct()->get_cert_status = sslstatus_get_cert_status; + GetStruct()->get_sslversion = sslstatus_get_sslversion; + GetStruct()->get_content_status = sslstatus_get_content_status; + GetStruct()->get_x509certificate = sslstatus_get_x509certificate; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived(CefWrapperType type, cef_sslstatus_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = WT_SSLSTATUS; diff --git a/libcef_dll/cpptoc/sslstatus_cpptoc.h b/libcef_dll/cpptoc/sslstatus_cpptoc.h new file mode 100644 index 000000000..9f3926e6f --- /dev/null +++ b/libcef_dll/cpptoc/sslstatus_cpptoc.h @@ -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_SSLSTATUS_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_SSLSTATUS_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_ssl_status.h" +#include "include/capi/cef_ssl_status_capi.h" +#include "include/cef_x509_certificate.h" +#include "include/capi/cef_x509_certificate_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 CefSSLStatusCppToC + : public CefCppToC { + public: + CefSSLStatusCppToC(); +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_SSLSTATUS_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/sslcert_principal_cpptoc.cc b/libcef_dll/cpptoc/x509cert_principal_cpptoc.cc similarity index 57% rename from libcef_dll/cpptoc/sslcert_principal_cpptoc.cc rename to libcef_dll/cpptoc/x509cert_principal_cpptoc.cc index eb5b2ba96..32f88d51f 100644 --- a/libcef_dll/cpptoc/sslcert_principal_cpptoc.cc +++ b/libcef_dll/cpptoc/x509cert_principal_cpptoc.cc @@ -10,7 +10,7 @@ // for more information. // -#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h" +#include "libcef_dll/cpptoc/x509cert_principal_cpptoc.h" #include "libcef_dll/transfer_util.h" @@ -18,8 +18,8 @@ namespace { // MEMBER FUNCTIONS - Body may be edited by hand. -cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_display_name( - struct _cef_sslcert_principal_t* self) { +cef_string_userfree_t CEF_CALLBACK x509cert_principal_get_display_name( + struct _cef_x509cert_principal_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -27,14 +27,14 @@ cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_display_name( return NULL; // Execute - CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetDisplayName(); + CefString _retval = CefX509CertPrincipalCppToC::Get(self)->GetDisplayName(); // Return type: string return _retval.DetachToUserFree(); } -cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_common_name( - struct _cef_sslcert_principal_t* self) { +cef_string_userfree_t CEF_CALLBACK x509cert_principal_get_common_name( + struct _cef_x509cert_principal_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -42,14 +42,14 @@ cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_common_name( return NULL; // Execute - CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetCommonName(); + CefString _retval = CefX509CertPrincipalCppToC::Get(self)->GetCommonName(); // Return type: string return _retval.DetachToUserFree(); } -cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_locality_name( - struct _cef_sslcert_principal_t* self) { +cef_string_userfree_t CEF_CALLBACK x509cert_principal_get_locality_name( + struct _cef_x509cert_principal_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -57,14 +57,14 @@ cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_locality_name( return NULL; // Execute - CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetLocalityName(); + CefString _retval = CefX509CertPrincipalCppToC::Get(self)->GetLocalityName(); // Return type: string return _retval.DetachToUserFree(); } -cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_state_or_province_name( - struct _cef_sslcert_principal_t* self) { +cef_string_userfree_t CEF_CALLBACK x509cert_principal_get_state_or_province_name( + struct _cef_x509cert_principal_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -72,15 +72,15 @@ cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_state_or_province_name( return NULL; // Execute - CefString _retval = CefSSLCertPrincipalCppToC::Get( + CefString _retval = CefX509CertPrincipalCppToC::Get( self)->GetStateOrProvinceName(); // Return type: string return _retval.DetachToUserFree(); } -cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_country_name( - struct _cef_sslcert_principal_t* self) { +cef_string_userfree_t CEF_CALLBACK x509cert_principal_get_country_name( + struct _cef_x509cert_principal_t* self) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -88,14 +88,14 @@ cef_string_userfree_t CEF_CALLBACK sslcert_principal_get_country_name( return NULL; // Execute - CefString _retval = CefSSLCertPrincipalCppToC::Get(self)->GetCountryName(); + CefString _retval = CefX509CertPrincipalCppToC::Get(self)->GetCountryName(); // Return type: string return _retval.DetachToUserFree(); } -void CEF_CALLBACK sslcert_principal_get_street_addresses( - struct _cef_sslcert_principal_t* self, cef_string_list_t addresses) { +void CEF_CALLBACK x509cert_principal_get_street_addresses( + struct _cef_x509cert_principal_t* self, cef_string_list_t addresses) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -111,7 +111,7 @@ void CEF_CALLBACK sslcert_principal_get_street_addresses( transfer_string_list_contents(addresses, addressesList); // Execute - CefSSLCertPrincipalCppToC::Get(self)->GetStreetAddresses( + CefX509CertPrincipalCppToC::Get(self)->GetStreetAddresses( addressesList); // Restore param: addresses; type: string_vec_byref @@ -119,8 +119,8 @@ void CEF_CALLBACK sslcert_principal_get_street_addresses( transfer_string_list_contents(addressesList, addresses); } -void CEF_CALLBACK sslcert_principal_get_organization_names( - struct _cef_sslcert_principal_t* self, cef_string_list_t names) { +void CEF_CALLBACK x509cert_principal_get_organization_names( + struct _cef_x509cert_principal_t* self, cef_string_list_t names) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -136,7 +136,7 @@ void CEF_CALLBACK sslcert_principal_get_organization_names( transfer_string_list_contents(names, namesList); // Execute - CefSSLCertPrincipalCppToC::Get(self)->GetOrganizationNames( + CefX509CertPrincipalCppToC::Get(self)->GetOrganizationNames( namesList); // Restore param: names; type: string_vec_byref @@ -144,8 +144,8 @@ void CEF_CALLBACK sslcert_principal_get_organization_names( transfer_string_list_contents(namesList, names); } -void CEF_CALLBACK sslcert_principal_get_organization_unit_names( - struct _cef_sslcert_principal_t* self, cef_string_list_t names) { +void CEF_CALLBACK x509cert_principal_get_organization_unit_names( + struct _cef_x509cert_principal_t* self, cef_string_list_t names) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -161,7 +161,7 @@ void CEF_CALLBACK sslcert_principal_get_organization_unit_names( transfer_string_list_contents(names, namesList); // Execute - CefSSLCertPrincipalCppToC::Get(self)->GetOrganizationUnitNames( + CefX509CertPrincipalCppToC::Get(self)->GetOrganizationUnitNames( namesList); // Restore param: names; type: string_vec_byref @@ -169,8 +169,8 @@ void CEF_CALLBACK sslcert_principal_get_organization_unit_names( transfer_string_list_contents(namesList, names); } -void CEF_CALLBACK sslcert_principal_get_domain_components( - struct _cef_sslcert_principal_t* self, cef_string_list_t components) { +void CEF_CALLBACK x509cert_principal_get_domain_components( + struct _cef_x509cert_principal_t* self, cef_string_list_t components) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING DCHECK(self); @@ -186,7 +186,7 @@ void CEF_CALLBACK sslcert_principal_get_domain_components( transfer_string_list_contents(components, componentsList); // Execute - CefSSLCertPrincipalCppToC::Get(self)->GetDomainComponents( + CefX509CertPrincipalCppToC::Get(self)->GetDomainComponents( componentsList); // Restore param: components; type: string_vec_byref @@ -199,33 +199,33 @@ void CEF_CALLBACK sslcert_principal_get_domain_components( // CONSTRUCTOR - Do not edit by hand. -CefSSLCertPrincipalCppToC::CefSSLCertPrincipalCppToC() { - GetStruct()->get_display_name = sslcert_principal_get_display_name; - GetStruct()->get_common_name = sslcert_principal_get_common_name; - GetStruct()->get_locality_name = sslcert_principal_get_locality_name; +CefX509CertPrincipalCppToC::CefX509CertPrincipalCppToC() { + GetStruct()->get_display_name = x509cert_principal_get_display_name; + GetStruct()->get_common_name = x509cert_principal_get_common_name; + GetStruct()->get_locality_name = x509cert_principal_get_locality_name; GetStruct()->get_state_or_province_name = - sslcert_principal_get_state_or_province_name; - GetStruct()->get_country_name = sslcert_principal_get_country_name; - GetStruct()->get_street_addresses = sslcert_principal_get_street_addresses; + x509cert_principal_get_state_or_province_name; + GetStruct()->get_country_name = x509cert_principal_get_country_name; + GetStruct()->get_street_addresses = x509cert_principal_get_street_addresses; GetStruct()->get_organization_names = - sslcert_principal_get_organization_names; + x509cert_principal_get_organization_names; GetStruct()->get_organization_unit_names = - sslcert_principal_get_organization_unit_names; - GetStruct()->get_domain_components = sslcert_principal_get_domain_components; + x509cert_principal_get_organization_unit_names; + GetStruct()->get_domain_components = x509cert_principal_get_domain_components; } -template<> CefRefPtr CefCppToC::UnwrapDerived( - CefWrapperType type, cef_sslcert_principal_t* s) { +template<> CefRefPtr CefCppToC::UnwrapDerived( + CefWrapperType type, cef_x509cert_principal_t* s) { NOTREACHED() << "Unexpected class type: " << type; return NULL; } #if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; #endif -template<> CefWrapperType CefCppToC::kWrapperType = - WT_SSLCERT_PRINCIPAL; +template<> CefWrapperType CefCppToC::kWrapperType = + WT_X509CERT_PRINCIPAL; diff --git a/libcef_dll/cpptoc/x509cert_principal_cpptoc.h b/libcef_dll/cpptoc/x509cert_principal_cpptoc.h new file mode 100644 index 000000000..8b11b8e01 --- /dev/null +++ b/libcef_dll/cpptoc/x509cert_principal_cpptoc.h @@ -0,0 +1,35 @@ +// 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_X509CERT_PRINCIPAL_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_X509CERT_PRINCIPAL_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_x509_certificate.h" +#include "include/capi/cef_x509_certificate_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 CefX509CertPrincipalCppToC + : public CefCppToC { + public: + CefX509CertPrincipalCppToC(); +}; + +#endif // BUILDING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CPPTOC_X509CERT_PRINCIPAL_CPPTOC_H_ diff --git a/libcef_dll/cpptoc/x509certificate_cpptoc.cc b/libcef_dll/cpptoc/x509certificate_cpptoc.cc new file mode 100644 index 000000000..d544b74d8 --- /dev/null +++ b/libcef_dll/cpptoc/x509certificate_cpptoc.cc @@ -0,0 +1,254 @@ +// 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 +#include "libcef_dll/cpptoc/binary_value_cpptoc.h" +#include "libcef_dll/cpptoc/x509cert_principal_cpptoc.h" +#include "libcef_dll/cpptoc/x509certificate_cpptoc.h" + + +namespace { + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_x509cert_principal_t* CEF_CALLBACK x509certificate_get_subject( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefX509CertificateCppToC::Get( + self)->GetSubject(); + + // Return type: refptr_same + return CefX509CertPrincipalCppToC::Wrap(_retval); +} + +cef_x509cert_principal_t* CEF_CALLBACK x509certificate_get_issuer( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefX509CertificateCppToC::Get( + self)->GetIssuer(); + + // Return type: refptr_same + return CefX509CertPrincipalCppToC::Wrap(_retval); +} + +cef_binary_value_t* CEF_CALLBACK x509certificate_get_serial_number( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefX509CertificateCppToC::Get( + self)->GetSerialNumber(); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + +cef_time_t CEF_CALLBACK x509certificate_get_valid_start( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefTime(); + + // Execute + cef_time_t _retval = CefX509CertificateCppToC::Get(self)->GetValidStart(); + + // Return type: simple + return _retval; +} + +cef_time_t CEF_CALLBACK x509certificate_get_valid_expiry( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return CefTime(); + + // Execute + cef_time_t _retval = CefX509CertificateCppToC::Get(self)->GetValidExpiry(); + + // Return type: simple + return _retval; +} + +cef_binary_value_t* CEF_CALLBACK x509certificate_get_derencoded( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefX509CertificateCppToC::Get( + self)->GetDEREncoded(); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + +cef_binary_value_t* CEF_CALLBACK x509certificate_get_pemencoded( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefRefPtr _retval = CefX509CertificateCppToC::Get( + self)->GetPEMEncoded(); + + // Return type: refptr_same + return CefBinaryValueCppToC::Wrap(_retval); +} + +size_t CEF_CALLBACK x509certificate_get_issuer_chain_size( + struct _cef_x509certificate_t* self) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return 0; + + // Execute + size_t _retval = CefX509CertificateCppToC::Get(self)->GetIssuerChainSize(); + + // Return type: simple + return _retval; +} + +void CEF_CALLBACK x509certificate_get_derencoded_issuer_chain( + struct _cef_x509certificate_t* self, size_t* chainCount, + cef_binary_value_t** chain) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: chain; type: refptr_vec_same_byref + DCHECK(chainCount && (*chainCount == 0 || chain)); + if (!chainCount || (*chainCount > 0 && !chain)) + return; + + // Translate param: chain; type: refptr_vec_same_byref + std::vector > chainList; + if (chainCount && *chainCount > 0 && chain) { + for (size_t i = 0; i < *chainCount; ++i) { + chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i])); + } + } + + // Execute + CefX509CertificateCppToC::Get(self)->GetDEREncodedIssuerChain( + chainList); + + // Restore param: chain; type: refptr_vec_same_byref + if (chainCount && chain) { + *chainCount = std::min(chainList.size(), *chainCount); + if (*chainCount > 0) { + for (size_t i = 0; i < *chainCount; ++i) { + chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]); + } + } + } +} + +void CEF_CALLBACK x509certificate_get_pemencoded_issuer_chain( + struct _cef_x509certificate_t* self, size_t* chainCount, + cef_binary_value_t** chain) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return; + // Verify param: chain; type: refptr_vec_same_byref + DCHECK(chainCount && (*chainCount == 0 || chain)); + if (!chainCount || (*chainCount > 0 && !chain)) + return; + + // Translate param: chain; type: refptr_vec_same_byref + std::vector > chainList; + if (chainCount && *chainCount > 0 && chain) { + for (size_t i = 0; i < *chainCount; ++i) { + chainList.push_back(CefBinaryValueCppToC::Unwrap(chain[i])); + } + } + + // Execute + CefX509CertificateCppToC::Get(self)->GetPEMEncodedIssuerChain( + chainList); + + // Restore param: chain; type: refptr_vec_same_byref + if (chainCount && chain) { + *chainCount = std::min(chainList.size(), *chainCount); + if (*chainCount > 0) { + for (size_t i = 0; i < *chainCount; ++i) { + chain[i] = CefBinaryValueCppToC::Wrap(chainList[i]); + } + } + } +} + +} // namespace + + +// CONSTRUCTOR - Do not edit by hand. + +CefX509CertificateCppToC::CefX509CertificateCppToC() { + GetStruct()->get_subject = x509certificate_get_subject; + GetStruct()->get_issuer = x509certificate_get_issuer; + GetStruct()->get_serial_number = x509certificate_get_serial_number; + GetStruct()->get_valid_start = x509certificate_get_valid_start; + GetStruct()->get_valid_expiry = x509certificate_get_valid_expiry; + GetStruct()->get_derencoded = x509certificate_get_derencoded; + GetStruct()->get_pemencoded = x509certificate_get_pemencoded; + GetStruct()->get_issuer_chain_size = x509certificate_get_issuer_chain_size; + GetStruct()->get_derencoded_issuer_chain = + x509certificate_get_derencoded_issuer_chain; + GetStruct()->get_pemencoded_issuer_chain = + x509certificate_get_pemencoded_issuer_chain; +} + +template<> CefRefPtr CefCppToC::UnwrapDerived( + CefWrapperType type, cef_x509certificate_t* s) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCppToC::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCppToC::kWrapperType = + WT_X509CERTIFICATE; diff --git a/libcef_dll/cpptoc/sslcert_principal_cpptoc.h b/libcef_dll/cpptoc/x509certificate_cpptoc.h similarity index 66% rename from libcef_dll/cpptoc/sslcert_principal_cpptoc.h rename to libcef_dll/cpptoc/x509certificate_cpptoc.h index 7ddfcc934..97682df7f 100644 --- a/libcef_dll/cpptoc/sslcert_principal_cpptoc.h +++ b/libcef_dll/cpptoc/x509certificate_cpptoc.h @@ -10,26 +10,26 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CPPTOC_SSLCERT_PRINCIPAL_CPPTOC_H_ -#define CEF_LIBCEF_DLL_CPPTOC_SSLCERT_PRINCIPAL_CPPTOC_H_ +#ifndef CEF_LIBCEF_DLL_CPPTOC_X509CERTIFICATE_CPPTOC_H_ +#define CEF_LIBCEF_DLL_CPPTOC_X509CERTIFICATE_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_ssl_info.h" -#include "include/capi/cef_ssl_info_capi.h" +#include "include/cef_x509_certificate.h" +#include "include/capi/cef_x509_certificate_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 CefSSLCertPrincipalCppToC - : public CefCppToC { +class CefX509CertificateCppToC + : public CefCppToC { public: - CefSSLCertPrincipalCppToC(); + CefX509CertificateCppToC(); }; #endif // BUILDING_CEF_SHARED -#endif // CEF_LIBCEF_DLL_CPPTOC_SSLCERT_PRINCIPAL_CPPTOC_H_ +#endif // CEF_LIBCEF_DLL_CPPTOC_X509CERTIFICATE_CPPTOC_H_ diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.cc b/libcef_dll/ctocpp/browser_host_ctocpp.cc index 92b62b090..ee25a5310 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.cc +++ b/libcef_dll/ctocpp/browser_host_ctocpp.cc @@ -18,6 +18,7 @@ #include "libcef_dll/ctocpp/browser_ctocpp.h" #include "libcef_dll/ctocpp/browser_host_ctocpp.h" #include "libcef_dll/ctocpp/drag_data_ctocpp.h" +#include "libcef_dll/ctocpp/navigation_entry_ctocpp.h" #include "libcef_dll/ctocpp/request_context_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -789,6 +790,22 @@ void CefBrowserHostCToCpp::DragSourceSystemDragEnded() { _struct->drag_source_system_drag_ended(_struct); } +CefRefPtr CefBrowserHostCToCpp::GetVisibleNavigationEntry( + ) { + cef_browser_host_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_visible_navigation_entry)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_navigation_entry_t* _retval = _struct->get_visible_navigation_entry( + _struct); + + // Return type: refptr_same + return CefNavigationEntryCToCpp::Wrap(_retval); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/browser_host_ctocpp.h b/libcef_dll/ctocpp/browser_host_ctocpp.h index cc03c437d..3b11648fc 100644 --- a/libcef_dll/ctocpp/browser_host_ctocpp.h +++ b/libcef_dll/ctocpp/browser_host_ctocpp.h @@ -97,6 +97,7 @@ class CefBrowserHostCToCpp void DragTargetDrop(const CefMouseEvent& event) OVERRIDE; void DragSourceEndedAt(int x, int y, DragOperationsMask op) OVERRIDE; void DragSourceSystemDragEnded() OVERRIDE; + CefRefPtr GetVisibleNavigationEntry() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/navigation_entry_ctocpp.cc b/libcef_dll/ctocpp/navigation_entry_ctocpp.cc index 3a0dbc6e7..4ebc423d1 100644 --- a/libcef_dll/ctocpp/navigation_entry_ctocpp.cc +++ b/libcef_dll/ctocpp/navigation_entry_ctocpp.cc @@ -11,6 +11,7 @@ // #include "libcef_dll/ctocpp/navigation_entry_ctocpp.h" +#include "libcef_dll/ctocpp/sslstatus_ctocpp.h" // VIRTUAL METHODS - Body may be edited by hand. @@ -150,6 +151,20 @@ int CefNavigationEntryCToCpp::GetHttpStatusCode() { return _retval; } +CefRefPtr CefNavigationEntryCToCpp::GetSSLStatus() { + cef_navigation_entry_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_sslstatus)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_sslstatus_t* _retval = _struct->get_sslstatus(_struct); + + // Return type: refptr_same + return CefSSLStatusCToCpp::Wrap(_retval); +} + // CONSTRUCTOR - Do not edit by hand. diff --git a/libcef_dll/ctocpp/navigation_entry_ctocpp.h b/libcef_dll/ctocpp/navigation_entry_ctocpp.h index 56df51e5b..56dc6f31c 100644 --- a/libcef_dll/ctocpp/navigation_entry_ctocpp.h +++ b/libcef_dll/ctocpp/navigation_entry_ctocpp.h @@ -20,6 +20,8 @@ #include "include/cef_navigation_entry.h" #include "include/capi/cef_navigation_entry_capi.h" +#include "include/cef_ssl_status.h" +#include "include/capi/cef_ssl_status_capi.h" #include "libcef_dll/ctocpp/ctocpp.h" // Wrap a C structure with a C++ class. @@ -40,6 +42,7 @@ class CefNavigationEntryCToCpp bool HasPostData() OVERRIDE; CefTime GetCompletionTime() OVERRIDE; int GetHttpStatusCode() OVERRIDE; + CefRefPtr GetSSLStatus() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/sslinfo_ctocpp.cc b/libcef_dll/ctocpp/sslinfo_ctocpp.cc index 0a39f1fc7..c392b89b8 100644 --- a/libcef_dll/ctocpp/sslinfo_ctocpp.cc +++ b/libcef_dll/ctocpp/sslinfo_ctocpp.cc @@ -10,10 +10,8 @@ // for more information. // -#include -#include "libcef_dll/ctocpp/binary_value_ctocpp.h" -#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h" #include "libcef_dll/ctocpp/sslinfo_ctocpp.h" +#include "libcef_dll/ctocpp/x509certificate_ctocpp.h" // VIRTUAL METHODS - Body may be edited by hand. @@ -32,222 +30,18 @@ cef_cert_status_t CefSSLInfoCToCpp::GetCertStatus() { return _retval; } -bool CefSSLInfoCToCpp::IsCertStatusError() { +CefRefPtr CefSSLInfoCToCpp::GetX509Certificate() { cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, is_cert_status_error)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->is_cert_status_error(_struct); - - // Return type: bool - return _retval?true:false; -} - -bool CefSSLInfoCToCpp::IsCertStatusMinorError() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, is_cert_status_minor_error)) - return false; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - int _retval = _struct->is_cert_status_minor_error(_struct); - - // Return type: bool - return _retval?true:false; -} - -CefRefPtr CefSSLInfoCToCpp::GetSubject() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_subject)) + if (CEF_MEMBER_MISSING(_struct, get_x509certificate)) return NULL; // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING // Execute - cef_sslcert_principal_t* _retval = _struct->get_subject(_struct); + cef_x509certificate_t* _retval = _struct->get_x509certificate(_struct); // Return type: refptr_same - return CefSSLCertPrincipalCToCpp::Wrap(_retval); -} - -CefRefPtr CefSSLInfoCToCpp::GetIssuer() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_issuer)) - return NULL; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_sslcert_principal_t* _retval = _struct->get_issuer(_struct); - - // Return type: refptr_same - return CefSSLCertPrincipalCToCpp::Wrap(_retval); -} - -CefRefPtr CefSSLInfoCToCpp::GetSerialNumber() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_serial_number)) - return NULL; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_binary_value_t* _retval = _struct->get_serial_number(_struct); - - // Return type: refptr_same - return CefBinaryValueCToCpp::Wrap(_retval); -} - -CefTime CefSSLInfoCToCpp::GetValidStart() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_valid_start)) - return CefTime(); - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_time_t _retval = _struct->get_valid_start(_struct); - - // Return type: simple - return _retval; -} - -CefTime CefSSLInfoCToCpp::GetValidExpiry() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_valid_expiry)) - return CefTime(); - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_time_t _retval = _struct->get_valid_expiry(_struct); - - // Return type: simple - return _retval; -} - -CefRefPtr CefSSLInfoCToCpp::GetDEREncoded() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_derencoded)) - return NULL; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_binary_value_t* _retval = _struct->get_derencoded(_struct); - - // Return type: refptr_same - return CefBinaryValueCToCpp::Wrap(_retval); -} - -CefRefPtr CefSSLInfoCToCpp::GetPEMEncoded() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_pemencoded)) - return NULL; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - cef_binary_value_t* _retval = _struct->get_pemencoded(_struct); - - // Return type: refptr_same - return CefBinaryValueCToCpp::Wrap(_retval); -} - -size_t CefSSLInfoCToCpp::GetIssuerChainSize() { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_issuer_chain_size)) - return 0; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Execute - size_t _retval = _struct->get_issuer_chain_size(_struct); - - // Return type: simple - return _retval; -} - -void CefSSLInfoCToCpp::GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_derencoded_issuer_chain)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Translate param: chain; type: refptr_vec_same_byref - size_t chainSize = chain.size(); - size_t chainCount = std::max(GetIssuerChainSize(), chainSize); - cef_binary_value_t** chainList = NULL; - if (chainCount > 0) { - chainList = new cef_binary_value_t*[chainCount]; - DCHECK(chainList); - if (chainList) { - memset(chainList, 0, sizeof(cef_binary_value_t*)*chainCount); - } - if (chainList && chainSize > 0) { - for (size_t i = 0; i < chainSize; ++i) { - chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]); - } - } - } - - // Execute - _struct->get_derencoded_issuer_chain(_struct, - &chainCount, - chainList); - - // Restore param:chain; type: refptr_vec_same_byref - chain.clear(); - if (chainCount > 0 && chainList) { - for (size_t i = 0; i < chainCount; ++i) { - chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i])); - } - delete [] chainList; - } -} - -void CefSSLInfoCToCpp::GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) { - cef_sslinfo_t* _struct = GetStruct(); - if (CEF_MEMBER_MISSING(_struct, get_pemencoded_issuer_chain)) - return; - - // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING - - // Translate param: chain; type: refptr_vec_same_byref - size_t chainSize = chain.size(); - size_t chainCount = std::max(GetIssuerChainSize(), chainSize); - cef_binary_value_t** chainList = NULL; - if (chainCount > 0) { - chainList = new cef_binary_value_t*[chainCount]; - DCHECK(chainList); - if (chainList) { - memset(chainList, 0, sizeof(cef_binary_value_t*)*chainCount); - } - if (chainList && chainSize > 0) { - for (size_t i = 0; i < chainSize; ++i) { - chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]); - } - } - } - - // Execute - _struct->get_pemencoded_issuer_chain(_struct, - &chainCount, - chainList); - - // Restore param:chain; type: refptr_vec_same_byref - chain.clear(); - if (chainCount > 0 && chainList) { - for (size_t i = 0; i < chainCount; ++i) { - chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i])); - } - delete [] chainList; - } + return CefX509CertificateCToCpp::Wrap(_retval); } diff --git a/libcef_dll/ctocpp/sslinfo_ctocpp.h b/libcef_dll/ctocpp/sslinfo_ctocpp.h index 7fc487c8d..57fbbc363 100644 --- a/libcef_dll/ctocpp/sslinfo_ctocpp.h +++ b/libcef_dll/ctocpp/sslinfo_ctocpp.h @@ -31,18 +31,7 @@ class CefSSLInfoCToCpp // CefSSLInfo methods. cef_cert_status_t GetCertStatus() OVERRIDE; - bool IsCertStatusError() OVERRIDE; - bool IsCertStatusMinorError() OVERRIDE; - CefRefPtr GetSubject() OVERRIDE; - CefRefPtr GetIssuer() OVERRIDE; - CefRefPtr GetSerialNumber() OVERRIDE; - CefTime GetValidStart() OVERRIDE; - CefTime GetValidExpiry() OVERRIDE; - CefRefPtr GetDEREncoded() OVERRIDE; - CefRefPtr GetPEMEncoded() OVERRIDE; - size_t GetIssuerChainSize() OVERRIDE; - void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) OVERRIDE; - void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) OVERRIDE; + CefRefPtr GetX509Certificate() OVERRIDE; }; #endif // USING_CEF_SHARED diff --git a/libcef_dll/ctocpp/sslstatus_ctocpp.cc b/libcef_dll/ctocpp/sslstatus_ctocpp.cc new file mode 100644 index 000000000..12a378787 --- /dev/null +++ b/libcef_dll/ctocpp/sslstatus_ctocpp.cc @@ -0,0 +1,107 @@ +// 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/ctocpp/sslstatus_ctocpp.h" +#include "libcef_dll/ctocpp/x509certificate_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +bool CefSSLStatusCToCpp::IsSecureConnection() { + cef_sslstatus_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, is_secure_connection)) + return false; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = _struct->is_secure_connection(_struct); + + // Return type: bool + return _retval?true:false; +} + +cef_cert_status_t CefSSLStatusCToCpp::GetCertStatus() { + cef_sslstatus_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_cert_status)) + return CERT_STATUS_NONE; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_cert_status_t _retval = _struct->get_cert_status(_struct); + + // Return type: simple + return _retval; +} + +cef_ssl_version_t CefSSLStatusCToCpp::GetSSLVersion() { + cef_sslstatus_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_sslversion)) + return SSL_CONNECTION_VERSION_UNKNOWN; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_ssl_version_t _retval = _struct->get_sslversion(_struct); + + // Return type: simple + return _retval; +} + +cef_ssl_content_status_t CefSSLStatusCToCpp::GetContentStatus() { + cef_sslstatus_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_content_status)) + return SSL_CONTENT_NORMAL_CONTENT; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_ssl_content_status_t _retval = _struct->get_content_status(_struct); + + // Return type: simple + return _retval; +} + +CefRefPtr CefSSLStatusCToCpp::GetX509Certificate() { + cef_sslstatus_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_x509certificate)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_x509certificate_t* _retval = _struct->get_x509certificate(_struct); + + // Return type: refptr_same + return CefX509CertificateCToCpp::Wrap(_retval); +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefSSLStatusCToCpp::CefSSLStatusCToCpp() { +} + +template<> cef_sslstatus_t* CefCToCpp::UnwrapDerived(CefWrapperType type, CefSSLStatus* c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCpp::kWrapperType = WT_SSLSTATUS; diff --git a/libcef_dll/ctocpp/sslstatus_ctocpp.h b/libcef_dll/ctocpp/sslstatus_ctocpp.h new file mode 100644 index 000000000..0242480b8 --- /dev/null +++ b/libcef_dll/ctocpp/sslstatus_ctocpp.h @@ -0,0 +1,43 @@ +// 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_CTOCPP_SSLSTATUS_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_SSLSTATUS_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_ssl_status.h" +#include "include/capi/cef_ssl_status_capi.h" +#include "include/cef_x509_certificate.h" +#include "include/capi/cef_x509_certificate_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefSSLStatusCToCpp + : public CefCToCpp { + public: + CefSSLStatusCToCpp(); + + // CefSSLStatus methods. + bool IsSecureConnection() OVERRIDE; + cef_cert_status_t GetCertStatus() OVERRIDE; + cef_ssl_version_t GetSSLVersion() OVERRIDE; + cef_ssl_content_status_t GetContentStatus() OVERRIDE; + CefRefPtr GetX509Certificate() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_SSLSTATUS_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/sslcert_principal_ctocpp.cc b/libcef_dll/ctocpp/x509cert_principal_ctocpp.cc similarity index 76% rename from libcef_dll/ctocpp/sslcert_principal_ctocpp.cc rename to libcef_dll/ctocpp/x509cert_principal_ctocpp.cc index a2f9cf3be..87eda4e4d 100644 --- a/libcef_dll/ctocpp/sslcert_principal_ctocpp.cc +++ b/libcef_dll/ctocpp/x509cert_principal_ctocpp.cc @@ -10,14 +10,14 @@ // for more information. // -#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h" +#include "libcef_dll/ctocpp/x509cert_principal_ctocpp.h" #include "libcef_dll/transfer_util.h" // VIRTUAL METHODS - Body may be edited by hand. -CefString CefSSLCertPrincipalCToCpp::GetDisplayName() { - cef_sslcert_principal_t* _struct = GetStruct(); +CefString CefX509CertPrincipalCToCpp::GetDisplayName() { + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_display_name)) return CefString(); @@ -32,8 +32,8 @@ CefString CefSSLCertPrincipalCToCpp::GetDisplayName() { return _retvalStr; } -CefString CefSSLCertPrincipalCToCpp::GetCommonName() { - cef_sslcert_principal_t* _struct = GetStruct(); +CefString CefX509CertPrincipalCToCpp::GetCommonName() { + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_common_name)) return CefString(); @@ -48,8 +48,8 @@ CefString CefSSLCertPrincipalCToCpp::GetCommonName() { return _retvalStr; } -CefString CefSSLCertPrincipalCToCpp::GetLocalityName() { - cef_sslcert_principal_t* _struct = GetStruct(); +CefString CefX509CertPrincipalCToCpp::GetLocalityName() { + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_locality_name)) return CefString(); @@ -64,8 +64,8 @@ CefString CefSSLCertPrincipalCToCpp::GetLocalityName() { return _retvalStr; } -CefString CefSSLCertPrincipalCToCpp::GetStateOrProvinceName() { - cef_sslcert_principal_t* _struct = GetStruct(); +CefString CefX509CertPrincipalCToCpp::GetStateOrProvinceName() { + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_state_or_province_name)) return CefString(); @@ -80,8 +80,8 @@ CefString CefSSLCertPrincipalCToCpp::GetStateOrProvinceName() { return _retvalStr; } -CefString CefSSLCertPrincipalCToCpp::GetCountryName() { - cef_sslcert_principal_t* _struct = GetStruct(); +CefString CefX509CertPrincipalCToCpp::GetCountryName() { + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_country_name)) return CefString(); @@ -96,9 +96,9 @@ CefString CefSSLCertPrincipalCToCpp::GetCountryName() { return _retvalStr; } -void CefSSLCertPrincipalCToCpp::GetStreetAddresses( +void CefX509CertPrincipalCToCpp::GetStreetAddresses( std::vector& addresses) { - cef_sslcert_principal_t* _struct = GetStruct(); + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_street_addresses)) return; @@ -122,9 +122,9 @@ void CefSSLCertPrincipalCToCpp::GetStreetAddresses( } } -void CefSSLCertPrincipalCToCpp::GetOrganizationNames( +void CefX509CertPrincipalCToCpp::GetOrganizationNames( std::vector& names) { - cef_sslcert_principal_t* _struct = GetStruct(); + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_organization_names)) return; @@ -148,9 +148,9 @@ void CefSSLCertPrincipalCToCpp::GetOrganizationNames( } } -void CefSSLCertPrincipalCToCpp::GetOrganizationUnitNames( +void CefX509CertPrincipalCToCpp::GetOrganizationUnitNames( std::vector& names) { - cef_sslcert_principal_t* _struct = GetStruct(); + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_organization_unit_names)) return; @@ -174,9 +174,9 @@ void CefSSLCertPrincipalCToCpp::GetOrganizationUnitNames( } } -void CefSSLCertPrincipalCToCpp::GetDomainComponents( +void CefX509CertPrincipalCToCpp::GetDomainComponents( std::vector& components) { - cef_sslcert_principal_t* _struct = GetStruct(); + cef_x509cert_principal_t* _struct = GetStruct(); if (CEF_MEMBER_MISSING(_struct, get_domain_components)) return; @@ -203,21 +203,21 @@ void CefSSLCertPrincipalCToCpp::GetDomainComponents( // CONSTRUCTOR - Do not edit by hand. -CefSSLCertPrincipalCToCpp::CefSSLCertPrincipalCToCpp() { +CefX509CertPrincipalCToCpp::CefX509CertPrincipalCToCpp() { } -template<> cef_sslcert_principal_t* CefCToCpp::UnwrapDerived( - CefWrapperType type, CefSSLCertPrincipal* c) { +template<> cef_x509cert_principal_t* CefCToCpp::UnwrapDerived( + CefWrapperType type, CefX509CertPrincipal* c) { NOTREACHED() << "Unexpected class type: " << type; return NULL; } #if DCHECK_IS_ON() -template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; #endif -template<> CefWrapperType CefCToCpp::kWrapperType = - WT_SSLCERT_PRINCIPAL; +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_X509CERT_PRINCIPAL; diff --git a/libcef_dll/ctocpp/sslcert_principal_ctocpp.h b/libcef_dll/ctocpp/x509cert_principal_ctocpp.h similarity index 73% rename from libcef_dll/ctocpp/sslcert_principal_ctocpp.h rename to libcef_dll/ctocpp/x509cert_principal_ctocpp.h index 19ece7d29..07dc74033 100644 --- a/libcef_dll/ctocpp/sslcert_principal_ctocpp.h +++ b/libcef_dll/ctocpp/x509cert_principal_ctocpp.h @@ -10,8 +10,8 @@ // for more information. // -#ifndef CEF_LIBCEF_DLL_CTOCPP_SSLCERT_PRINCIPAL_CTOCPP_H_ -#define CEF_LIBCEF_DLL_CTOCPP_SSLCERT_PRINCIPAL_CTOCPP_H_ +#ifndef CEF_LIBCEF_DLL_CTOCPP_X509CERT_PRINCIPAL_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_X509CERT_PRINCIPAL_CTOCPP_H_ #pragma once #ifndef USING_CEF_SHARED @@ -19,19 +19,19 @@ #else // USING_CEF_SHARED #include -#include "include/cef_ssl_info.h" -#include "include/capi/cef_ssl_info_capi.h" +#include "include/cef_x509_certificate.h" +#include "include/capi/cef_x509_certificate_capi.h" #include "libcef_dll/ctocpp/ctocpp.h" // Wrap a C structure with a C++ class. // This class may be instantiated and accessed wrapper-side only. -class CefSSLCertPrincipalCToCpp - : public CefCToCpp { +class CefX509CertPrincipalCToCpp + : public CefCToCpp { public: - CefSSLCertPrincipalCToCpp(); + CefX509CertPrincipalCToCpp(); - // CefSSLCertPrincipal methods. + // CefX509CertPrincipal methods. CefString GetDisplayName() OVERRIDE; CefString GetCommonName() OVERRIDE; CefString GetLocalityName() OVERRIDE; @@ -44,4 +44,4 @@ class CefSSLCertPrincipalCToCpp }; #endif // USING_CEF_SHARED -#endif // CEF_LIBCEF_DLL_CTOCPP_SSLCERT_PRINCIPAL_CTOCPP_H_ +#endif // CEF_LIBCEF_DLL_CTOCPP_X509CERT_PRINCIPAL_CTOCPP_H_ diff --git a/libcef_dll/ctocpp/x509certificate_ctocpp.cc b/libcef_dll/ctocpp/x509certificate_ctocpp.cc new file mode 100644 index 000000000..cde24fbab --- /dev/null +++ b/libcef_dll/ctocpp/x509certificate_ctocpp.cc @@ -0,0 +1,233 @@ +// 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 +#include "libcef_dll/ctocpp/binary_value_ctocpp.h" +#include "libcef_dll/ctocpp/x509cert_principal_ctocpp.h" +#include "libcef_dll/ctocpp/x509certificate_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefRefPtr CefX509CertificateCToCpp::GetSubject() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_subject)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_x509cert_principal_t* _retval = _struct->get_subject(_struct); + + // Return type: refptr_same + return CefX509CertPrincipalCToCpp::Wrap(_retval); +} + +CefRefPtr CefX509CertificateCToCpp::GetIssuer() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_issuer)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_x509cert_principal_t* _retval = _struct->get_issuer(_struct); + + // Return type: refptr_same + return CefX509CertPrincipalCToCpp::Wrap(_retval); +} + +CefRefPtr CefX509CertificateCToCpp::GetSerialNumber() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_serial_number)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_binary_value_t* _retval = _struct->get_serial_number(_struct); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + +CefTime CefX509CertificateCToCpp::GetValidStart() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_valid_start)) + return CefTime(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_time_t _retval = _struct->get_valid_start(_struct); + + // Return type: simple + return _retval; +} + +CefTime CefX509CertificateCToCpp::GetValidExpiry() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_valid_expiry)) + return CefTime(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_time_t _retval = _struct->get_valid_expiry(_struct); + + // Return type: simple + return _retval; +} + +CefRefPtr CefX509CertificateCToCpp::GetDEREncoded() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_derencoded)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_binary_value_t* _retval = _struct->get_derencoded(_struct); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + +CefRefPtr CefX509CertificateCToCpp::GetPEMEncoded() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_pemencoded)) + return NULL; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_binary_value_t* _retval = _struct->get_pemencoded(_struct); + + // Return type: refptr_same + return CefBinaryValueCToCpp::Wrap(_retval); +} + +size_t CefX509CertificateCToCpp::GetIssuerChainSize() { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_issuer_chain_size)) + return 0; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = _struct->get_issuer_chain_size(_struct); + + // Return type: simple + return _retval; +} + +void CefX509CertificateCToCpp::GetDEREncodedIssuerChain( + IssuerChainBinaryList& chain) { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_derencoded_issuer_chain)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: chain; type: refptr_vec_same_byref + size_t chainSize = chain.size(); + size_t chainCount = std::max(GetIssuerChainSize(), chainSize); + cef_binary_value_t** chainList = NULL; + if (chainCount > 0) { + chainList = new cef_binary_value_t*[chainCount]; + DCHECK(chainList); + if (chainList) { + memset(chainList, 0, sizeof(cef_binary_value_t*)*chainCount); + } + if (chainList && chainSize > 0) { + for (size_t i = 0; i < chainSize; ++i) { + chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]); + } + } + } + + // Execute + _struct->get_derencoded_issuer_chain(_struct, + &chainCount, + chainList); + + // Restore param:chain; type: refptr_vec_same_byref + chain.clear(); + if (chainCount > 0 && chainList) { + for (size_t i = 0; i < chainCount; ++i) { + chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i])); + } + delete [] chainList; + } +} + +void CefX509CertificateCToCpp::GetPEMEncodedIssuerChain( + IssuerChainBinaryList& chain) { + cef_x509certificate_t* _struct = GetStruct(); + if (CEF_MEMBER_MISSING(_struct, get_pemencoded_issuer_chain)) + return; + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Translate param: chain; type: refptr_vec_same_byref + size_t chainSize = chain.size(); + size_t chainCount = std::max(GetIssuerChainSize(), chainSize); + cef_binary_value_t** chainList = NULL; + if (chainCount > 0) { + chainList = new cef_binary_value_t*[chainCount]; + DCHECK(chainList); + if (chainList) { + memset(chainList, 0, sizeof(cef_binary_value_t*)*chainCount); + } + if (chainList && chainSize > 0) { + for (size_t i = 0; i < chainSize; ++i) { + chainList[i] = CefBinaryValueCToCpp::Unwrap(chain[i]); + } + } + } + + // Execute + _struct->get_pemencoded_issuer_chain(_struct, + &chainCount, + chainList); + + // Restore param:chain; type: refptr_vec_same_byref + chain.clear(); + if (chainCount > 0 && chainList) { + for (size_t i = 0; i < chainCount; ++i) { + chain.push_back(CefBinaryValueCToCpp::Wrap(chainList[i])); + } + delete [] chainList; + } +} + + +// CONSTRUCTOR - Do not edit by hand. + +CefX509CertificateCToCpp::CefX509CertificateCToCpp() { +} + +template<> cef_x509certificate_t* CefCToCpp::UnwrapDerived( + CefWrapperType type, CefX509Certificate* c) { + NOTREACHED() << "Unexpected class type: " << type; + return NULL; +} + +#if DCHECK_IS_ON() +template<> base::AtomicRefCount CefCToCpp::DebugObjCt = 0; +#endif + +template<> CefWrapperType CefCToCpp::kWrapperType = + WT_X509CERTIFICATE; diff --git a/libcef_dll/ctocpp/x509certificate_ctocpp.h b/libcef_dll/ctocpp/x509certificate_ctocpp.h new file mode 100644 index 000000000..d5f2f024d --- /dev/null +++ b/libcef_dll/ctocpp/x509certificate_ctocpp.h @@ -0,0 +1,47 @@ +// 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_CTOCPP_X509CERTIFICATE_CTOCPP_H_ +#define CEF_LIBCEF_DLL_CTOCPP_X509CERTIFICATE_CTOCPP_H_ +#pragma once + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef_x509_certificate.h" +#include "include/capi/cef_x509_certificate_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefX509CertificateCToCpp + : public CefCToCpp { + public: + CefX509CertificateCToCpp(); + + // CefX509Certificate methods. + CefRefPtr GetSubject() OVERRIDE; + CefRefPtr GetIssuer() OVERRIDE; + CefRefPtr GetSerialNumber() OVERRIDE; + CefTime GetValidStart() OVERRIDE; + CefTime GetValidExpiry() OVERRIDE; + CefRefPtr GetDEREncoded() OVERRIDE; + CefRefPtr GetPEMEncoded() OVERRIDE; + size_t GetIssuerChainSize() OVERRIDE; + void GetDEREncodedIssuerChain(IssuerChainBinaryList& chain) OVERRIDE; + void GetPEMEncodedIssuerChain(IssuerChainBinaryList& chain) OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // CEF_LIBCEF_DLL_CTOCPP_X509CERTIFICATE_CTOCPP_H_ diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index 6a49e8fdf..00e254668 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -24,6 +24,8 @@ #include "include/capi/cef_process_util_capi.h" #include "include/cef_scheme.h" #include "include/capi/cef_scheme_capi.h" +#include "include/cef_ssl_info.h" +#include "include/capi/cef_ssl_info_capi.h" #include "include/cef_task.h" #include "include/capi/cef_task_capi.h" #include "include/cef_trace.h" @@ -69,8 +71,8 @@ #include "libcef_dll/cpptoc/process_message_cpptoc.h" #include "libcef_dll/cpptoc/request_callback_cpptoc.h" #include "libcef_dll/cpptoc/run_context_menu_callback_cpptoc.h" -#include "libcef_dll/cpptoc/sslcert_principal_cpptoc.h" #include "libcef_dll/cpptoc/sslinfo_cpptoc.h" +#include "libcef_dll/cpptoc/sslstatus_cpptoc.h" #include "libcef_dll/cpptoc/scheme_registrar_cpptoc.h" #include "libcef_dll/cpptoc/views/scroll_view_cpptoc.h" #include "libcef_dll/cpptoc/stream_reader_cpptoc.h" @@ -87,6 +89,8 @@ #include "libcef_dll/cpptoc/views/view_cpptoc.h" #include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" #include "libcef_dll/cpptoc/views/window_cpptoc.h" +#include "libcef_dll/cpptoc/x509cert_principal_cpptoc.h" +#include "libcef_dll/cpptoc/x509certificate_cpptoc.h" #include "libcef_dll/cpptoc/xml_reader_cpptoc.h" #include "libcef_dll/cpptoc/zip_reader_cpptoc.h" #include "libcef_dll/ctocpp/app_ctocpp.h" @@ -297,8 +301,8 @@ CEF_EXPORT void cef_shutdown() { &CefRunContextMenuCallbackCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero( &CefRunFileDialogCallbackCToCpp::DebugObjCt)); - DCHECK(base::AtomicRefCountIsZero(&CefSSLCertPrincipalCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefSSLInfoCppToC::DebugObjCt)); + DCHECK(base::AtomicRefCountIsZero(&CefSSLStatusCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero( &CefSchemeHandlerFactoryCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefSchemeRegistrarCppToC::DebugObjCt)); @@ -331,6 +335,8 @@ CEF_EXPORT void cef_shutdown() { DCHECK(base::AtomicRefCountIsZero(&CefWindowCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefWindowDelegateCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefWriteHandlerCToCpp::DebugObjCt)); + DCHECK(base::AtomicRefCountIsZero(&CefX509CertPrincipalCppToC::DebugObjCt)); + DCHECK(base::AtomicRefCountIsZero(&CefX509CertificateCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefXmlReaderCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefZipReaderCppToC::DebugObjCt)); #endif // DCHECK_IS_ON() @@ -786,6 +792,28 @@ CEF_EXPORT int cef_clear_scheme_handler_factories() { return _retval; } +CEF_EXPORT int cef_is_cert_status_error(cef_cert_status_t status) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefIsCertStatusError( + status); + + // Return type: bool + return _retval; +} + +CEF_EXPORT int cef_is_cert_status_minor_error(cef_cert_status_t status) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + bool _retval = CefIsCertStatusMinorError( + status); + + // Return type: bool + return _retval; +} + CEF_EXPORT int cef_currently_on(cef_thread_id_t threadId) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index ecb268ed8..b9badb1cc 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -24,6 +24,8 @@ #include "include/capi/cef_process_util_capi.h" #include "include/cef_scheme.h" #include "include/capi/cef_scheme_capi.h" +#include "include/cef_ssl_info.h" +#include "include/capi/cef_ssl_info_capi.h" #include "include/cef_task.h" #include "include/capi/cef_task_capi.h" #include "include/cef_trace.h" @@ -121,8 +123,8 @@ #include "libcef_dll/ctocpp/process_message_ctocpp.h" #include "libcef_dll/ctocpp/request_callback_ctocpp.h" #include "libcef_dll/ctocpp/run_context_menu_callback_ctocpp.h" -#include "libcef_dll/ctocpp/sslcert_principal_ctocpp.h" #include "libcef_dll/ctocpp/sslinfo_ctocpp.h" +#include "libcef_dll/ctocpp/sslstatus_ctocpp.h" #include "libcef_dll/ctocpp/scheme_registrar_ctocpp.h" #include "libcef_dll/ctocpp/views/scroll_view_ctocpp.h" #include "libcef_dll/ctocpp/stream_reader_ctocpp.h" @@ -139,6 +141,8 @@ #include "libcef_dll/ctocpp/views/view_ctocpp.h" #include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" #include "libcef_dll/ctocpp/views/window_ctocpp.h" +#include "libcef_dll/ctocpp/x509cert_principal_ctocpp.h" +#include "libcef_dll/ctocpp/x509certificate_ctocpp.h" #include "libcef_dll/ctocpp/xml_reader_ctocpp.h" #include "libcef_dll/ctocpp/zip_reader_ctocpp.h" #include "libcef_dll/transfer_util.h" @@ -289,8 +293,8 @@ CEF_GLOBAL void CefShutdown() { &CefRunContextMenuCallbackCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero( &CefRunFileDialogCallbackCppToC::DebugObjCt)); - DCHECK(base::AtomicRefCountIsZero(&CefSSLCertPrincipalCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefSSLInfoCToCpp::DebugObjCt)); + DCHECK(base::AtomicRefCountIsZero(&CefSSLStatusCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero( &CefSchemeHandlerFactoryCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefSchemeRegistrarCToCpp::DebugObjCt)); @@ -323,6 +327,8 @@ CEF_GLOBAL void CefShutdown() { DCHECK(base::AtomicRefCountIsZero(&CefWindowCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefWindowDelegateCppToC::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefWriteHandlerCppToC::DebugObjCt)); + DCHECK(base::AtomicRefCountIsZero(&CefX509CertPrincipalCToCpp::DebugObjCt)); + DCHECK(base::AtomicRefCountIsZero(&CefX509CertificateCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefXmlReaderCToCpp::DebugObjCt)); DCHECK(base::AtomicRefCountIsZero(&CefZipReaderCToCpp::DebugObjCt)); #endif // DCHECK_IS_ON() @@ -730,6 +736,28 @@ CEF_GLOBAL bool CefClearSchemeHandlerFactories() { return _retval?true:false; } +CEF_GLOBAL bool CefIsCertStatusError(cef_cert_status_t status) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_is_cert_status_error( + status); + + // Return type: bool + return _retval?true:false; +} + +CEF_GLOBAL bool CefIsCertStatusMinorError(cef_cert_status_t status) { + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + int _retval = cef_is_cert_status_minor_error( + status); + + // Return type: bool + return _retval?true:false; +} + CEF_GLOBAL bool CefCurrentlyOn(CefThreadId threadId) { // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING diff --git a/libcef_dll/wrapper_types.h b/libcef_dll/wrapper_types.h index f8783de50..c4ad50b8e 100644 --- a/libcef_dll/wrapper_types.h +++ b/libcef_dll/wrapper_types.h @@ -100,8 +100,8 @@ enum CefWrapperType { WT_RESPONSE_FILTER, WT_RUN_CONTEXT_MENU_CALLBACK, WT_RUN_FILE_DIALOG_CALLBACK, - WT_SSLCERT_PRINCIPAL, WT_SSLINFO, + WT_SSLSTATUS, WT_SCHEME_HANDLER_FACTORY, WT_SCHEME_REGISTRAR, WT_SCROLL_VIEW, @@ -137,6 +137,8 @@ enum CefWrapperType { WT_WINDOW, WT_WINDOW_DELEGATE, WT_WRITE_HANDLER, + WT_X509CERT_PRINCIPAL, + WT_X509CERTIFICATE, WT_XML_READER, WT_ZIP_READER, }; diff --git a/tests/cefclient/browser/client_handler.cc b/tests/cefclient/browser/client_handler.cc index 453c21914..dfa2698eb 100644 --- a/tests/cefclient/browser/client_handler.cc +++ b/tests/cefclient/browser/client_handler.cc @@ -14,6 +14,8 @@ #include "include/cef_browser.h" #include "include/cef_frame.h" #include "include/cef_parser.h" +#include "include/cef_ssl_status.h" +#include "include/cef_x509_certificate.h" #include "include/wrapper/cef_closure_task.h" #include "cefclient/browser/main_context.h" #include "cefclient/browser/resource_util.h" @@ -36,6 +38,7 @@ enum client_menu_ids { CLIENT_ID_SHOW_DEVTOOLS = MENU_ID_USER_FIRST, CLIENT_ID_CLOSE_DEVTOOLS, CLIENT_ID_INSPECT_ELEMENT, + CLIENT_ID_SHOW_SSL_INFO, CLIENT_ID_TESTMENU_SUBMENU, CLIENT_ID_TESTMENU_CHECKITEM, CLIENT_ID_TESTMENU_RADIOITEM1, @@ -82,8 +85,10 @@ std::string GetBinaryString(CefRefPtr value) { return CefBase64Encode(src.data(), src.size()); } +#define FLAG(flag) if (status & flag) result += std::string(#flag) + "
" +#define VALUE(val,def) if (val == def) return std::string(#def) + std::string GetCertStatusString(cef_cert_status_t status) { - #define FLAG(flag) if (status & flag) result += std::string(#flag) + "
" std::string result; FLAG(CERT_STATUS_COMMON_NAME_INVALID); @@ -109,6 +114,29 @@ std::string GetCertStatusString(cef_cert_status_t status) { return result; } +std::string GetSSLVersionString(cef_ssl_version_t version) { + VALUE(version, SSL_CONNECTION_VERSION_UNKNOWN); + VALUE(version, SSL_CONNECTION_VERSION_SSL2); + VALUE(version, SSL_CONNECTION_VERSION_SSL3); + VALUE(version, SSL_CONNECTION_VERSION_TLS1); + VALUE(version, SSL_CONNECTION_VERSION_TLS1_1); + VALUE(version, SSL_CONNECTION_VERSION_TLS1_2); + VALUE(version, SSL_CONNECTION_VERSION_QUIC); + return std::string(); +} + +std::string GetContentStatusString(cef_ssl_content_status_t status) { + std::string result; + + VALUE(status, SSL_CONTENT_NORMAL_CONTENT); + FLAG(SSL_CONTENT_DISPLAYED_INSECURE_CONTENT); + FLAG(SSL_CONTENT_RAN_INSECURE_CONTENT); + + if (result.empty()) + return " "; + return result; +} + // Load a data: URI containing the error message. void LoadErrorPage(CefRefPtr frame, const std::string& failed_url, @@ -129,6 +157,58 @@ void LoadErrorPage(CefRefPtr frame, frame->LoadURL(test_runner::GetDataURI(ss.str(), "text/html")); } +// Return HTML string with information about a certificate. +std::string GetCertificateInformation(CefRefPtr cert, + cef_cert_status_t certstatus) { + CefRefPtr subject = cert->GetSubject(); + CefRefPtr issuer = cert->GetIssuer(); + + // Build a table showing certificate information. Various types of invalid + // certificates can be tested using https://badssl.com/. + std::stringstream ss; + ss << "

X.509 Certificate Information:

" + ""; + + if (certstatus != CERT_STATUS_NONE) { + ss << ""; + } + + ss << "" + "" + "" << + "" + ""; + + CefX509Certificate::IssuerChainBinaryList der_chain_list; + CefX509Certificate::IssuerChainBinaryList pem_chain_list; + cert->GetDEREncodedIssuerChain(der_chain_list); + cert->GetPEMEncodedIssuerChain(pem_chain_list); + DCHECK_EQ(der_chain_list.size(), pem_chain_list.size()); + + der_chain_list.insert(der_chain_list.begin(), cert->GetDEREncoded()); + pem_chain_list.insert(pem_chain_list.begin(), cert->GetPEMEncoded()); + + for (size_t i = 0U; i < der_chain_list.size(); ++i) { + ss << "" + "" + "" + ""; + } + + ss << "
FieldValue
Status" << + GetCertStatusString(certstatus) << "
Subject" << + (subject.get() ? subject->GetDisplayName().ToString() : " ") << + "
Issuer" << + (issuer.get() ? issuer->GetDisplayName().ToString() : " ") << + "
Serial #*" << + GetBinaryString(cert->GetSerialNumber()) << "
Valid Start" << + GetTimeString(cert->GetValidStart()) << "
Valid Expiry" << + GetTimeString(cert->GetValidExpiry()) << "
DER Encoded*" << + GetBinaryString(der_chain_list[i]) << "
PEM Encoded*" << + GetBinaryString(pem_chain_list[i]) << "
* Displayed value is base64 encoded."; + return ss.str(); +} + } // namespace @@ -237,6 +317,11 @@ void ClientHandler::OnBeforeContextMenu( model->AddSeparator(); model->AddItem(CLIENT_ID_INSPECT_ELEMENT, "Inspect Element"); + if (HasSSLInformation(browser)) { + model->AddSeparator(); + model->AddItem(CLIENT_ID_SHOW_SSL_INFO, "Show SSL information"); + } + // Test context menu features. BuildTestMenu(model); } @@ -260,6 +345,9 @@ bool ClientHandler::OnContextMenuCommand( case CLIENT_ID_INSPECT_ELEMENT: ShowDevTools(browser, CefPoint(params->GetXCoord(), params->GetYCoord())); return true; + case CLIENT_ID_SHOW_SSL_INFO: + ShowSSLInformation(browser); + return true; default: // Allow default handling, if any. return ExecuteTestMenu(command_id); } @@ -602,52 +690,13 @@ bool ClientHandler::OnCertificateError( CefRefPtr callback) { CEF_REQUIRE_UI_THREAD(); - CefRefPtr subject = ssl_info->GetSubject(); - CefRefPtr issuer = ssl_info->GetIssuer(); - - // Build a table showing certificate information. Various types of invalid - // certificates can be tested using https://badssl.com/. - std::stringstream ss; - ss << "X.509 Certificate Information:" - "" << - "" - "" - "" - "" - "" - ""; - - CefSSLInfo::IssuerChainBinaryList der_chain_list; - CefSSLInfo::IssuerChainBinaryList pem_chain_list; - ssl_info->GetDEREncodedIssuerChain(der_chain_list); - ssl_info->GetPEMEncodedIssuerChain(pem_chain_list); - DCHECK_EQ(der_chain_list.size(), pem_chain_list.size()); - - der_chain_list.insert(der_chain_list.begin(), ssl_info->GetDEREncoded()); - pem_chain_list.insert(pem_chain_list.begin(), ssl_info->GetPEMEncoded()); - - for (size_t i = 0U; i < der_chain_list.size(); ++i) { - ss << "" - "" - "" - ""; + CefRefPtr cert = ssl_info->GetX509Certificate(); + if (cert.get()) { + // Load the error page. + LoadErrorPage(browser->GetMainFrame(), request_url, cert_error, + GetCertificateInformation(cert, ssl_info->GetCertStatus())); } - ss << "
FieldValue
Subject" << - (subject.get() ? subject->GetDisplayName().ToString() : " ") << - "
Issuer" << - (issuer.get() ? issuer->GetDisplayName().ToString() : " ") << - "
Serial #*" << - GetBinaryString(ssl_info->GetSerialNumber()) << "
Status" << - GetCertStatusString(ssl_info->GetCertStatus()) << "
Valid Start" << - GetTimeString(ssl_info->GetValidStart()) << "
Valid Expiry" << - GetTimeString(ssl_info->GetValidExpiry()) << "
DER Encoded*" << - GetBinaryString(der_chain_list[i]) << "
PEM Encoded*" << - GetBinaryString(pem_chain_list[i]) << "
* Displayed value is base64 encoded."; - - // Load the error page. - LoadErrorPage(browser->GetMainFrame(), request_url, cert_error, ss.str()); - return false; // Cancel the request. } @@ -724,6 +773,56 @@ void ClientHandler::CloseDevTools(CefRefPtr browser) { browser->GetHost()->CloseDevTools(); } +bool ClientHandler::HasSSLInformation(CefRefPtr browser) { + CefRefPtr nav = + browser->GetHost()->GetVisibleNavigationEntry(); + + return (nav && nav->GetSSLStatus() && + nav->GetSSLStatus()->IsSecureConnection()); +} + +void ClientHandler::ShowSSLInformation(CefRefPtr browser) { + std::stringstream ss; + CefRefPtr nav = + browser->GetHost()->GetVisibleNavigationEntry(); + if (!nav) + return; + + CefRefPtr ssl = nav->GetSSLStatus(); + if (!ssl) + return; + + ss << "SSL Information" + "" + "

SSL Connection

" << + ""; + + CefURLParts urlparts; + if (CefParseURL(nav->GetURL(), urlparts)) { + CefString port(&urlparts.port); + ss << ""; + } + + ss << ""; + ss << ""; + + ss << "
FieldValue
Server" << CefString(&urlparts.host).ToString(); + if (!port.empty()) + ss << ":" << port.ToString(); + ss << "
SSL Version" << + GetSSLVersionString(ssl->GetSSLVersion()) << "
Content Status" << + GetContentStatusString(ssl->GetContentStatus()) << "
"; + + CefRefPtr cert = ssl->GetX509Certificate(); + if (cert.get()) + ss << GetCertificateInformation(cert, ssl->GetCertStatus()); + + ss << ""; + + MainContext::Get()->GetRootWindowManager()->CreateRootWindow( + false, is_osr(), CefRect(), + test_runner::GetDataURI(ss.str(), "text/html")); +} bool ClientHandler::CreatePopupWindow( CefRefPtr browser, diff --git a/tests/cefclient/browser/client_handler.h b/tests/cefclient/browser/client_handler.h index a1c795625..cfdce0912 100644 --- a/tests/cefclient/browser/client_handler.h +++ b/tests/cefclient/browser/client_handler.h @@ -266,6 +266,12 @@ class ClientHandler : public CefClient, // Close the existing DevTools popup window, if any. void CloseDevTools(CefRefPtr browser); + // Test if the current site has SSL information available. + bool HasSSLInformation(CefRefPtr browser); + + // Show SSL information for the current site. + void ShowSSLInformation(CefRefPtr browser); + // Returns the Delegate. Delegate* delegate() const { return delegate_; }