aboutsummaryrefslogtreecommitdiffstats
path: root/src/init.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-01-09 20:25:12 +0000
committerSaturneric <[email protected]>2022-01-09 20:25:12 +0000
commit3cff1c7d0cc46d2f10da1f7019d1478f7e0e3eaa (patch)
treed845fa4138d6ebb929116650dec3157d935520c5 /src/init.cpp
parent<feature>(ui, resources): add imap folder support. (diff)
downloadGpgFrontend-3cff1c7d0cc46d2f10da1f7019d1478f7e0e3eaa.tar.gz
GpgFrontend-3cff1c7d0cc46d2f10da1f7019d1478f7e0e3eaa.zip
<fixed>(ui): fix SIGSEGV when closing.
1. Fixed the segfault problem when closing the program (problem with root certificate). 2. Added some code that is executed before the exit function is called, including releasing all the root certificates that have been loaded. 3. Optimized the preloading code of the root certificate.
Diffstat (limited to '')
-rw-r--r--src/init.cpp17
1 files changed, 4 insertions, 13 deletions
diff --git a/src/init.cpp b/src/init.cpp
index e774ab6e..fffaaa1b 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -27,15 +27,6 @@
#include "ui/settings/GlobalSettingStation.h"
-vmime::shared_ptr<vmime::security::cert::X509Certificate> load_x509_cert(
- const boost::filesystem::path& path) {
- auto out_buffer = GpgFrontend::read_all_data_in_file(path.string());
- auto cert = vmime::security::cert::X509Certificate::import(
- reinterpret_cast<const vmime::byte_t*>(out_buffer.data()),
- out_buffer.size());
- return cert;
-}
-
std::vector<boost::filesystem::path> get_files_of_directory(
const boost::filesystem::path& _path) {
namespace fs = boost::filesystem;
@@ -82,12 +73,12 @@ void init_certs() {
root_certs;
auto cert_file_paths = get_files_of_directory(
GpgFrontend::UI::GlobalSettingStation::GetInstance().GetCertsDir());
+
+ auto& _instance = GpgFrontend::UI::GlobalSettingStation::GetInstance();
for (const auto& cert_file_path : cert_file_paths) {
- auto _cert = load_x509_cert(cert_file_path);
- root_certs.push_back(_cert);
+ _instance.AddRootCert(cert_file_path);
}
- LOG(INFO) << _("root certs loaded") << root_certs.size();
- GpgFrontend::UI::GlobalSettingStation::GetInstance().SetRootCerts(root_certs);
+ LOG(INFO) << _("root certs loaded") << _instance.GetRootCerts().size();
}
void init_locale() {