Make sure icinga works even without SSL.

This commit is contained in:
Gunnar Beutner 2012-05-15 11:08:04 +02:00
parent 925e947a98
commit bcaff12d20
3 changed files with 21 additions and 16 deletions

View File

@ -0,0 +1,9 @@
{
"icinga": {
"icinga": {
}
},
"component": {
"demo": { }
}
}

View 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());

View 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 (!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);
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);
shared_ptr<SSL_CTX> sslContext = Utility::MakeSSLContext(GetPublicKeyFile(), GetPrivateKeyFile(), GetCAKeyFile());
m_EndpointManager->SetSSLContext(sslContext);
}
/* create the primary RPC listener */
string service = GetService();