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];