From eaeacbd8de1443731c26595f6ee0f6e844529579 Mon Sep 17 00:00:00 2001 From: Mackenzie <41524393+Mack29446@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:23:28 +0100 Subject: [PATCH 1/2] log non-200 status codes --- src/Network/Http.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Network/Http.cpp b/src/Network/Http.cpp index 6f9b746..6ca7310 100644 --- a/src/Network/Http.cpp +++ b/src/Network/Http.cpp @@ -81,7 +81,7 @@ std::string HTTP::Get(const std::string& IP) { Ret = res->body; } else { WriteHttpDebug(cli, "GET", IP, res); - error("Failed to GET '" + IP + "': " + res->reason + ", ssl verify = " + std::to_string(cli.get_openssl_verify_result())); + error("Failed to GET (status " + std::to_string(res->status) + ") '" + IP + "': " + res->reason + ", ssl verify = " + std::to_string(cli.get_openssl_verify_result())); } } else { if (isDownload) { From ede6fcd7dd23e74ad69cc3c5e55fcbaf3ca83e74 Mon Sep 17 00:00:00 2001 From: Mackenzie <41524393+Mack29446@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:33:14 +0100 Subject: [PATCH 2/2] log SSL errors --- src/Network/Http.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Network/Http.cpp b/src/Network/Http.cpp index 6ca7310..1769e62 100644 --- a/src/Network/Http.cpp +++ b/src/Network/Http.cpp @@ -87,8 +87,14 @@ std::string HTTP::Get(const std::string& IP) { if (isDownload) { std::cout << "\n"; } + auto result = cli.get_openssl_verify_result(); + std::string verify_error; + if (result) { + verify_error = X509_verify_cert_error_string(result); + } + WriteHttpDebug(cli, "GET", IP, res); - error("HTTP Get failed on " + to_string(res.error()) + ", ssl verify = " + std::to_string(cli.get_openssl_verify_result())); + error("HTTP Get failed on " + to_string(res.error()) + ", ssl verify = " + verify_error); } return Ret; @@ -128,8 +134,13 @@ std::string HTTP::Post(const std::string& IP, const std::string& Fields) { } Ret = res->body; } else { + auto result = cli.get_openssl_verify_result(); + std::string verify_error; + if (result) { + verify_error = X509_verify_cert_error_string(result); + } WriteHttpDebug(cli, "POST", IP, res); - error("HTTP Post failed on " + to_string(res.error()) + ", ssl verify = " + std::to_string(cli.get_openssl_verify_result())); + error("HTTP Post failed on " + to_string(res.error()) + ", ssl verify = " + verify_error); } }