diff --git a/lib/cli/consolecommand.cpp b/lib/cli/consolecommand.cpp index c259711ad..0e7dea49e 100644 --- a/lib/cli/consolecommand.cpp +++ b/lib/cli/consolecommand.cpp @@ -527,10 +527,9 @@ Shared::Ptr ConsoleCommand::Connect() Shared::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; } diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 1b3e7bf90..f797f3f35 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -605,10 +605,9 @@ OptionalTlsStream ElasticsearchWriter::Connect() Shared::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; } diff --git a/lib/perfdata/gelfwriter.cpp b/lib/perfdata/gelfwriter.cpp index 7210731d9..cac722051 100644 --- a/lib/perfdata/gelfwriter.cpp +++ b/lib/perfdata/gelfwriter.cpp @@ -177,10 +177,9 @@ void GelfWriter::ReconnectInternal() Shared::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; } diff --git a/lib/perfdata/influxdbcommonwriter.cpp b/lib/perfdata/influxdbcommonwriter.cpp index 7d25ba129..34f0f36f8 100644 --- a/lib/perfdata/influxdbcommonwriter.cpp +++ b/lib/perfdata/influxdbcommonwriter.cpp @@ -152,10 +152,9 @@ OptionalTlsStream InfluxdbCommonWriter::Connect() Shared::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; } diff --git a/lib/remote/pkiutility.cpp b/lib/remote/pkiutility.cpp index bc108b980..38ca1cd0b 100644 --- a/lib/remote/pkiutility.cpp +++ b/lib/remote/pkiutility.cpp @@ -86,12 +86,10 @@ std::shared_ptr PkiUtility::FetchCert(const String& host, const String& po Shared::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(); } @@ -154,12 +152,10 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const Shared::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; } diff --git a/plugins/check_nscp_api.cpp b/plugins/check_nscp_api.cpp index 6d55ea4f6..bf5521d00 100644 --- a/plugins/check_nscp_api.cpp +++ b/plugins/check_nscp_api.cpp @@ -179,10 +179,9 @@ static Shared::Ptr Connect(const String& host, const String& port Shared::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; }