mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-23 17:57:54 +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;
|
||||
|
||||
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) {
|
||||
Log(LogCritical, "DebugConsole")
|
||||
<< "Cannot make SSL context: " << ex.what();
|
||||
Log(LogCritical, "DebugConsole") << ex.what();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -605,10 +605,9 @@ OptionalTlsStream ElasticsearchWriter::Connect()
|
||||
Shared<TlsContext>::Ptr sslContext;
|
||||
|
||||
try {
|
||||
sslContext = MakeAsioSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||
} catch (const std::exception&) {
|
||||
Log(LogWarning, "ElasticsearchWriter")
|
||||
<< "Unable to create SSL context.";
|
||||
sslContext = SetupSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "ElasticsearchWriter") << ex.what();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -177,10 +177,9 @@ void GelfWriter::ReconnectInternal()
|
||||
Shared<TlsContext>::Ptr sslContext;
|
||||
|
||||
try {
|
||||
sslContext = MakeAsioSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||
sslContext = SetupSslContext(GetCertPath(), GetKeyPath(), GetCaPath());
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, "GelfWriter")
|
||||
<< "Unable to create SSL context.";
|
||||
Log(LogWarning, "GelfWriter") << ex.what();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -152,10 +152,9 @@ OptionalTlsStream InfluxdbCommonWriter::Connect()
|
||||
Shared<TlsContext>::Ptr sslContext;
|
||||
|
||||
try {
|
||||
sslContext = MakeAsioSslContext(GetSslCert(), GetSslKey(), GetSslCaCert());
|
||||
sslContext = SetupSslContext(GetSslCert(), GetSslKey(), GetSslCaCert());
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogWarning, GetReflectionType()->GetName())
|
||||
<< "Unable to create SSL context.";
|
||||
Log(LogWarning, GetReflectionType()->GetName()) << ex.what();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
@ -86,12 +86,10 @@ std::shared_ptr<X509> PkiUtility::FetchCert(const String& host, const String& po
|
||||
Shared<TlsContext>::Ptr sslContext;
|
||||
|
||||
try {
|
||||
sslContext = MakeAsioSslContext();
|
||||
sslContext = SetupSslContext();
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogCritical, "pki")
|
||||
<< "Cannot make SSL context.";
|
||||
Log(LogDebug, "pki")
|
||||
<< "Cannot make SSL context:\n" << DiagnosticInformation(ex);
|
||||
Log(LogCritical, "pki") << ex.what();
|
||||
Log(LogDebug, "pki") << DiagnosticInformation(ex);
|
||||
return std::shared_ptr<X509>();
|
||||
}
|
||||
|
||||
@ -154,12 +152,10 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const
|
||||
Shared<TlsContext>::Ptr sslContext;
|
||||
|
||||
try {
|
||||
sslContext = MakeAsioSslContext(certfile, keyfile);
|
||||
sslContext = SetupSslContext(certfile, keyfile);
|
||||
} catch (const std::exception& ex) {
|
||||
Log(LogCritical, "cli")
|
||||
<< "Cannot make SSL context for cert path: '" << certfile << "' key path: '" << keyfile << "' ca path: '" << cafile << "'.";
|
||||
Log(LogDebug, "cli")
|
||||
<< "Cannot make SSL context for cert path: '" << certfile << "' key path: '" << keyfile << "' ca path: '" << cafile << "':\n" << DiagnosticInformation(ex);
|
||||
Log(LogCritical, "cli") << ex.what();
|
||||
Log(LogDebug, "cli") << DiagnosticInformation(ex);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -179,10 +179,9 @@ static Shared<AsioTlsStream>::Ptr Connect(const String& host, const String& port
|
||||
Shared<TlsContext>::Ptr sslContext;
|
||||
|
||||
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) {
|
||||
Log(LogCritical, "DebugConsole")
|
||||
<< "Cannot make SSL context: " << ex.what();
|
||||
Log(LogCritical, "DebugConsole") << ex.what();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user