Skip to content

Commit

Permalink
Added OpenSSL3.x support based on the work on @Meltie2013 and @i-am-fyre
Browse files Browse the repository at this point in the history
  • Loading branch information
billy1arm committed Oct 20, 2023
1 parent f68677d commit f9889b8
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 3 deletions.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions src/mangosd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ target_link_libraries(mangosd
$<$<BOOL:${SOAP}>:gsoap>
Threads::Threads
${OPENSSL_LIBRARIES}
#if (defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3)
OpenSSL::Crypto
#endif()

)

install(
Expand Down
30 changes: 30 additions & 0 deletions src/mangosd/mangosd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@

#include <openssl/opensslv.h>
#include <openssl/crypto.h>
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
# include <openssl/provider.h>
#endif
#include <ace/Version.h>
#include <ace/Get_Opt.h>

Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/realmd
Submodule realmd updated 2 files
+3 −0 CMakeLists.txt
+32 −0 Main.cpp
11 changes: 11 additions & 0 deletions src/shared/Auth/ARC4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,27 @@
*/

#include "ARC4.h"
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
#include <openssl/provider.h>
#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);
}

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);
Expand Down
3 changes: 3 additions & 0 deletions src/shared/Auth/Sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include "Common/Common.h"
#include <openssl/sha.h>
#include <openssl/crypto.h>
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
# include <openssl/provider.h>
#endif

class BigNumber;

Expand Down
4 changes: 4 additions & 0 deletions src/shared/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

)
2 changes: 1 addition & 1 deletion src/tools/Extractor_projects

0 comments on commit f9889b8

Please sign in to comment.