From 0d0c2678d95c1cbb973b3e41e8f8c50057bd636e Mon Sep 17 00:00:00 2001 From: Julian Brost Date: Fri, 17 Jun 2022 14:37:57 +0200 Subject: [PATCH] Icinga DB: make error message more helpful if API isn't set up --- lib/icingadb/icingadb.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/icingadb/icingadb.cpp b/lib/icingadb/icingadb.cpp index 21702f3a8..525be4b71 100644 --- a/lib/icingadb/icingadb.cpp +++ b/lib/icingadb/icingadb.cpp @@ -292,7 +292,14 @@ void IcingaDB::InitEnvironmentId() } } } else { - std::shared_ptr cert = GetX509Certificate(ApiListener::GetDefaultCaPath()); + String caPath = ApiListener::GetDefaultCaPath(); + + if (!Utility::PathExists(caPath)) { + throw std::runtime_error("Cannot find the CA certificate at '" + caPath + "'. " + "Please ensure the ApiListener is enabled first using 'icinga2 api setup'."); + } + + std::shared_ptr cert = GetX509Certificate(caPath); unsigned int n; unsigned char digest[EVP_MAX_MD_SIZE];