From e5c7fd1c5515b920b1ac4c8e1bbdf3a4bab00252 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Sat, 18 May 2019 21:30:06 +0300 Subject: [PATCH] Add NetworkService support for CefLoadCRLSetsFile (fixes issue #2497, see issue #2622). --- libcef/browser/net/crlset_file_util_impl.cc | 31 ++++++++++----------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libcef/browser/net/crlset_file_util_impl.cc b/libcef/browser/net/crlset_file_util_impl.cc index 7abd68537..d8ccdc0df 100644 --- a/libcef/browser/net/crlset_file_util_impl.cc +++ b/libcef/browser/net/crlset_file_util_impl.cc @@ -6,20 +6,19 @@ #include "libcef/browser/context.h" #include "libcef/browser/thread_util.h" +#include "libcef/common/net_service/util.h" #include "base/files/file_util.h" #include "base/logging.h" -#include "base/threading/thread_restrictions.h" -#include "net/cert/crl_set.h" -#include "net/ssl/ssl_config_service.h" +#include "content/public/browser/network_service_instance.h" +#include "services/network/network_service.h" namespace { -// Based on chrome/browser/net/crl_set_fetcher.cc. - -void SetCRLSetIfNewer(scoped_refptr crl_set) { - CEF_REQUIRE_IOT(); - // TODO(cef): Re-implement via NetworkService. +void UpdateCRLSet(const std::string& crl_set_bytes) { + CEF_REQUIRE_UIT(); + content::GetNetworkService()->UpdateCRLSet( + base::as_bytes(base::make_span(crl_set_bytes))); } void LoadFromDisk(const base::FilePath& path) { @@ -31,14 +30,9 @@ void LoadFromDisk(const base::FilePath& path) { return; } - scoped_refptr crl_set; - if (!net::CRLSet::Parse(crl_set_bytes, &crl_set)) { - LOG(WARNING) << "Failed to parse CRL set from " << path.MaybeAsASCII(); - return; - } - - VLOG(1) << "Loaded " << crl_set_bytes.size() << " bytes of CRL set from disk"; - CEF_POST_TASK(CEF_IOT, base::BindOnce(&SetCRLSetIfNewer, crl_set)); + VLOG(1) << "Loading " << crl_set_bytes.size() + << " bytes of CRL set from disk"; + CEF_POST_TASK(CEF_UIT, base::BindOnce(&UpdateCRLSet, crl_set_bytes)); } } // namespace @@ -49,5 +43,10 @@ void CefLoadCRLSetsFile(const CefString& path) { return; } + if (!net_service::IsEnabled()) { + NOTIMPLEMENTED(); + return; + } + CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path)); }