]> granicus.if.org Git - icinga2/commitdiff
Make sure icinga works even without SSL.
authorGunnar Beutner <gunnar.beutner@netways.de>
Tue, 15 May 2012 09:08:04 +0000 (11:08 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Tue, 15 May 2012 09:08:04 +0000 (11:08 +0200)
icinga-app/icinga-standalone.conf [new file with mode: 0644]
icinga/endpointmanager.cpp
icinga/icingaapplication.cpp

diff --git a/icinga-app/icinga-standalone.conf b/icinga-app/icinga-standalone.conf
new file mode 100644 (file)
index 0000000..ccc2025
--- /dev/null
@@ -0,0 +1,9 @@
+{
+       "icinga": {
+               "icinga": {
+               }
+       },
+       "component": {
+               "demo": { }
+       }
+}
\ No newline at end of file
index 83e2f7b88a1deb5f25be9c49a4ba14772cd4c542..3a20120956fd24803a79adb98fa82da1d629d741 100644 (file)
@@ -43,6 +43,9 @@ shared_ptr<SSL_CTX> 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());
index 8f36f7888fcc63bcf568105879bffaaae42d5bc7..c515cade3854e8e2b9e29573a3f1bb2f6a306285 100644 (file)
@@ -66,23 +66,16 @@ int IcingaApplication::Main(const vector<string>& args)
        fileComponentConfig->SetPropertyInteger("replicate", 0);
        GetConfigHive()->AddObject(fileComponentConfig);
 
-       if (GetPrivateKeyFile().empty())
-               throw InvalidArgumentException("No private key was specified.");
-
-       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<X509> cert = Utility::GetX509Certificate(GetPublicKeyFile());
-       string identity = Utility::GetCertificateCN(cert);
-       Application::Log("My identity: " + identity);
-       m_EndpointManager->SetIdentity(identity);
-
-       shared_ptr<SSL_CTX> sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile());
-       m_EndpointManager->SetSSLContext(sslContext);
+       if (!GetPrivateKeyFile().empty() && !GetPublicKeyFile().empty() && !GetCAKeyFile().empty()) {
+               /* set up SSL context */
+               shared_ptr<X509> cert = Utility::GetX509Certificate(GetPublicKeyFile());
+               string identity = Utility::GetCertificateCN(cert);
+               Application::Log("My identity: " + identity);
+               m_EndpointManager->SetIdentity(identity);
+
+               shared_ptr<SSL_CTX> sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile());
+               m_EndpointManager->SetSSLContext(sslContext);
+       }
 
        /* create the primary RPC listener */
        string service = GetService();