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"
|
|
|
|
#include "base/threading/thread_restrictions.h"
|
|
|
|
#include "net/cert/crl_set.h"
|
|
|
|
#include "net/ssl/ssl_config_service.h"
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// Based on chrome/browser/net/crl_set_fetcher.cc.
|
|
|
|
|
|
|
|
void SetCRLSetIfNewer(scoped_refptr<net::CRLSet> crl_set) {
|
|
|
|
CEF_REQUIRE_IOT();
|
2017-12-07 22:44:24 +01:00
|
|
|
net::SSLConfigService::SetCRLSetIfNewer(crl_set);
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
scoped_refptr<net::CRLSet> crl_set;
|
2018-03-20 21:15:08 +01:00
|
|
|
if (!net::CRLSet::Parse(crl_set_bytes, &crl_set)) {
|
2017-07-11 21:02:44 +02:00
|
|
|
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));
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
void CefLoadCRLSetsFile(const CefString& path) {
|
|
|
|
if (!CONTEXT_STATE_VALID()) {
|
|
|
|
NOTREACHED() << "context not valid";
|
|
|
|
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
|
|
|
}
|