From 9ec6a675bf8fdb7eebfe598753a2b34a7ab7b761 Mon Sep 17 00:00:00 2001 From: Warlockbugs Date: Mon, 15 Jul 2024 20:56:33 +0300 Subject: [PATCH] OpenSSL3: Fix bundled modules search path on Windows Also add error output for module loading problems --- src/mangosd/Main.cpp | 10 ++++++++-- src/realmd/Main.cpp | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/mangosd/Main.cpp b/src/mangosd/Main.cpp index 22c4239f69b..fd4b2e5ba77 100644 --- a/src/mangosd/Main.cpp +++ b/src/mangosd/Main.cpp @@ -34,9 +34,11 @@ #include #include #include +#include #include #include +#include #include @@ -179,16 +181,20 @@ int main(int argc, char* argv[]) DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); // Load OpenSSL 3.0+ providers +#ifdef _WIN32 + // For bundled OpenSSL library + OSSL_PROVIDER_set_default_search_path(nullptr, boost::filesystem::current_path().string().c_str()); +#endif OSSL_PROVIDER* openssl_legacy = OSSL_PROVIDER_load(nullptr, "legacy"); if (!openssl_legacy) { - sLog.outError("OpenSSL3: Failed to load Legacy provider"); + sLog.outError("OpenSSL3: Failed to load Legacy provider: %s", ERR_error_string(ERR_get_error(), NULL)); return 1; } OSSL_PROVIDER* openssl_default = OSSL_PROVIDER_load(nullptr, "default"); if (!openssl_default) { - sLog.outError("OpenSSL3: Failed to load Default provider"); + sLog.outError("OpenSSL3: Failed to load Default provider: %s", ERR_error_string(ERR_get_error(), NULL)); OSSL_PROVIDER_unload(openssl_legacy); return 1; } diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index 0c8ba997b76..663f1bbe90a 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -36,10 +36,12 @@ #include #include #include +#include #include #include #include +#include #include #include @@ -176,16 +178,20 @@ int main(int argc, char* argv[]) DETAIL_LOG("%s (Library: %s)", OPENSSL_VERSION_TEXT, OpenSSL_version(OPENSSL_VERSION)); // Load OpenSSL 3.0+ providers +#ifdef _WIN32 + // For bundled OpenSSL library + OSSL_PROVIDER_set_default_search_path(nullptr, boost::filesystem::current_path().string().c_str()); +#endif OSSL_PROVIDER* openssl_legacy = OSSL_PROVIDER_load(nullptr, "legacy"); if (!openssl_legacy) { - sLog.outError("OpenSSL3: Failed to load Legacy provider"); + sLog.outError("OpenSSL3: Failed to load Legacy provider: %s", ERR_error_string(ERR_get_error(), NULL)); return 1; } OSSL_PROVIDER* openssl_default = OSSL_PROVIDER_load(nullptr, "default"); if (!openssl_default) { - sLog.outError("OpenSSL3: Failed to load Default provider"); + sLog.outError("OpenSSL3: Failed to load Default provider: %s", ERR_error_string(ERR_get_error(), NULL)); OSSL_PROVIDER_unload(openssl_legacy); return 1; }