From e79bdf333c47952b9f18972f782bc3b4b75ad204 Mon Sep 17 00:00:00 2001 From: Povilas Kanapickas Date: Mon, 1 Nov 2021 04:50:14 +0200 Subject: [PATCH] gui: Fix fingerprint database being not populated due to missing dirs --- src/gui/src/MainWindow.cpp | 5 +++++ src/gui/src/SslCertificate.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/gui/src/MainWindow.cpp b/src/gui/src/MainWindow.cpp index 87f31eb2..7d4a9a5e 100644 --- a/src/gui/src/MainWindow.cpp +++ b/src/gui/src/MainWindow.cpp @@ -444,6 +444,11 @@ void MainWindow::checkFingerprint(const QString& line) auto db_path = barrier::DataDirectories::trusted_servers_ssl_fingerprints_path(); + auto db_dir = db_path.parent_path(); + if (!barrier::fs::exists(db_dir)) { + barrier::fs::create_directories(db_dir); + } + // We compare only SHA256 fingerprints, but show both SHA1 and SHA256 so that the users can // still verify fingerprints on old Barrier servers. This way the only time when we are exposed // to SHA1 vulnerabilities is when the user is reconnecting again. diff --git a/src/gui/src/SslCertificate.cpp b/src/gui/src/SslCertificate.cpp index 26f3b3ee..65ac08a6 100644 --- a/src/gui/src/SslCertificate.cpp +++ b/src/gui/src/SslCertificate.cpp @@ -65,6 +65,11 @@ void SslCertificate::generate_fingerprint(const barrier::fs::path& cert_path) { try { auto local_path = barrier::DataDirectories::local_ssl_fingerprints_path(); + auto local_dir = local_path.parent_path(); + if (!barrier::fs::exists(local_dir)) { + barrier::fs::create_directories(local_dir); + } + barrier::FingerprintDatabase db; db.add_trusted(barrier::get_pem_file_cert_fingerprint(cert_path.u8string(), barrier::FingerprintType::SHA1));