Unverified Commit d7309c7a authored by Dominik Charousset's avatar Dominik Charousset Committed by GitHub

Merge pull request #627

Fix unit tests with OpenSSL 1.1.0
parents 8e08b12b 96803c60
...@@ -45,6 +45,8 @@ if(CAF_BUILD_STATIC_RUNTIME) ...@@ -45,6 +45,8 @@ if(CAF_BUILD_STATIC_RUNTIME)
endif() endif()
endif() endif()
endforeach() endforeach()
else()
set(CAF_BUILD_STATIC_RUNTIME no)
endif() endif()
# add helper target that simplifies re-running configure # add helper target that simplifies re-running configure
...@@ -537,7 +539,7 @@ if(NOT CAF_NO_OPENSSL) ...@@ -537,7 +539,7 @@ if(NOT CAF_NO_OPENSSL)
# Check OpenSSL version >= 1.0.1 # Check OpenSSL version >= 1.0.1
if (OPENSSL_VERSION VERSION_LESS 1.0.1) if (OPENSSL_VERSION VERSION_LESS 1.0.1)
message(STATUS message(STATUS
"Disable OpenSSL. Required >= 1.0.1 due to TLSv2 support.") "Disable OpenSSL. Required >= 1.0.1 due to TLSv1.2 support.")
set(CAF_NO_OPENSSL yes) set(CAF_NO_OPENSSL yes)
else() else()
# Check if openssl headers and library versions match # Check if openssl headers and library versions match
...@@ -552,7 +554,7 @@ if(NOT CAF_NO_OPENSSL) ...@@ -552,7 +554,7 @@ if(NOT CAF_NO_OPENSSL)
} }
return -1; return -1;
} }
" OPENSSL_CORRECT_VERSION_NUMBER ) " OPENSSL_CORRECT_VERSION_NUMBER)
if (NOT OPENSSL_CORRECT_VERSION_NUMBER) if (NOT OPENSSL_CORRECT_VERSION_NUMBER)
message(FATAL_ERROR message(FATAL_ERROR
"OpenSSL library version does not match headers") "OpenSSL library version does not match headers")
......
...@@ -236,5 +236,4 @@ ...@@ -236,5 +236,4 @@
throw std::runtime_error(msg) throw std::runtime_error(msg)
#endif // CAF_NO_EXCEPTIONS #endif // CAF_NO_EXCEPTIONS
#endif // CAF_CONFIG_HPP #endif // CAF_CONFIG_HPP
...@@ -33,6 +33,11 @@ CAF_POP_WARNINGS ...@@ -33,6 +33,11 @@ CAF_POP_WARNINGS
#include "caf/io/network/native_socket.hpp" #include "caf/io/network/native_socket.hpp"
#include "caf/io/network/default_multiplexer.hpp" #include "caf/io/network/default_multiplexer.hpp"
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
# define CAF_SSL_HAS_SECURITY_LEVEL
# define CAF_SSL_HAS_NON_VERSIONED_TLS_FUN
#endif
namespace caf { namespace caf {
namespace openssl { namespace openssl {
......
...@@ -204,7 +204,11 @@ const char* session::openssl_passphrase() { ...@@ -204,7 +204,11 @@ const char* session::openssl_passphrase() {
SSL_CTX* session::create_ssl_context() { SSL_CTX* session::create_ssl_context() {
CAF_BLOCK_SIGPIPE(); CAF_BLOCK_SIGPIPE();
#ifdef CAF_SSL_HAS_NON_VERSIONED_TLS_FUN
auto ctx = SSL_CTX_new(TLS_method());
#else
auto ctx = SSL_CTX_new(TLSv1_2_method()); auto ctx = SSL_CTX_new(TLSv1_2_method());
#endif
if (!ctx) if (!ctx)
raise_ssl_error("cannot create OpenSSL context"); raise_ssl_error("cannot create OpenSSL context");
if (sys_.openssl_manager().authentication_enabled()) { if (sys_.openssl_manager().authentication_enabled()) {
...@@ -240,13 +244,13 @@ SSL_CTX* session::create_ssl_context() { ...@@ -240,13 +244,13 @@ SSL_CTX* session::create_ssl_context() {
} else { } else {
// No authentication. // No authentication.
SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr); SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, nullptr);
auto ecdh = EC_KEY_new_by_curve_name(NID_secp384r1); SSL_CTX_set_ecdh_auto(ctx, 1);
if (!ecdh) #ifdef CAF_SSL_HAS_SECURITY_LEVEL
raise_ssl_error("cannot get ECDH curve"); const char* cipher = "AECDH-AES256-SHA@SECLEVEL=0";
CAF_PUSH_WARNINGS #else
SSL_CTX_set_tmp_ecdh(ctx, ecdh); const char* cipher = "AECDH-AES256-SHA";
CAF_POP_WARNINGS #endif
if (SSL_CTX_set_cipher_list(ctx, "AECDH-AES256-SHA") != 1) if (SSL_CTX_set_cipher_list(ctx, cipher) != 1)
raise_ssl_error("cannot set anonymous cipher"); raise_ssl_error("cannot set anonymous cipher");
} }
return ctx; return ctx;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment