diff --git a/icinga-app/icinga-standalone.conf b/icinga-app/icinga-standalone.conf new file mode 100644 index 000000000..ccc2025a3 --- /dev/null +++ b/icinga-app/icinga-standalone.conf @@ -0,0 +1,9 @@ +{ + "icinga": { + "icinga": { + } + }, + "component": { + "demo": { } + } +} \ No newline at end of file diff --git a/icinga/endpointmanager.cpp b/icinga/endpointmanager.cpp index 83e2f7b88..3a2012095 100644 --- a/icinga/endpointmanager.cpp +++ b/icinga/endpointmanager.cpp @@ -43,6 +43,9 @@ shared_ptr EndpointManager::GetSSLContext(void) const void EndpointManager::AddListener(string service) { + if (!GetSSLContext()) + throw InvalidArgumentException("SSL context is required for AddListener()"); + stringstream s; s << "Adding new listener: port " << service; Application::Log(s.str()); diff --git a/icinga/icingaapplication.cpp b/icinga/icingaapplication.cpp index 8f36f7888..c515cade3 100644 --- a/icinga/icingaapplication.cpp +++ b/icinga/icingaapplication.cpp @@ -66,23 +66,16 @@ int IcingaApplication::Main(const vector& args) fileComponentConfig->SetPropertyInteger("replicate", 0); GetConfigHive()->AddObject(fileComponentConfig); - if (GetPrivateKeyFile().empty()) - throw InvalidArgumentException("No private key was specified."); + if (!GetPrivateKeyFile().empty() && !GetPublicKeyFile().empty() && !GetCAKeyFile().empty()) { + /* set up SSL context */ + shared_ptr cert = Utility::GetX509Certificate(GetPublicKeyFile()); + string identity = Utility::GetCertificateCN(cert); + Application::Log("My identity: " + identity); + m_EndpointManager->SetIdentity(identity); - if (GetPublicKeyFile().empty()) - throw InvalidArgumentException("No public certificate was specified."); - - if (GetCAKeyFile().empty()) - throw InvalidArgumentException("No CA certificate was specified."); - - /* set up SSL context */ - shared_ptr cert = Utility::GetX509Certificate(GetPublicKeyFile()); - string identity = Utility::GetCertificateCN(cert); - Application::Log("My identity: " + identity); - m_EndpointManager->SetIdentity(identity); - - shared_ptr sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile()); - m_EndpointManager->SetSSLContext(sslContext); + shared_ptr sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile()); + m_EndpointManager->SetSSLContext(sslContext); + } /* create the primary RPC listener */ string service = GetService();