From ec6dae6abb240c4bc90624909f21ed5eaad63ef2 Mon Sep 17 00:00:00 2001 From: John Date: Thu, 18 May 2023 12:04:42 +0200 Subject: [PATCH] allow late init of ssl --- src/lib/utils/httpclient.cpp | 1 + src/lib/utils/httpclient.h | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/utils/httpclient.cpp b/src/lib/utils/httpclient.cpp index 10b918ce..7460e292 100755 --- a/src/lib/utils/httpclient.cpp +++ b/src/lib/utils/httpclient.cpp @@ -316,6 +316,7 @@ bool HttpClient::parseUrl(const string& url, string* proto, string* host, uint16 bool HttpClient::connect(const string& host, const uint16_t port, bool https, const string& userAgent, const int timeout) { + initialize(); disconnect(); #ifdef HAVE_SSL m_socket = SSLSocket::connect(host, port, https, timeout, m_caFile, m_caPath); diff --git a/src/lib/utils/httpclient.h b/src/lib/utils/httpclient.h index 3c26a463..d8f13603 100755 --- a/src/lib/utils/httpclient.h +++ b/src/lib/utils/httpclient.h @@ -124,8 +124,9 @@ class HttpClient { * Constructor. * @param caFile the CA file to use (uses defaults if neither caFile nor caPath are set), or "#" for insecure. * @param caPath the path with CA files to use (uses defaults if neither caFile nor caPath are set). + * @param init whether to immediately initialize the library (instead of during connect()). */ - explicit HttpClient(const char* caFile = nullptr, const char* caPath = nullptr) : + explicit HttpClient(const char* caFile = nullptr, const char* caPath = nullptr, bool init = true) : #ifdef HAVE_SSL m_https(false), m_caFile(caFile), @@ -133,7 +134,9 @@ class HttpClient { #endif m_socket(nullptr), m_port(0), m_timeout(0), m_bufferSize(0), m_buffer(nullptr) { - initialize(); + if (init) { + initialize(); + } } /**