diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-08-05 11:05:21 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-08-05 11:36:59 +0200 |
commit | f7aa318f476a0f79a4c26a54418276f3e79896b8 (patch) | |
tree | f870dfb5508ea72ff7f1d59b515001e717291642 | |
parent | 7ffc8485306dddc24d963b7993cd66c5ebd346d6 (diff) | |
download | justbuild-f7aa318f476a0f79a4c26a54418276f3e79896b8.tar.gz |
authentication: Properly log failures to open certification files
-rw-r--r-- | src/buildtool/auth/authentication.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
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 <cerrno> // for errno #include <cstdint> +#include <cstring> // for strerror() #include <filesystem> #include <fstream> #include <optional> @@ -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<char>(cert)), std::istreambuf_iterator<char>()); return tmp; |