From 11ac59331fca28d2e74cc64d2bc7b58b063e238d Mon Sep 17 00:00:00 2001 From: XMRig Date: Wed, 22 Apr 2020 14:49:15 +0700 Subject: [PATCH] #1654 Fixed build with LibreSSL. --- src/base/kernel/Entry.cpp | 6 +++++- src/base/kernel/config/BaseConfig.cpp | 7 ++++++- src/base/net/tls/TlsContext.cpp | 4 ++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/base/kernel/Entry.cpp b/src/base/kernel/Entry.cpp index 58f9438b..ae2ac3ce 100644 --- a/src/base/kernel/Entry.cpp +++ b/src/base/kernel/Entry.cpp @@ -79,10 +79,14 @@ static int showVersion() printf("\nlibuv/%s\n", uv_version_string()); -# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT) +# if defined(XMRIG_FEATURE_TLS) { +# if defined(LIBRESSL_VERSION_TEXT) + printf("LibreSSL/%s\n", LIBRESSL_VERSION_TEXT + 9); +# elif defined(OPENSSL_VERSION_TEXT) constexpr const char *v = OPENSSL_VERSION_TEXT + 8; printf("OpenSSL/%.*s\n", static_cast(strchr(v, ' ') - v), v); +# endif } # endif diff --git a/src/base/kernel/config/BaseConfig.cpp b/src/base/kernel/config/BaseConfig.cpp index 2b5a7120..12f5db74 100644 --- a/src/base/kernel/config/BaseConfig.cpp +++ b/src/base/kernel/config/BaseConfig.cpp @@ -145,11 +145,16 @@ void xmrig::BaseConfig::printVersions() std::string libs; -# if defined(XMRIG_FEATURE_TLS) && defined(OPENSSL_VERSION_TEXT) +# if defined(XMRIG_FEATURE_TLS) { +# if defined(LIBRESSL_VERSION_TEXT) + snprintf(buf, sizeof buf, "LibreSSL/%s ", LIBRESSL_VERSION_TEXT + 9); + libs += buf; +# elif defined(OPENSSL_VERSION_TEXT) constexpr const char *v = OPENSSL_VERSION_TEXT + 8; snprintf(buf, sizeof buf, "OpenSSL/%.*s ", static_cast(strchr(v, ' ') - v), v); libs += buf; +# endif } # endif diff --git a/src/base/net/tls/TlsContext.cpp b/src/base/net/tls/TlsContext.cpp index d29c744b..d2ab71c5 100644 --- a/src/base/net/tls/TlsContext.cpp +++ b/src/base/net/tls/TlsContext.cpp @@ -156,7 +156,7 @@ bool xmrig::TlsContext::load(const TlsConfig &config) SSL_CTX_set_options(m_ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3); SSL_CTX_set_options(m_ctx, SSL_OP_CIPHER_SERVER_PREFERENCE); -# if OPENSSL_VERSION_NUMBER >= 0x1010100fL +# if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(LIBRESSL_VERSION_NUMBER) SSL_CTX_set_max_early_data(m_ctx, 0); # endif @@ -184,7 +184,7 @@ bool xmrig::TlsContext::setCipherSuites(const char *ciphersuites) return true; } -# if OPENSSL_VERSION_NUMBER >= 0x1010100fL +# if OPENSSL_VERSION_NUMBER >= 0x1010100fL && !defined(LIBRESSL_VERSION_NUMBER) if (SSL_CTX_set_ciphersuites(m_ctx, ciphersuites) == 1) { return true; }