1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-16 00:00:07 +01:00

ssl ecdh adapt if missing ecdh.h include

https://github.com/warmcat/libwebsockets/issues/457
This commit is contained in:
Joakim Soderberg 2016-03-12 08:49:09 +08:00 committed by Andy Green
parent f192c01a13
commit d36fa29ac4
3 changed files with 15 additions and 2 deletions

View file

@ -695,6 +695,15 @@ if (LWS_WITH_SSL)
include_directories("${OPENSSL_INCLUDE_DIRS}")
list(APPEND LIB_LIST ${OPENSSL_LIBRARIES})
endif()
# older (0.98) Openssl lacks this
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/ecdh.h LWS_HAVE_OPENSSL_ECDH_H)
if (LWS_SSL_SERVER_WITH_ECDH_CERT AND NOT LWS_HAVE_OPENSSL_ECDH_H)
message(FATAL_ERROR "Missing openssl/ecdh.h, so cannot use LWS_SSL_SERVER_WITH_ECDH_CERT")
endif()
endif(LWS_WITH_SSL)
if (LWS_WITH_LIBEV)
@ -1208,6 +1217,7 @@ message(" LWS_WITH_HTTP2 = ${LWS_WITH_HTTP2}")
message(" LWS_MBED3 = ${LWS_MBED3}")
message(" LWS_SSL_SERVER_WITH_ECDH_CERT = ${LWS_SSL_SERVER_WITH_ECDH_CERT}")
message(" LWS_MAX_SMP = ${LWS_MAX_SMP}")
message(" LWS_HAVE_OPENSSL_ECDH_H = ${LWS_HAVE_OPENSSL_ECDH_H}")
message("---------------------------------------------------------------------")
# These will be available to parent projects including libwebsockets using add_subdirectory()

View file

@ -24,7 +24,7 @@
#include <openssl/err.h>
#endif
#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
#ifdef LWS_HAVE_OPENSSL_ECDH_H
#include <openssl/ecdh.h>
#endif
@ -139,7 +139,7 @@ static int
lws_context_ssl_init_ecdh_curve(struct lws_context_creation_info *info,
struct lws_context *context)
{
#if OPENSSL_VERSION_NUMBER >= 0x0090800fL
#ifdef LWS_HAVE_OPENSSL_ECDH_H
EC_KEY *ecdh;
int ecdh_nid;
const char *ecdh_curve = "prime256v1";

View file

@ -74,6 +74,9 @@
/* SSL server using ECDH certificate */
#cmakedefine LWS_SSL_SERVER_WITH_ECDH_CERT
/* whether the Openssl is recent enough, and / or built with, ecdh */
#cmakedefine LWS_HAVE_OPENSSL_ECDH_H
/* Maximum supported service threads */
#define LWS_MAX_SMP ${LWS_MAX_SMP}