Skip to content

Commit fd8ea5b

Browse files
committed
Add cef.LoadCrlSetsFile (cztomczak#403)
1 parent b0e2e8a commit fd8ea5b

File tree

8 files changed

+59
-2
lines changed

8 files changed

+59
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,7 @@ Additional information for v31.2 release:
474474
* [GetVersion](api/cefpython.md#getversion)
475475
* [Initialize](api/cefpython.md#initialize)
476476
* [IsThread](api/cefpython.md#isthread)
477+
* [LoadCrlSetsFile](api/cefpython.md#loadcrlsetsfile)
477478
* [MessageLoop](api/cefpython.md#messageloop)
478479
* [MessageLoopWork](api/cefpython.md#messageloopwork)
479480
* [PostTask](api/cefpython.md#posttask)

api/API-index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@
162162
* [GetVersion](cefpython.md#getversion)
163163
* [Initialize](cefpython.md#initialize)
164164
* [IsThread](cefpython.md#isthread)
165+
* [LoadCrlSetsFile](cefpython.md#loadcrlsetsfile)
165166
* [MessageLoop](cefpython.md#messageloop)
166167
* [MessageLoopWork](cefpython.md#messageloopwork)
167168
* [PostTask](cefpython.md#posttask)

api/cefpython.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Table of contents:
2121
* [GetVersion](#getversion)
2222
* [Initialize](#initialize)
2323
* [IsThread](#isthread)
24+
* [LoadCrlSetsFile](#loadcrlsetsfile)
2425
* [MessageLoop](#messageloop)
2526
* [MessageLoopWork](#messageloopwork)
2627
* [PostTask](#posttask)
@@ -200,6 +201,22 @@ CEF maintains multiple internal threads that are used for handling different typ
200201
See PostTask() for a list of threads.
201202

202203

204+
### LoadCrlSetsFile
205+
206+
| Parameter | Type |
207+
| --- | --- |
208+
| path | bytes |
209+
| __Return__ | bool |
210+
211+
Description from upstream CEF:
212+
> Loads the existing "Certificate Revocation Lists" file that is managed by
213+
> Google Chrome. This file can generally be found in Chrome's User Data
214+
> directory (e.g. "C:\Users\[User]\AppData\Local\Google\Chrome\User Data\" on
215+
> Windows) and is updated periodically by Chrome's component updater service.
216+
> Must be called in the browser process after the context has been initialized.
217+
> See https://dev.chromium.org/Home/chromium-security/crlsets for background.
218+
219+
203220
### MessageLoop
204221

205222
| | |

src/cef_v59..v66_changes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ cef_extension_handler.h
134134
- CefExtensionHandler
135135

136136
cef_file_util.h
137-
- CefLoadCRLSetsFile
137+
+ CefLoadCRLSetsFile
138138

139139
cef_request_handler.h
140140
- CanGetCookies

src/cefpython.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ from main_message_loop cimport *
300300
# noinspection PyUnresolvedReferences
301301
from cef_views cimport *
302302
from cef_log cimport *
303+
from cef_file_util cimport *
303304

304305
# -----------------------------------------------------------------------------
305306
# GLOBAL VARIABLES
@@ -1019,3 +1020,6 @@ cpdef dict GetVersion():
10191020
cef_commit_hash=__cef_commit_hash__,
10201021
cef_commit_number=__cef_commit_number__,
10211022
)
1023+
1024+
cpdef LoadCrlSetsFile(py_string path):
1025+
CefLoadCRLSetsFile(PyToCefStringValue(path))

src/extern/cef/cef_file_util.pxd

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2018 CEF Python, see the Authors file.
2+
# All rights reserved. Licensed under BSD 3-clause license.
3+
# Project website: https://github.com/cztomczak/cefpython
4+
5+
from cef_string cimport CefString
6+
7+
cdef extern from "include/cef_file_util.h":
8+
void CefLoadCRLSetsFile(const CefString& path)

src/utils.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Project website: https://github.com/cztomczak/cefpython
44

55
include "cefpython.pyx"
6+
include "string_utils.pyx"
67

78
# noinspection PyUnresolvedReferences
89
cimport cef_types

unittests/main_test.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from cefpython3 import cefpython as cef
1313

14+
import glob
1415
import os
1516
import sys
1617

@@ -126,15 +127,39 @@ def test_main(self):
126127
# Test initialization of CEF
127128
settings = {
128129
"debug": False,
129-
"log_severity": cef.LOGSEVERITY_ERROR,
130+
"log_severity": cef.LOGSEVERITY_WARNING,
130131
"log_file": "",
131132
}
132133
if "--debug" in sys.argv:
133134
settings["debug"] = True
134135
settings["log_severity"] = cef.LOGSEVERITY_INFO
136+
if "--debug-warning" in sys.argv:
137+
settings["debug"] = True
138+
settings["log_severity"] = cef.LOGSEVERITY_WARNING
135139
cef.Initialize(settings)
136140
subtest_message("cef.Initialize() ok")
137141

142+
# CRL set file
143+
certrevoc_dir = ""
144+
if WINDOWS:
145+
certrevoc_dir = r"C:\localappdata\Google\Chrome\User Data" \
146+
r"\CertificateRevocation"
147+
elif LINUX:
148+
certrevoc_dir = r"/home/*/.config/google-chrome" \
149+
r"/CertificateRevocation"
150+
elif MAC:
151+
certrevoc_dir = r"/Users/*/Library/Application Support/Google" \
152+
r"/Chrome/CertificateRevocation"
153+
if os.path.exists(certrevoc_dir):
154+
crlset_files = glob.iglob(os.path.join(certrevoc_dir, "*",
155+
"crl-set"))
156+
crlset = ""
157+
for crlset in crlset_files:
158+
pass
159+
if os.path.exists(crlset):
160+
cef.LoadCrlSetsFile(crlset)
161+
subtest_message("cef.LoadCrlSetsFile ok")
162+
138163
# High DPI on Windows
139164
if WINDOWS:
140165
self.assertIsInstance(cef.DpiAware.GetSystemDpi(), tuple)

0 commit comments

Comments
 (0)