mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 02:07:53 +02:00
Use SetupSslContext() instead of MakeAsioSslContext() everywhere
It does the same and already provides proper exception messages.
This commit is contained in:
parent
7938d60415
commit
fa08e90630
@ -527,10 +527,9 @@ Shared<AsioTlsStream>::Ptr ConsoleCommand::Connect()
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext(Empty, Empty, Empty); //TODO: Add support for cert, key, ca parameters
|
sslContext = SetupSslContext(); //TODO: Add support for cert, key, ca parameters
|
||||||
} catch(const std::exception& ex) {
|
} catch(const std::exception& ex) {
|
||||||
Log(LogCritical, "DebugConsole")
|
Log(LogCritical, "DebugConsole") << ex.what();
|
||||||
<< "Cannot make SSL context: " << ex.what();
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,10 +605,9 @@ OptionalTlsStream ElasticsearchWriter::Connect()
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
sslContext = SetupSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||||
} catch (const std::exception&) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogWarning, "ElasticsearchWriter")
|
Log(LogWarning, "ElasticsearchWriter") << ex.what();
|
||||||
<< "Unable to create SSL context.";
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,10 +177,9 @@ void GelfWriter::ReconnectInternal()
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
sslContext = SetupSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogWarning, "GelfWriter")
|
Log(LogWarning, "GelfWriter") << ex.what();
|
||||||
<< "Unable to create SSL context.";
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,10 +152,9 @@ OptionalTlsStream InfluxdbCommonWriter::Connect()
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext(GetSslCert(), GetSslKey(), GetSslCaCert());
|
sslContext = SetupSslContext(GetSslCert(), GetSslKey(), GetSslCaCert());
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogWarning, GetReflectionType()->GetName())
|
Log(LogWarning, GetReflectionType()->GetName()) << ex.what();
|
||||||
<< "Unable to create SSL context.";
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,12 +86,10 @@ std::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& po
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext();
|
sslContext = SetupSslContext();
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogCritical, "pki")
|
Log(LogCritical, "pki") << ex.what();
|
||||||
<< "Cannot make SSL context.";
|
Log(LogDebug, "pki") << DiagnosticInformation(ex);
|
||||||
Log(LogDebug, "pki")
|
|
||||||
<< "Cannot make SSL context:\n" << DiagnosticInformation(ex);
|
|
||||||
return std::shared_ptr<X509>();
|
return std::shared_ptr<X509>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,12 +152,10 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext(certfile, keyfile);
|
sslContext = SetupSslContext(certfile, keyfile);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
Log(LogCritical, "cli")
|
Log(LogCritical, "cli") << ex.what();
|
||||||
<< "Cannot make SSL context for cert path: '" << certfile << "' key path: '" << keyfile << "' ca path: '" << cafile << "'.";
|
Log(LogDebug, "cli") << DiagnosticInformation(ex);
|
||||||
Log(LogDebug, "cli")
|
|
||||||
<< "Cannot make SSL context for cert path: '" << certfile << "' key path: '" << keyfile << "' ca path: '" << cafile << "':\n" << DiagnosticInformation(ex);
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,10 +179,9 @@ static Shared<AsioTlsStream>::Ptr Connect(const String& host, const String& port
|
|||||||
Shared<TlsContext>::Ptr sslContext;
|
Shared<TlsContext>::Ptr sslContext;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
sslContext = MakeAsioSslContext(Empty, Empty, Empty); //TODO: Add support for cert, key, ca parameters
|
sslContext = SetupSslContext(); //TODO: Add support for cert, key, ca parameters
|
||||||
} catch(const std::exception& ex) {
|
} catch(const std::exception& ex) {
|
||||||
Log(LogCritical, "DebugConsole")
|
Log(LogCritical, "DebugConsole") << ex.what();
|
||||||
<< "Cannot make SSL context: " << ex.what();
|
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user