From f9889b8c02a5e9c8bf907179b2194d44b4571cab Mon Sep 17 00:00:00 2001 From: Antz Date: Fri, 20 Oct 2023 15:16:16 +0100 Subject: [PATCH] Added OpenSSL3.x support based on the work on @Meltie2013 and @i-am-fyre --- CMakeLists.txt | 4 +++- src/mangosd/CMakeLists.txt | 4 ++++ src/mangosd/mangosd.cpp | 30 ++++++++++++++++++++++++++++++ src/realmd | 2 +- src/shared/Auth/ARC4.cpp | 11 +++++++++++ src/shared/Auth/Sha1.h | 3 +++ src/shared/CMakeLists.txt | 4 ++++ src/tools/Extractor_projects | 2 +- 8 files changed, 57 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ddebbdb5..3e956498e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,7 +17,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -cmake_minimum_required(VERSION 3.12 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18 FATAL_ERROR) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -109,6 +109,8 @@ find_package(DL REQUIRED) find_package(ZLIB QUIET) find_package(BZip2 QUIET) +#static linkage for openssl libs +set(OPENSSL_USE_STATIC_LIBS ON) find_package(OpenSSL REQUIRED) include(${CMAKE_SOURCE_DIR}/cmake/GenRevision.cmake) diff --git a/src/mangosd/CMakeLists.txt b/src/mangosd/CMakeLists.txt index 4f7105ce0..ae5bc7530 100644 --- a/src/mangosd/CMakeLists.txt +++ b/src/mangosd/CMakeLists.txt @@ -77,6 +77,10 @@ target_link_libraries(mangosd $<$:gsoap> Threads::Threads ${OPENSSL_LIBRARIES} +#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) + OpenSSL::Crypto +#endif() + ) install( diff --git a/src/mangosd/mangosd.cpp b/src/mangosd/mangosd.cpp index 27bcdb5a9..b8ce10248 100644 --- a/src/mangosd/mangosd.cpp +++ b/src/mangosd/mangosd.cpp @@ -28,6 +28,9 @@ #include #include +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) +# include +#endif #include #include @@ -391,11 +394,38 @@ int main(int argc, char** argv) sLog.outString("Using configuration file %s.", cfg_file); DETAIL_LOG("Using SSL version: %s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION)); + +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) + OSSL_PROVIDER* legacy; + OSSL_PROVIDER* deflt; + + /* Load Multiple providers into the default (NULL) library context */ + legacy = OSSL_PROVIDER_load(NULL, "legacy"); + if (legacy == NULL) { + sLog.outError("Failed to load OpenSSL 3.x Legacy provider\n"); +#ifdef WIN32 + sLog.outError("\nPlease check you have set the following Enviroment Varible:\n"); + sLog.outError("OPENSSL_MODULES=C:\\OpenSSL-Win64\\bin\n"); + sLog.outError("(where C:\\OpenSSL-Win64\\bin is the location you installed OpenSSL\n"); +#endif + Log::WaitBeforeContinueIfNeed(); + return 0; + } + deflt = OSSL_PROVIDER_load(NULL, "default"); + if (deflt == NULL) { + sLog.outError("Failed to load OpenSSL 3.x Default provider\n"); + OSSL_PROVIDER_unload(legacy); + Log::WaitBeforeContinueIfNeed(); + return 0; + } +#else if (SSLeay() < 0x10100000L || SSLeay() > 0x10200000L) { DETAIL_LOG("WARNING: OpenSSL version may be out of date or unsupported. Logins to server may not work!"); DETAIL_LOG("WARNING: Minimal required version [OpenSSL 1.1.x] and Maximum supported version [OpenSSL 1.2]"); } +#endif + DETAIL_LOG("Using ACE: %s", ACE_VERSION); diff --git a/src/realmd b/src/realmd index 2be26140b..8c08d47a9 160000 --- a/src/realmd +++ b/src/realmd @@ -1 +1 @@ -Subproject commit 2be26140bf3b399259aa2398e2c3939e02a0dd7b +Subproject commit 8c08d47a9a3e6c64007be67074e7c587a5e63e5e diff --git a/src/shared/Auth/ARC4.cpp b/src/shared/Auth/ARC4.cpp index ed9782ff4..b5ce60292 100644 --- a/src/shared/Auth/ARC4.cpp +++ b/src/shared/Auth/ARC4.cpp @@ -24,9 +24,16 @@ */ #include "ARC4.h" +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) +#include +#endif ARC4::ARC4(uint8 len) : m_ctx() { +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) + OSSL_PROVIDER_load(NULL, "legacy"); +#endif + m_ctx = EVP_CIPHER_CTX_new(); EVP_EncryptInit_ex(m_ctx, EVP_rc4(), NULL, NULL, NULL); EVP_CIPHER_CTX_set_key_length(m_ctx, len); @@ -34,6 +41,10 @@ ARC4::ARC4(uint8 len) : m_ctx() ARC4::ARC4(uint8 *seed, uint8 len) : m_ctx() { +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) + OSSL_PROVIDER_load(NULL, "legacy"); +#endif + m_ctx = EVP_CIPHER_CTX_new(); EVP_EncryptInit_ex(m_ctx, EVP_rc4(), NULL, NULL, NULL); EVP_CIPHER_CTX_set_key_length(m_ctx, len); diff --git a/src/shared/Auth/Sha1.h b/src/shared/Auth/Sha1.h index b0489b6b9..770659fb0 100644 --- a/src/shared/Auth/Sha1.h +++ b/src/shared/Auth/Sha1.h @@ -28,6 +28,9 @@ #include "Common/Common.h" #include #include +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) +# include +#endif class BigNumber; diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt index 109bedc3f..7ba6b6a6d 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -236,4 +236,8 @@ target_link_libraries(shared MySQL::MySQL DL::DL ${OPENSSL_LIBRARIES} +#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) + OpenSSL::Crypto +#endif() + ) diff --git a/src/tools/Extractor_projects b/src/tools/Extractor_projects index b460e858e..1d533d5fe 160000 --- a/src/tools/Extractor_projects +++ b/src/tools/Extractor_projects @@ -1 +1 @@ -Subproject commit b460e858e9b878cada6fc9692b3b53fd3ea08169 +Subproject commit 1d533d5fec24fce8237e81d863f8270330363303