Merge pull request #9404 from Icinga/feature/icingadb-no-ca-error-message

Icinga DB: make error message more helpful if API isn't set up
This commit is contained in:
Alexander Aleksandrovič Klimov 2022-06-20 19:36:26 +02:00 committed by GitHub
commit dc571e4d0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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