mirror of https://github.com/Icinga/icinga2.git
Implement TLS support for the GelfWriter
This implements TLS support for the GelfWriter.
This commit is contained in:
parent
d94e300907
commit
90bb423226
|
@ -169,7 +169,30 @@ void GelfWriter::ReconnectInternal()
|
||||||
throw ex;
|
throw ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Stream = new NetworkStream(socket);
|
if (GetEnableTls()) {
|
||||||
|
std::shared_ptr<SSL_CTX> sslContext;
|
||||||
|
|
||||||
|
try {
|
||||||
|
sslContext = MakeSSLContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "GelfWriter")
|
||||||
|
<< "Unable to create SSL context.";
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
TlsStream::Ptr tlsStream = new TlsStream(socket, GetHost(), RoleClient, sslContext);
|
||||||
|
|
||||||
|
try {
|
||||||
|
tlsStream->Handshake();
|
||||||
|
} catch (const std::exception& ex) {
|
||||||
|
Log(LogWarning, "GelfWriter")
|
||||||
|
<< "TLS handshake with host'" << GetHost() << "' on port '" << GetPort() << "' failed.'";
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Stream = tlsStream;
|
||||||
|
} else
|
||||||
|
m_Stream = new NetworkStream(socket);
|
||||||
|
|
||||||
SetConnected(true);
|
SetConnected(true);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,12 @@ class GelfWriter : ConfigObject
|
||||||
[config] bool enable_ha {
|
[config] bool enable_ha {
|
||||||
default {{{ return false; }}}
|
default {{{ return false; }}}
|
||||||
};
|
};
|
||||||
|
[config] bool enable_tls {
|
||||||
|
default {{{ return false; }}}
|
||||||
|
};
|
||||||
|
[config] String ca_path;
|
||||||
|
[config] String cert_path;
|
||||||
|
[config] String key_path;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue