Add ability to use OpenSSL on apple platforms.

This commit is contained in:
Benjamin Sergeant 2019-09-29 15:34:58 -07:00
parent 681390f22f
commit f6bf2531bb
6 changed files with 29 additions and 10 deletions

View File

@ -114,12 +114,11 @@ if (WIN32)
set(USE_MBED_TLS TRUE)
endif()
set(USE_OPEN_SSL FALSE)
if (USE_TLS)
if (USE_MBED_TLS)
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketMbedTLS.h)
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketMbedTLS.cpp)
elseif (APPLE)
elseif (APPLE AND NOT USE_OPEN_SSL)
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketAppleSSL.h)
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketAppleSSL.cpp)
elseif (WIN32)
@ -141,6 +140,8 @@ if (USE_TLS)
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_TLS)
if (USE_MBED_TLS)
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_MBED_TLS)
elseif (USE_OPEN_SSL)
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_OPEN_SSL)
elseif (APPLE)
elseif (WIN32)
else()
@ -163,6 +164,13 @@ if (UNIX)
endif()
if (USE_TLS AND USE_OPEN_SSL)
# Help finding Homebrew's OpenSSL on macOS
if (APPLE)
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /usr/local/opt/openssl/lib)
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} /usr/local/opt/openssl/include)
endif()
find_package(OpenSSL REQUIRED)
add_definitions(${OPENSSL_DEFINITIONS})
message(STATUS "OpenSSL: " ${OPENSSL_VERSION})

View File

@ -1 +1 @@
6.3.0
6.3.1

View File

@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.
## [6.3.1] - 2019-09-29
- Add ability to use OpenSSL on apple platforms.
## [6.3.0] - 2019-09-28
- ixcobra / fix crash in CobraConnection::publishNext when the queue is empty + handle CobraConnection_PublishMode_Batch in CobraMetricsThreadedPublisher

View File

@ -10,12 +10,12 @@
#ifdef IXWEBSOCKET_USE_MBED_TLS
#include <ixwebsocket/IXSocketMbedTLS.h>
#elif __APPLE__
#include <ixwebsocket/IXSocketAppleSSL.h>
#elif defined(_WIN32)
#include <ixwebsocket/IXSocketSChannel.h>
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
#include <ixwebsocket/IXSocketOpenSSL.h>
#elif __APPLE__
#include <ixwebsocket/IXSocketAppleSSL.h>
#endif
#else
@ -42,12 +42,12 @@ namespace ix
#ifdef IXWEBSOCKET_USE_TLS
#if defined(IXWEBSOCKET_USE_MBED_TLS)
socket = std::make_shared<SocketMbedTLS>(tlsOptions);
#elif defined(__APPLE__)
socket = std::make_shared<SocketAppleSSL>(tlsOptions);
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
socket = std::make_shared<SocketOpenSSL>(tlsOptions);
#elif defined(_WIN32)
socket = std::make_shared<SocketSChannel>(tlsOptions);
#else
socket = std::make_shared<SocketOpenSSL>(tlsOptions);
#elif defined(__APPLE__)
socket = std::make_shared<SocketAppleSSL>(tlsOptions);
#endif
#else
errorMsg = "TLS support is not enabled on this platform.";

View File

@ -6,4 +6,4 @@
#pragma once
#define IX_WEBSOCKET_VERSION "6.3.0"
#define IX_WEBSOCKET_VERSION "6.3.1"

View File

@ -14,6 +14,9 @@ brew:
ws:
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_MBED_TLS=1 .. ; make -j 4)
ws_openssl:
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_OPEN_SSL=1 .. ; make -j 4)
uninstall:
xargs rm -fv < build/install_manifest.txt
@ -64,6 +67,10 @@ test:
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4)
(cd test ; python2.7 run.py -r)
test_openssl:
mkdir -p build && (cd build ; cmake -DCMAKE_BUILD_TYPE=Debug -DUSE_TLS=1 -DUSE_OPEN_SSL=1 -DUSE_WS=1 -DUSE_TEST=1 .. ; make -j 4)
(cd test ; python2.7 run.py -r)
ws_test: ws
(cd ws ; env DEBUG=1 PATH=../ws/build:$$PATH bash test_ws.sh)