2017-07-11 21:02:44 +02:00
|
|
|
// Copyright 2017 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 "include/cef_file_util.h"
|
|
|
|
|
|
|
|
#include "libcef/browser/context.h"
|
|
|
|
#include "libcef/browser/thread_util.h"
|
|
|
|
|
|
|
|
#include "base/files/file_util.h"
|
|
|
|
#include "base/logging.h"
|
2019-05-18 20:30:06 +02:00
|
|
|
#include "content/public/browser/network_service_instance.h"
|
2023-04-26 21:55:59 +02:00
|
|
|
#include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h"
|
2017-07-11 21:02:44 +02:00
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2019-05-18 20:30:06 +02:00
|
|
|
void UpdateCRLSet(const std::string& crl_set_bytes) {
|
|
|
|
CEF_REQUIRE_UIT();
|
2023-04-26 21:55:59 +02:00
|
|
|
content::GetCertVerifierServiceFactory()->UpdateCRLSet(
|
2020-03-04 01:29:39 +01:00
|
|
|
base::as_bytes(base::make_span(crl_set_bytes)), base::DoNothing());
|
2017-07-11 21:02:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void LoadFromDisk(const base::FilePath& path) {
|
2018-03-20 21:15:08 +01:00
|
|
|
CEF_REQUIRE_BLOCKING();
|
2017-07-11 21:02:44 +02:00
|
|
|
|
|
|
|
std::string crl_set_bytes;
|
|
|
|
if (!base::ReadFileToString(path, &crl_set_bytes)) {
|
|
|
|
LOG(WARNING) << "Failed to read CRL set from " << path.MaybeAsASCII();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-18 20:30:06 +02:00
|
|
|
VLOG(1) << "Loading " << crl_set_bytes.size()
|
|
|
|
<< " bytes of CRL set from disk";
|
|
|
|
CEF_POST_TASK(CEF_UIT, base::BindOnce(&UpdateCRLSet, crl_set_bytes));
|
2017-07-11 21:02:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void CefLoadCRLSetsFile(const CefString& path) {
|
|
|
|
if (!CONTEXT_STATE_VALID()) {
|
2023-05-08 17:07:57 +02:00
|
|
|
DCHECK(false) << "context not valid";
|
2017-07-11 21:02:44 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-03-20 21:15:08 +01:00
|
|
|
CEF_POST_USER_VISIBLE_TASK(base::BindOnce(&LoadFromDisk, path));
|
2017-07-11 21:02:44 +02:00
|
|
|
}
|