Skip to content

Commit

Permalink
Add support for OpenSSL 1.1 and replace deprecated function calls
Browse files Browse the repository at this point in the history
See #16 for details. Thanks to
Chris West @FauxFaux for the initial patch!

Use OpenSSL 1.1.0g for Windows superbuild.

Fix Windows build by removing calls to obsolete do_ms.bat
<https://stackoverflow.com/questions/39076244/why-there-is-no-ms-do-ms-bat-after-perl-configure-vc-win64a/39247560#39247560>.

Workaround for incorrect library suffixes searched by FindOpenSSL
<https://gitlab.kitware.com/cmake/cmake/issues/17604>.

Link OpenSSL statically and fix missing dependency on crypt32.lib.

(cherry picked from commit edd3687)
(cherry picked from commit b003e00)
(cherry picked from commit cc6e204)
(cherry picked from commit 303c640)
(cherry picked from commit 4e24006)
(cherry picked from commit 448ac48)
(cherry picked from commit 00b3bb0)
(cherry picked from commit 85e7efc)
(cherry picked from commit 9840962)
  • Loading branch information
qris committed Jan 14, 2018
1 parent c196ad2 commit 451d744
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 105 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -18,7 +18,7 @@ configuration:
environment:
VisualStudioVersion: 11.0
Generator_Base: Visual Studio 11 2012
OPENSSL_VERSION: 1.0.2f
OPENSSL_VERSION: 1.1.0f
PCRE_VERSION: 8.38
CMAKE_UNIBUILD_DIR: '%APPVEYOR_BUILD_FOLDER%\..\cmake'
BOXBACKUP_VERSION_BASE: 0.12
Expand Down
21 changes: 20 additions & 1 deletion infrastructure/cmake/CMakeLists.txt
Expand Up @@ -419,7 +419,26 @@ else()
endif()

# Link to OpenSSL
find_package(OpenSSL REQUIRED)
# Workaround for incorrect library suffixes searched by FindOpenSSL:
# https://gitlab.kitware.com/cmake/cmake/issues/17604
if(WIN32 AND MSVC)
find_package(OpenSSL)
set(OPENSSL_SSL_LIBRARY ${SSL_EAY_RELEASE})
set(OPENSSL_CRYPTO_LIBRARY ${LIB_EAY_RELEASE})
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} crypt32)
find_package_handle_standard_args(OpenSSL
REQUIRED_VARS
OPENSSL_SSL_LIBRARY
OPENSSL_CRYPTO_LIBRARY
OPENSSL_INCLUDE_DIR
VERSION_VAR
OPENSSL_VERSION
FAIL_MESSAGE
"Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR"
)
else()
find_package(OpenSSL REQUIRED)
endif()
include_directories(${OPENSSL_INCLUDE_DIR})
target_link_libraries(lib_crypto PUBLIC ${OPENSSL_LIBRARIES})

Expand Down
24 changes: 12 additions & 12 deletions infrastructure/cmake/windows/CMakeLists.txt
Expand Up @@ -15,9 +15,9 @@ set(ZLIB_VERSION 1.2.11)
set(ZLIB_HASH SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1)

# Version of OpenSSL to download, build, and compile Box Backup against:
set(OPENSSL_VERSION 1.0.2l)
set(OPENSSL_VERSION 1.1.0g)
# Hash of openssl-${OPENSSL_VERSION}.tar.gz, to be verified after download:
set(OPENSSL_HASH SHA256=ce07195b659e75f4e1db43552860070061f156a98bb37b672b101ba6e3ddf30c)
set(OPENSSL_HASH SHA256=de4d501267da39310905cb6dc8c6121f7a2cad45a7707f76df828fe1b85073af)

# Version of PCRE to download, build, and compile Box Backup against:
set(PCRE_VERSION 8.41)
Expand Down Expand Up @@ -49,17 +49,17 @@ if(WIN32)
URL "https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz"
URL_HASH ${OPENSSL_HASH}
DOWNLOAD_NO_PROGRESS 1
CONFIGURE_COMMAND perl Configure debug-VC-WIN32 no-asm --prefix=${install_dir}
COMMAND cmd /c ms\\do_ms.bat
# You would expect us to use nt.mak to compile a static library here, but mk1mf.pl uses the /MT[d]
# CRT in that case, which is incompatible with our dynamic runtime, /MD[d]. It seems that the libs
# built by ntdll.mak, which are compiled with /MD[d], are full libraries and not import libs,
# so we can link statically against them and still get a dynamic runtime.
BUILD_IN_SOURCE 1
BUILD_COMMAND nmake /s /f ms\\nt.mak
CONFIGURE_COMMAND perl Configure ${openssl_config} no-asm no-shared
--prefix=${install_dir}
--openssldir=etc
# Run tests before install, but don't make the main target depend on them, so that
# we don't have to run them whenever we build manually on Windows.
TEST_BEFORE_INSTALL 1
TEST_COMMAND nmake /s /f ms\\nt.mak test
INSTALL_COMMAND nmake /s /f ms\\nt.mak install
TEST_EXCLUDE_FROM_MAIN 1
BUILD_IN_SOURCE 1
BUILD_COMMAND nmake /s
TEST_COMMAND nmake /s test
INSTALL_COMMAND nmake /s install
STEP_TARGETS test
)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
Expand Down
2 changes: 1 addition & 1 deletion lib/crypto/CipherBlowfish.cpp
Expand Up @@ -206,7 +206,7 @@ void CipherBlowfish::SetupParameters(EVP_CIPHER_CTX *pCipherContext) const
}
// Set key
#ifndef HAVE_OLD_SSL
if(EVP_CipherInit_ex(pCipherContext, NULL, NULL, (unsigned char*)mpKey, (unsigned char*)mpInitialisationVector, -1) != 1)
if(EVP_CipherInit_ex(pCipherContext, GetCipher(), NULL, (unsigned char*)mpKey, (unsigned char*)mpInitialisationVector, -1) != 1)
#else
if(EVP_CipherInit(pCipherContext, NULL, (unsigned char*)mKey.c_str(), (unsigned char*)mInitialisationVector, -1) != 1)
#endif
Expand Down

0 comments on commit 451d744

Please sign in to comment.