Icinga DB: make error message more helpful if API isn't set up

This commit is contained in:
Julian Brost 2022-06-17 14:37:57 +02:00
parent 323da4f06b
commit 0d0c2678d9

View File

@ -292,7 +292,14 @@ void IcingaDB::InitEnvironmentId()
}
}
} else {
std::shared_ptr<X509> 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<X509> cert = GetX509Certificate(caPath);
unsigned int n;
unsigned char digest[EVP_MAX_MD_SIZE];