Skip to content

Commit

Permalink
Add cef.LoadCrlSetsFile (#403)
Browse files Browse the repository at this point in the history
  • Loading branch information
cztomczak committed Aug 19, 2018
1 parent b0e2e8a commit fd8ea5b
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions api/API-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 17 additions & 0 deletions api/cefpython.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Table of contents:
* [GetVersion](#getversion)
* [Initialize](#initialize)
* [IsThread](#isthread)
* [LoadCrlSetsFile](#loadcrlsetsfile)
* [MessageLoop](#messageloop)
* [MessageLoopWork](#messageloopwork)
* [PostTask](#posttask)
Expand Down Expand Up @@ -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

| | |
Expand Down
2 changes: 1 addition & 1 deletion src/cef_v59..v66_changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ cef_extension_handler.h
- CefExtensionHandler

cef_file_util.h
- CefLoadCRLSetsFile
+ CefLoadCRLSetsFile

cef_request_handler.h
- CanGetCookies
Expand Down
4 changes: 4 additions & 0 deletions src/cefpython.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
8 changes: 8 additions & 0 deletions src/extern/cef/cef_file_util.pxd
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions src/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Project website: https://github.com/cztomczak/cefpython

include "cefpython.pyx"
include "string_utils.pyx"

# noinspection PyUnresolvedReferences
cimport cef_types
Expand Down
27 changes: 26 additions & 1 deletion unittests/main_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from cefpython3 import cefpython as cef

import glob
import os
import sys

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fd8ea5b

Please sign in to comment.