From f7aa318f476a0f79a4c26a54418276f3e79896b8 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 5 Aug 2024 11:05:21 +0200 Subject: authentication: Properly log failures to open certification files --- src/buildtool/auth/authentication.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/buildtool/auth/authentication.hpp b/src/buildtool/auth/authentication.hpp index f06e6a1c..80fe5886 100644 --- a/src/buildtool/auth/authentication.hpp +++ b/src/buildtool/auth/authentication.hpp @@ -15,7 +15,9 @@ #ifndef INCLUDED_SRC_BUILDTOOL_AUTH_AUTHENTICATION_HPP #define INCLUDED_SRC_BUILDTOOL_AUTH_AUTHENTICATION_HPP +#include // for errno #include +#include // for strerror() #include #include #include @@ -201,6 +203,13 @@ class Auth::TLS::Builder final { // if the file does not exist, it will throw an exception auto file = std::filesystem::canonical(x); std::ifstream cert{file}; + if (cert.fail()) { + Logger::Log(LogLevel::Error, + "Certification file {} failed to open with:\n{}", + file.string(), + strerror(errno)); + return std::nullopt; + } std::string tmp((std::istreambuf_iterator(cert)), std::istreambuf_iterator()); return tmp; -- cgit v1.2.3