Skip to content

Commit 72cf9ab

Browse files
committed
Add support for LibreSSL
The frontends are mostly interchangeable.
1 parent a0e45c4 commit 72cf9ab

4 files changed

Lines changed: 22 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,16 +125,16 @@ option(USE_TLS "Enable TLS support" FALSE)
125125
if (USE_TLS)
126126
# default to securetranport on Apple if nothing is configured
127127
if (APPLE)
128-
if (NOT USE_MBED_TLS AND NOT USE_OPEN_SSL) # unless we want something else
128+
if (NOT USE_MBED_TLS AND NOT USE_OPEN_SSL AND NOT USE_LIBRE_SSL) # unless we want something else
129129
set(USE_SECURE_TRANSPORT ON)
130130
endif()
131131
# default to mbedtls on windows if nothing is configured
132132
elseif (WIN32)
133-
if (NOT USE_OPEN_SSL) # unless we want something else
133+
if (NOT USE_OPEN_SSL AND NOT USE_LIBRE_SSL) # unless we want something else
134134
set(USE_MBED_TLS ON)
135135
endif()
136136
else() # default to OpenSSL on all other platforms
137-
if (NOT USE_MBED_TLS) # Unless mbedtls is requested
137+
if (NOT USE_MBED_TLS AND NOT USE_LIBRE_SSL) # Unless mbedtls or libressl is requested
138138
set(USE_OPEN_SSL ON)
139139
set(requires "openssl")
140140
endif()
@@ -146,7 +146,7 @@ if (USE_TLS)
146146
elseif (USE_SECURE_TRANSPORT)
147147
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketAppleSSL.h)
148148
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketAppleSSL.cpp)
149-
elseif (USE_OPEN_SSL)
149+
elseif (USE_OPEN_SSL OR USE_LIBRE_SSL)
150150
list( APPEND IXWEBSOCKET_HEADERS ixwebsocket/IXSocketOpenSSL.h)
151151
list( APPEND IXWEBSOCKET_SOURCES ixwebsocket/IXSocketOpenSSL.cpp)
152152
else()
@@ -183,6 +183,8 @@ if (USE_TLS)
183183
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_MBED_TLS)
184184
elseif (USE_OPEN_SSL)
185185
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_OPEN_SSL)
186+
elseif (USE_LIBRE_SSL)
187+
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_LIBRE_SSL)
186188
elseif (USE_SECURE_TRANSPORT)
187189
target_compile_definitions(ixwebsocket PUBLIC IXWEBSOCKET_USE_SECURE_TRANSPORT)
188190
else()
@@ -227,6 +229,16 @@ if (USE_TLS)
227229
endif()
228230
target_include_directories(ixwebsocket PUBLIC $<BUILD_INTERFACE:${MBEDTLS_INCLUDE_DIRS}>)
229231
target_link_libraries(ixwebsocket PRIVATE ${MBEDTLS_LIBRARIES})
232+
elseif (USE_LIBRE_SSL)
233+
message(STATUS "TLS configured to use libressl")
234+
235+
if (NOT LIBRESSL_FOUND)
236+
find_package(LibreSSL REQUIRED)
237+
endif()
238+
message(STATUS "LibreSSL: " ${LIBRESSL_VERSION})
239+
240+
target_include_directories(ixwebsocket PUBLIC $<BUILD_INTERFACE:${LIBRESSL_INCLUDE_DIR}>)
241+
target_link_libraries(ixwebsocket PRIVATE ${LIBRESSL_LIBRARIES})
230242
elseif (USE_SECURE_TRANSPORT)
231243
message(STATUS "TLS configured to use secure transport")
232244
target_link_libraries(ixwebsocket PRIVATE "-framework Foundation" "-framework Security")

ixwebsocket/IXSocketFactory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
#ifdef IXWEBSOCKET_USE_MBED_TLS
1313
#include "IXSocketMbedTLS.h"
14-
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
14+
#elif defined(IXWEBSOCKET_USE_OPEN_SSL) || defined(IXWEBSOCKET_USE_LIBRE_SSL)
1515
#include "IXSocketOpenSSL.h"
1616
#elif __APPLE__
1717
#include "IXSocketAppleSSL.h"
@@ -43,7 +43,7 @@ namespace ix
4343
#ifdef IXWEBSOCKET_USE_TLS
4444
#if defined(IXWEBSOCKET_USE_MBED_TLS)
4545
socket = ix::make_unique<SocketMbedTLS>(tlsOptions, fd);
46-
#elif defined(IXWEBSOCKET_USE_OPEN_SSL)
46+
#elif defined(IXWEBSOCKET_USE_OPEN_SSL) || defined(IXWEBSOCKET_USE_LIBRE_SSL)
4747
socket = ix::make_unique<SocketOpenSSL>(tlsOptions, fd);
4848
#elif defined(__APPLE__)
4949
socket = ix::make_unique<SocketAppleSSL>(tlsOptions, fd);

ixwebsocket/IXSocketOpenSSL.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Adapted from Satori SDK OpenSSL code.
77
*/
8-
#ifdef IXWEBSOCKET_USE_OPEN_SSL
8+
#if defined(IXWEBSOCKET_USE_OPEN_SSL) || defined(IXWEBSOCKET_USE_LIBRE_SSL)
99

1010
#include "IXSocketOpenSSL.h"
1111

@@ -860,4 +860,4 @@ namespace ix
860860

861861
} // namespace ix
862862

863-
#endif // IXWEBSOCKET_USE_OPEN_SSL
863+
#endif // defined(IXWEBSOCKET_USE_OPEN_SSL) || defined(IXWEBSOCKET_USE_LIBRE_SSL)

ixwebsocket/IXSocketOpenSSL.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Author: Benjamin Sergeant, Matt DeBoer
44
* Copyright (c) 2017-2020 Machine Zone, Inc. All rights reserved.
55
*/
6-
#ifdef IXWEBSOCKET_USE_OPEN_SSL
6+
#if defined(IXWEBSOCKET_USE_OPEN_SSL) || defined(IXWEBSOCKET_USE_LIBRE_SSL)
77

88
#pragma once
99

@@ -65,4 +65,4 @@ namespace ix
6565

6666
} // namespace ix
6767

68-
#endif // IXWEBSOCKET_USE_OPEN_SSL
68+
#endif // defined(IXWEBSOCKET_USE_OPEN_SSL) || defined(IXWEBSOCKET_USE_LIBRE_SSL)

0 commit comments

Comments
 (0)