diff --git a/README.md b/README.md index f736baef..9e2cc4fa 100644 --- a/README.md +++ b/README.md @@ -474,6 +474,7 @@ Additional information for v31.2 release: * [GetVersion](api/cefpython.md#getversion) * [Initialize](api/cefpython.md#initialize) * [IsThread](api/cefpython.md#isthread) + * [LoadCrlSetsFile](api/cefpython.md#loadcrlsetsfile) * [MessageLoop](api/cefpython.md#messageloop) * [MessageLoopWork](api/cefpython.md#messageloopwork) * [PostTask](api/cefpython.md#posttask) diff --git a/api/API-index.md b/api/API-index.md index 050fb753..9946b5b5 100644 --- a/api/API-index.md +++ b/api/API-index.md @@ -162,6 +162,7 @@ * [GetVersion](cefpython.md#getversion) * [Initialize](cefpython.md#initialize) * [IsThread](cefpython.md#isthread) + * [LoadCrlSetsFile](cefpython.md#loadcrlsetsfile) * [MessageLoop](cefpython.md#messageloop) * [MessageLoopWork](cefpython.md#messageloopwork) * [PostTask](cefpython.md#posttask) diff --git a/api/cefpython.md b/api/cefpython.md index efeed621..239bf400 100644 --- a/api/cefpython.md +++ b/api/cefpython.md @@ -21,6 +21,7 @@ Table of contents: * [GetVersion](#getversion) * [Initialize](#initialize) * [IsThread](#isthread) + * [LoadCrlSetsFile](#loadcrlsetsfile) * [MessageLoop](#messageloop) * [MessageLoopWork](#messageloopwork) * [PostTask](#posttask) @@ -200,6 +201,22 @@ CEF maintains multiple internal threads that are used for handling different typ See PostTask() for a list of threads. +### LoadCrlSetsFile + +| Parameter | Type | +| --- | --- | +| path | bytes | +| __Return__ | bool | + +Description from upstream CEF: +> Loads the existing "Certificate Revocation Lists" file that is managed by +> Google Chrome. This file can generally be found in Chrome's User Data +> directory (e.g. "C:\Users\[User]\AppData\Local\Google\Chrome\User Data\" on +> Windows) and is updated periodically by Chrome's component updater service. +> Must be called in the browser process after the context has been initialized. +> See https://dev.chromium.org/Home/chromium-security/crlsets for background. + + ### MessageLoop | | | diff --git a/src/cef_v59..v66_changes.txt b/src/cef_v59..v66_changes.txt index a0429e0c..e6dbfb2c 100644 --- a/src/cef_v59..v66_changes.txt +++ b/src/cef_v59..v66_changes.txt @@ -134,7 +134,7 @@ cef_extension_handler.h - CefExtensionHandler cef_file_util.h -- CefLoadCRLSetsFile ++ CefLoadCRLSetsFile cef_request_handler.h - CanGetCookies diff --git a/src/cefpython.pyx b/src/cefpython.pyx index cf7d7e46..5a526bcd 100644 --- a/src/cefpython.pyx +++ b/src/cefpython.pyx @@ -300,6 +300,7 @@ from main_message_loop cimport * # noinspection PyUnresolvedReferences from cef_views cimport * from cef_log cimport * +from cef_file_util cimport * # ----------------------------------------------------------------------------- # GLOBAL VARIABLES @@ -1019,3 +1020,6 @@ cpdef dict GetVersion(): cef_commit_hash=__cef_commit_hash__, cef_commit_number=__cef_commit_number__, ) + +cpdef LoadCrlSetsFile(py_string path): + CefLoadCRLSetsFile(PyToCefStringValue(path)) diff --git a/src/extern/cef/cef_file_util.pxd b/src/extern/cef/cef_file_util.pxd new file mode 100644 index 00000000..52e62580 --- /dev/null +++ b/src/extern/cef/cef_file_util.pxd @@ -0,0 +1,8 @@ +# Copyright (c) 2018 CEF Python, see the Authors file. +# All rights reserved. Licensed under BSD 3-clause license. +# Project website: https://github.com/cztomczak/cefpython + +from cef_string cimport CefString + +cdef extern from "include/cef_file_util.h": + void CefLoadCRLSetsFile(const CefString& path) diff --git a/src/utils.pyx b/src/utils.pyx index 03bfd1e3..0e499554 100644 --- a/src/utils.pyx +++ b/src/utils.pyx @@ -3,6 +3,7 @@ # Project website: https://github.com/cztomczak/cefpython include "cefpython.pyx" +include "string_utils.pyx" # noinspection PyUnresolvedReferences cimport cef_types diff --git a/unittests/main_test.py b/unittests/main_test.py index 3ffd1d4f..0640b2d3 100644 --- a/unittests/main_test.py +++ b/unittests/main_test.py @@ -11,6 +11,7 @@ from cefpython3 import cefpython as cef +import glob import os import sys @@ -126,15 +127,39 @@ def test_main(self): # Test initialization of CEF settings = { "debug": False, - "log_severity": cef.LOGSEVERITY_ERROR, + "log_severity": cef.LOGSEVERITY_WARNING, "log_file": "", } if "--debug" in sys.argv: settings["debug"] = True settings["log_severity"] = cef.LOGSEVERITY_INFO + if "--debug-warning" in sys.argv: + settings["debug"] = True + settings["log_severity"] = cef.LOGSEVERITY_WARNING cef.Initialize(settings) subtest_message("cef.Initialize() ok") + # CRL set file + certrevoc_dir = "" + if WINDOWS: + certrevoc_dir = r"C:\localappdata\Google\Chrome\User Data" \ + r"\CertificateRevocation" + elif LINUX: + certrevoc_dir = r"/home/*/.config/google-chrome" \ + r"/CertificateRevocation" + elif MAC: + certrevoc_dir = r"/Users/*/Library/Application Support/Google" \ + r"/Chrome/CertificateRevocation" + if os.path.exists(certrevoc_dir): + crlset_files = glob.iglob(os.path.join(certrevoc_dir, "*", + "crl-set")) + crlset = "" + for crlset in crlset_files: + pass + if os.path.exists(crlset): + cef.LoadCrlSetsFile(crlset) + subtest_message("cef.LoadCrlSetsFile ok") + # High DPI on Windows if WINDOWS: self.assertIsInstance(cef.DpiAware.GetSystemDpi(), tuple)