diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ddebbdb5..3e956498e 100755 --- 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 5e1c6c795..7bae2e0cd 100644 --- a/src/mangosd/CMakeLists.txt +++ b/src/mangosd/CMakeLists.txt @@ -63,6 +63,7 @@ target_include_directories(mangosd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${OPENSSL_INCLUDE_DIR} ) target_compile_definitions(mangosd @@ -76,6 +77,11 @@ target_link_libraries(mangosd $<$:gsoap> Threads::Threads DL::DL + ${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/CMakeLists.txt b/src/realmd/CMakeLists.txt index 61bc11703..dc226c56f 100644 --- a/src/realmd/CMakeLists.txt +++ b/src/realmd/CMakeLists.txt @@ -64,6 +64,7 @@ target_include_directories(realmd PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.h + ${OPENSSL_INCLUDE_DIR} ) target_link_libraries(realmd @@ -71,6 +72,10 @@ target_link_libraries(realmd shared Threads::Threads DL::DL + ${OPENSSL_LIBRARIES} +#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) + OpenSSL::Crypto +#endif() ) install( diff --git a/src/realmd/Main.cpp b/src/realmd/Main.cpp index 8444cd310..9db6fcc2b 100644 --- a/src/realmd/Main.cpp +++ b/src/realmd/Main.cpp @@ -40,6 +40,9 @@ #include #include +#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3) +# include +#endif #include #include @@ -221,11 +224,40 @@ extern int main(int argc, char** argv) } 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/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 9099fc6dc..5a3f31ddc 100644 --- a/src/shared/CMakeLists.txt +++ b/src/shared/CMakeLists.txt @@ -220,6 +220,7 @@ target_include_directories(shared PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} + ${OPENSSL_INCLUDE_DIR} ${TGT_INCL} ) @@ -237,5 +238,6 @@ target_link_libraries(shared ace utf8 MySQL::MySQL + ${OPENSSL_LIBRARIES} OpenSSL::Crypto ) diff --git a/src/tools/Extractor_projects/CMakeLists.txt b/src/tools/Extractor_projects/CMakeLists.txt index 44a00f762..0b31ce415 100644 --- a/src/tools/Extractor_projects/CMakeLists.txt +++ b/src/tools/Extractor_projects/CMakeLists.txt @@ -176,6 +176,10 @@ target_link_libraries(mmap-extractor RecastNavigation::Recast Threads::Threads DL::DL + ${OPENSSL_LIBRARIES} +#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3) + OpenSSL::Crypto +#endif() ) install(