summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt16
-rw-r--r--config.h.in1
-rw-r--r--contrib/cmake/BuildLibEvent.cmake18
-rw-r--r--contrib/src/uscxml/InterpreterOptions.cpp2
-rw-r--r--src/uscxml/server/HTTPServer.cpp12
-rw-r--r--src/uscxml/server/HTTPServer.h2
6 files changed, 32 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e9ca8e..c8a3545 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -253,6 +253,13 @@ else()
endif()
endif()
+#OpenSSL
+find_package(OpenSSL)
+if (OPENSSL_FOUND)
+ include_directories(${OPENSSL_INCLUDE_DIR})
+ list (APPEND USCXML_CORE_LIBS ${OPENSSL_LIBRARIES})
+endif()
+
# XercesC
CheckHasModule(XercesC)
@@ -328,13 +335,10 @@ if (UNIX)
list (APPEND USCXML_CORE_LIBS "pthread")
endif()
-#OpenSSL
-find_package(OpenSSL)
-if (OPENSSL_FOUND)
- include_directories(${OPENSSL_INCLUDE_DIR})
- list (APPEND USCXML_CORE_LIBS ${OPENSSL_LIBRARIES})
-endif()
+if (OPENSSL_FOUND AND LIBEVENT_HAS_BEVCB AND EVENT_SSL_FOUND)
+ set(HTTPS_ENABLED ON)
+endif()
# uriparser - part of contrib now
diff --git a/config.h.in b/config.h.in
index 69af116..ace7471 100644
--- a/config.h.in
+++ b/config.h.in
@@ -99,6 +99,7 @@
#cmakedefine OPENSSL_HAS_ELIPTIC_CURVES
#cmakedefine EVENT_SSL_FOUND
#cmakedefine LIBEVENT_HAS_BEVCB
+#cmakedefine HTTPS_ENABLED
#cmakedefine EXPECT_FOUND
#cmakedefine TCL_FOUND
diff --git a/contrib/cmake/BuildLibEvent.cmake b/contrib/cmake/BuildLibEvent.cmake
index 4e4e7af..223a214 100644
--- a/contrib/cmake/BuildLibEvent.cmake
+++ b/contrib/cmake/BuildLibEvent.cmake
@@ -1,12 +1,14 @@
# see http://www.kitware.com/products/html/BuildingExternalProjectsWithCMake2.8.html
# see http://tools.cinemapub.be/opendcp/opendcp-0.19-src/contrib/CMakeLists.txt
+find_package(OpenSSL)
+
include(ExternalProject)
if (MSVC)
externalproject_add(libevent
- URL https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
- URL_MD5 c4c56f986aa985677ca1db89630a2e11
+ URL https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
+ URL_MD5 f3eeaed018542963b7d2416ef1135ecc
BUILD_IN_SOURCE 1
PREFIX ${CMAKE_BINARY_DIR}/deps/libevent
CONFIGURE_COMMAND ""
@@ -25,14 +27,14 @@ else ()
endif()
externalproject_add(libevent
- URL https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
- URL_MD5 c4c56f986aa985677ca1db89630a2e11
+ URL https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
+ URL_MD5 f3eeaed018542963b7d2416ef1135ecc
BUILD_IN_SOURCE 0
PREFIX ${CMAKE_BINARY_DIR}/deps/libevent
PATCH_COMMAND
${CMAKE_COMMAND} -E copy "${PROJECT_SOURCE_DIR}/contrib/patches/libevent/sierra.kqueue.c" <SOURCE_DIR>/kqueue.c
CONFIGURE_COMMAND
- ${FORCE_FPIC} <SOURCE_DIR>/configure --enable-static --enable-shared --disable-openssl --prefix=<INSTALL_DIR>
+ ${FORCE_FPIC} <SOURCE_DIR>/configure --enable-static --enable-shared --prefix=<INSTALL_DIR>
)
endif()
@@ -43,10 +45,16 @@ if (APPLE)
set(LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_core.a)
list (APPEND LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_extra.a)
list (APPEND LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_pthreads.a)
+ if (OPENSSL_FOUND)
+ list (APPEND LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_openssl.a)
+ endif()
elseif (UNIX)
set(LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_core.a)
list (APPEND LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_extra.a)
list (APPEND LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_pthreads.a)
+ if (OPENSSL_FOUND)
+ list (APPEND LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent_openssl.a)
+ endif()
elseif(WIN32)
set(LIBEVENT_LIBRARIES ${CMAKE_BINARY_DIR}/deps/libevent/lib/libevent.lib)
else()
diff --git a/contrib/src/uscxml/InterpreterOptions.cpp b/contrib/src/uscxml/InterpreterOptions.cpp
index d3d50be..4c487e2 100644
--- a/contrib/src/uscxml/InterpreterOptions.cpp
+++ b/contrib/src/uscxml/InterpreterOptions.cpp
@@ -44,7 +44,7 @@ void InterpreterOptions::printUsageAndExit(const char* progName) {
printf(" [-p pluginPath]");
#endif
printf(" [-tN]");
-#ifdef EVENT_SSL_FOUND
+#ifdef HTTPS_ENABLED
printf(" [-sN] [--certificate=FILE | --private-key=FILE --public-key=FILE] ");
#endif
printf(" \\\n\t\t URL1 [--disable-http] [--option1=value1 --option2=value2]");
diff --git a/src/uscxml/server/HTTPServer.cpp b/src/uscxml/server/HTTPServer.cpp
index b180371..367df21 100644
--- a/src/uscxml/server/HTTPServer.cpp
+++ b/src/uscxml/server/HTTPServer.cpp
@@ -51,7 +51,7 @@ extern "C" {
//#include <arpa/inet.h>
#endif
-#if (defined EVENT_SSL_FOUND && defined LIBEVENT_HAS_BEVCB && defined OPENSSL_FOUND)
+#ifdef HTTPS_ENABLED
extern "C" {
#include <openssl/ssl.h>
#include <openssl/err.h>
@@ -115,7 +115,7 @@ HTTPServer::HTTPServer(unsigned short port, unsigned short wsPort, SSLConfig* ss
}
}
-#if (defined EVENT_SSL_FOUND && defined LIBEVENT_HAS_BEVCB && defined OPENSSL_FOUND)
+#ifdef HTTPS_ENABLED
// have another look here https://github.com/ppelleti/https-example/blob/master/https-server.c
if (!sslConf) {
@@ -223,7 +223,7 @@ HTTPServer* HTTPServer::getInstance(unsigned short port, unsigned short wsPort,
_instance = new HTTPServer(port, wsPort, sslConf);
// only start if we have something to do!
-#if (defined EVENT_SSL_FOUND && defined LIBEVENT_HAS_BEVCB && defined OPENSSL_FOUND && defined OPENSSL_HAS_ELIPTIC_CURVES)
+#ifdef HTTPS_ENABLED
if (_instance->_httpHandle || _instance->_wsHandle || _instance->_sslHandle)
#else
if (_instance->_httpHandle || _instance->_wsHandle)
@@ -297,7 +297,7 @@ void HTTPServer::httpRecvReqCallback(struct evhttp_request *req, void *callbackD
const char* wsConnection = evhttp_find_header(headers, "Connection");
if (wsUpgrade && wsConnection) {
if (iequals(wsUpgrade, "websocket") && iequals(wsConnection, "Upgrade")) {
- // this is a websocket request! .. but we do not know how to decouple form evhttp
+ // this is a websocket request! .. but we do not know how to decouple from evhttp
}
}
#endif
@@ -714,7 +714,7 @@ std::string HTTPServer::getBaseURL(ServerType type) {
case HTTP:
servletURL << "http://" << INSTANCE->_address << ":" << INSTANCE->_port;
break;
-#if (defined EVENT_SSL_FOUND && defined LIBEVENT_HAS_BEVCB && defined OPENSSL_FOUND)
+#ifdef HTTPS_ENABLED
case HTTPS:
servletURL << "https://" << INSTANCE->_address << ":" << INSTANCE->_sslPort;
break;
@@ -748,7 +748,7 @@ void HTTPServer::determineAddress() {
}
-#if (defined EVENT_SSL_FOUND && defined LIBEVENT_HAS_BEVCB && defined OPENSSL_FOUND)
+#ifdef HTTPS_ENABLED
// see https://github.com/ppelleti/https-example/blob/master/https-server.c
struct bufferevent* HTTPServer::sslBufferEventCallback(struct event_base *base, void *arg) {
struct bufferevent* r;
diff --git a/src/uscxml/server/HTTPServer.h b/src/uscxml/server/HTTPServer.h
index 6486770..02a2a93 100644
--- a/src/uscxml/server/HTTPServer.h
+++ b/src/uscxml/server/HTTPServer.h
@@ -187,7 +187,7 @@ private:
friend class HTTPServlet;
friend class WebSocketServlet;
-#if (defined EVENT_SSL_FOUND && defined LIBEVENT_HAS_BEVCB && defined OPENSSL_FOUND)
+#ifdef HTTPS_ENABLED
struct evhttp* _https;
struct evhttp_bound_socket* _sslHandle;
unsigned short _sslPort;