From eda3c3ade304ca1cbdac9ead1152d7939dda149c Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Thu, 6 Sep 2018 15:58:42 +0200 Subject: [PATCH] Improve TLS handshake exception logging refs #6602 --- lib/perfdata/elasticsearchwriter.cpp | 2 +- lib/perfdata/influxdbwriter.cpp | 2 +- lib/remote/apilistener.cpp | 4 ++-- lib/remote/pkiutility.cpp | 5 +++-- lib/remote/pkiutility.hpp | 1 + 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index d9d56b004..c10baf12d 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -434,7 +434,7 @@ void ElasticsearchWriter::SendRequest(const String& body) stream = Connect(); } catch (const std::exception& ex) { Log(LogWarning, "ElasticsearchWriter") - << "Flush failed, cannot connect to Elasticsearch."; + << "Flush failed, cannot connect to Elasticsearch: " << DiagnosticInformation(ex, false); return; } diff --git a/lib/perfdata/influxdbwriter.cpp b/lib/perfdata/influxdbwriter.cpp index 89cf13220..27dd69831 100644 --- a/lib/perfdata/influxdbwriter.cpp +++ b/lib/perfdata/influxdbwriter.cpp @@ -425,7 +425,7 @@ void InfluxdbWriter::Flush() stream = Connect(); } catch (const std::exception& ex) { Log(LogWarning, "InfluxDbWriter") - << "Flush failed, cannot connect to InfluxDB."; + << "Flush failed, cannot connect to InfluxDB: " << DiagnosticInformation(ex, false); return; } diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index c1546710d..f69407edd 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -454,9 +454,9 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri try { tlsStream->Handshake(); - } catch (const std::exception&) { + } catch (const std::exception& ex) { Log(LogCritical, "ApiListener") - << "Client TLS handshake failed (" << conninfo << ")"; + << "Client TLS handshake failed (" << conninfo << "): " << DiagnosticInformation(ex, false); tlsStream->Close(); return; } diff --git a/lib/remote/pkiutility.cpp b/lib/remote/pkiutility.cpp index 20d9ca6c2..915b3ee2e 100644 --- a/lib/remote/pkiutility.cpp +++ b/lib/remote/pkiutility.cpp @@ -187,8 +187,9 @@ int PkiUtility::RequestCertificate(const String& host, const String& port, const try { stream->Handshake(); - } catch (const std::exception&) { - Log(LogCritical, "cli", "Client TLS handshake failed."); + } catch (const std::exception& ex) { + Log(LogCritical, "cli") + << "Client TLS handshake failed: " << DiagnosticInformation(ex, false); return 1; } diff --git a/lib/remote/pkiutility.hpp b/lib/remote/pkiutility.hpp index 500b7be69..7098df3b1 100644 --- a/lib/remote/pkiutility.hpp +++ b/lib/remote/pkiutility.hpp @@ -21,6 +21,7 @@ #define PKIUTILITY_H #include "remote/i2-remote.hpp" +#include "base/exception.hpp" #include "base/dictionary.hpp" #include "base/string.hpp" #include -- 2.40.0