Skip to content

Commit 88a481a

Browse files
Add WinTLS support for SSL/TLS on Windows
Introduces conditional support for WinTLS as an alternative to OpenSSL for SSL/TLS on Windows platforms. Updates CMake configuration, build scripts, and source files to handle both OpenSSL and WinTLS, including new CMake find module, macro definitions, and conditional compilation. Refactors include paths, protocol handler directories, and updates documentation to reflect the new SSL/TLS options. Macro WITH_ETP_SSL is now automatically defined by the library if needed.
1 parent 5de0759 commit 88a481a

44 files changed

Lines changed: 342 additions & 121 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/github-actions.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ jobs:
202202
cmake -DCMAKE_TOOLCHAIN_FILE=%VCPKG_INSTALLATION_ROOT%\scripts\buildsystems\vcpkg.cmake -G"Visual Studio 17 2022" -A x64 -T host=x64 -Wno-dev -Wno-deprecated -DCMAKE_INSTALL_PREFIX=${{ runner.temp }}/fesapi-install ${{ runner.temp }}\fesapi-2.14.0.0 &&
203203
cmake --build . --config Release -j2 &&
204204
cmake --build . --config Release --target INSTALL &&
205-
%VCPKG_INSTALLATION_ROOT%\vcpkg install openssl boost-beast avro-cpp &&
205+
%VCPKG_INSTALLATION_ROOT%\vcpkg install bext-wintls boost-beast avro-cpp &&
206206
cd ${{ runner.temp }} &&
207207
mkdir fetpapi-build &&
208208
cd fetpapi-build &&

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/cs/fetpapiCs.csproj
33
/swig/setup.py
44
/swig/swigEtp1_2Include.i
5-
/src/nsDefinitions.h
5+
/src/macroDefinitions.h
66

77
## Ignore csharp swig generated files
88
/swig/swigGeneratedCsWrapper.cpp

CMakeLists.txt

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set (FETPAPI_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
1515

1616
# version mechanism
1717
set (Fetpapi_VERSION_MAJOR 0)
18-
set (Fetpapi_VERSION_MINOR 4)
18+
set (Fetpapi_VERSION_MINOR 5)
1919
set (Fetpapi_VERSION_PATCH 0)
2020
set (Fetpapi_VERSION_TWEAK 0)
2121

@@ -120,6 +120,7 @@ endif()
120120

121121
# avro DEPENDENCY
122122
find_package(AVRO REQUIRED)
123+
target_link_libraries (${PROJECT_NAME} PUBLIC AVRO::AVRO ${CMAKE_THREAD_LIBS_INIT})
123124

124125
if (WITH_FESAPI)
125126
find_package(FESAPI REQUIRED)
@@ -129,9 +130,9 @@ if (WITH_FESAPI)
129130
message(SEND_ERROR "The FESAPI library (FESAPI_JAR variable) does not look to be a valid file. Please modify it.")
130131
endif ()
131132
endif (WITH_JAVA_WRAPPING)
133+
target_link_libraries(${PROJECT_NAME} PUBLIC FESAPI::FESAPI)
132134
endif (WITH_FESAPI)
133135

134-
target_link_libraries (${PROJECT_NAME} PRIVATE AVRO::AVRO ${CMAKE_THREAD_LIBS_INIT})
135136
if (WIN32)
136137
target_link_libraries (${PROJECT_NAME} PRIVATE bcrypt.lib)
137138

@@ -149,24 +150,26 @@ else (WIN32)
149150
endif (WIN32)
150151

151152
if (WITH_ETP_SSL)
152-
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_ETP_SSL)
153-
if (NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto)
154-
find_package(OpenSSL REQUIRED)
153+
if (WIN32)
154+
set (USE_WINTLS_INSTEAD_OF_OPENSSL ON CACHE BOOL "Build FETPAPI with ETP SSL support.")
155155
endif()
156-
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
157-
# OpenSSL::applink is recommended under MSVC : https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
158-
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
159-
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::applink)
160-
endif ()
161-
endif ()
162156

163-
if (WITH_FESAPI)
164-
target_link_libraries(${PROJECT_NAME} PRIVATE FESAPI::FESAPI)
165-
endif (WITH_FESAPI)
157+
if (NOT USE_WINTLS_INSTEAD_OF_OPENSSL)
158+
target_compile_definitions(${PROJECT_NAME} PRIVATE WITH_ETP_SSL)
159+
if (NOT TARGET OpenSSL::SSL OR NOT TARGET OpenSSL::Crypto)
160+
find_package(OpenSSL REQUIRED)
161+
endif()
162+
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::SSL OpenSSL::Crypto)
163+
# OpenSSL::applink is recommended under MSVC : https://cmake.org/cmake/help/latest/module/FindOpenSSL.html
164+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
165+
target_link_libraries(${PROJECT_NAME} PRIVATE OpenSSL::applink)
166+
endif ()
167+
endif()
168+
endif ()
166169

167170
# Namespaces definitions
168171
set (FETPAPI_ETP_NS etp CACHE STRING "Namespace for etp objects")
169-
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/nsDefinitions.h ${CMAKE_CURRENT_SOURCE_DIR}/src/nsDefinitions.h) # Overwrite if different
172+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/macroDefinitions.h.in ${CMAKE_CURRENT_SOURCE_DIR}/src/macroDefinitions.h @ONLY) # Overwrite if different
170173

171174
# ============================================================================
172175
# SWIG wrapping
@@ -195,26 +198,25 @@ endif (WITH_PYTHON_WRAPPING)
195198

196199
include(${CMAKE_CURRENT_SOURCE_DIR}/src/CMakeLists.txt)
197200
set (ALL_SOURCES_AND_HEADERS
198-
${ALL_SOURCES_AND_HEADERS}
199-
${FETPAPI_SOURCES}
200201
${FETPAPI_HEADERS}
202+
${FETPAPI_ETP_SOURCES}
203+
${FETPAPI_ETP_HEADERS}
201204
${FETPAPI_PROTOCOL_SOURCES}
202205
${FETPAPI_PROTOCOL_HEADERS}
203206
${FETPAPI_FESAPI_SOURCES}
204207
${FETPAPI_FESAPI_HEADERS}
205208
${FETPAPI_SSL_SOURCES}
206209
${FETPAPI_SSL_HEADERS}
207210
)
208-
209-
if (WITH_FESAPI)
210-
target_include_directories(${PROJECT_NAME} PRIVATE ${FESAPI_INCLUDE_DIR})
211-
endif (WITH_FESAPI)
212-
213211
target_sources(${PROJECT_NAME} PRIVATE ${ALL_SOURCES_AND_HEADERS})
214212

215-
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${AVRO_INCLUDE_DIR})
216213
if (WITH_ETP_SSL)
217-
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
214+
if (NOT USE_WINTLS_INSTEAD_OF_OPENSSL)
215+
target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE ${OPENSSL_INCLUDE_DIR})
216+
else()
217+
find_package(WINTLS REQUIRED)
218+
target_link_libraries(${PROJECT_NAME} PUBLIC WINTLS::WINTLS)
219+
endif()
218220
endif ()
219221

220222
target_include_directories(${PROJECT_NAME} INTERFACE
@@ -224,8 +226,8 @@ target_include_directories(${PROJECT_NAME} INTERFACE
224226
# organizing sources and headers in the Visual Studio Project
225227
if (WIN32)
226228
set (ETP_PREFIX "etp")
227-
source_group ("${ETP_PREFIX}" FILES ${FETPAPI_SOURCES} ${FETPAPI_HEADERS})
228-
source_group ("${ETP_PREFIX}\\ProtocolHandlers" FILES ${FETPAPI_PROTOCOL_SOURCES} ${FETPAPI_PROTOCOL_HEADERS})
229+
source_group ("${ETP_PREFIX}" FILES ${FETPAPI_ETP_SOURCES} ${FETPAPI_ETP_HEADERS})
230+
source_group ("${ETP_PREFIX}\\protocolHandlers" FILES ${FETPAPI_PROTOCOL_SOURCES} ${FETPAPI_PROTOCOL_HEADERS})
229231

230232
if (WITH_ETP_SSL)
231233
source_group ("${ETP_PREFIX}\\ssl" FILES ${FETPAPI_SSL_SOURCES} ${FETPAPI_SSL_HEADERS})
@@ -287,7 +289,7 @@ install(EXPORT Fetpapi-export
287289
)
288290

289291
INSTALL (
290-
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/nsDefinitions.h
292+
FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/macroDefinitions.h
291293
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fetpapi
292294
COMPONENT fetpapi_headers
293295
)
@@ -300,7 +302,7 @@ INSTALL (
300302

301303
INSTALL (
302304
FILES ${FETPAPI_PROTOCOL_HEADERS}
303-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fetpapi/etp/ProtocolHandlers
305+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/fetpapi/etp/protocolHandlers
304306
COMPONENT fetpapi_headers
305307
)
306308

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
Download (build and install if necessary) third party libraries:
1313
- BOOST : All versions from version 1.66 should be ok but you may experience some [min/max build issues](https://github.com/boostorg/beast/issues/1980) using version 1.72 or 1.73.
1414
- AVRO : https://avro.apache.org/releases.html#Download (starting from version 1.9.0 [except 1.11.1](https://issues.apache.org/jira/browse/AVRO-3601), build it with the above boost library.)
15-
- (OPTIONALLY) OpenSSL : version 3.4 is known to work.
15+
- (OPTIONALLY) OpenSSL : version 3.4 is known to work. OpenSSL is mandatory on Unix environement if you want SSL/TLS support. On Windows environment, you can depends on [Wintls](https://github.com/laudrup/boost-wintls/tree/master) instead
16+
- (OPTIONALLY) [Wintls](https://github.com/laudrup/boost-wintls/tree/master) : Starting from version 0.9.9. Only on Windows and only if you don't want to use OpenSSL to support SSL/TLS. FYI, WinTLs uses native Windows API [(SSPI/Schannel)](https://docs.microsoft.com/en-us/windows-server/security/tls/tls-ssl-schannel-ssp-overview) functionality instead of OpenSSL for providing TLS encrypted stream functionality.
1617
- (OPTIONALLY) [FESAPI](https://github.com/F2I-Consulting/fesapi/releases) : All versions from version 2.7.0.0 should be ok but a minimal version of 2.11.0.0 is recommended to automatically recognize FESAPI CMake Variables using CMake find Module and build silently the EtpClient example.
1718

1819
# Configure the build
@@ -32,9 +33,14 @@ FETPAPI uses cmake as its build tool. A 3.12 version or later of cmake is requir
3233
- You will then have to also provide the path to the SWIG (version 3 as a mininum version) executable http://swig.org/download.html in the SWIG_EXECUTABLE variable (and click again on "Configure" button)
3334
- you will find the wrappers in fetpapi/cs/src (fetpapi/cs also contains a VS2015 project for the wrappers) or fetpapi/python/src
3435
- OPTIONALLY, for SSL support, please enable the WITH_ETP_SSL variable and set the following variables :
35-
- OPENSSL_INCLUDE_DIR : the OpenSSL include directory
36-
- LIB_EAY_RELEASE : the OpenSSL crypto library you want to link with.
37-
- SSL_EAY_RELEASE : the OpenSSL ssl library you want to link with.
36+
- If you use OpenSSL which is mandatory on Unix and optional on Windows to support SSL/TLS
37+
- OPENSSL_INCLUDE_DIR : the OpenSSL include directory
38+
- LIB_EAY_RELEASE : the OpenSSL crypto library you want to link with.
39+
- SSL_EAY_RELEASE : the OpenSSL ssl library you want to link with.
40+
- USE_WINTLS_INSTEAD_OF_OPENSSL : must be set to OFF on windows
41+
- If you use Wintls on Windows to support SSL/TLS
42+
- USE_WINTLS_INSTEAD_OF_OPENSSL : must be set to ON on windows
43+
- WINTLS_ROOT : Path to the folder containing the include folder of Wintls
3844
- OPTIONALLY, for FESAPI (v2.7.0.0 as a minimal version) support (see [here](https://github.com/F2I-Consulting/fesapi) for documentation on how to build fesapi), please enable the WITH_FESAPI variable and usually set the following variable :
3945
- FESAPI_ROOT : The path to the folder containing include and lib folders of FESAPI (using [our own cmake find module](./cmake/modules/FindFESAPI.cmake))
4046

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,9 @@ under the License.
1818
-----------------------------------------------------------------------*/
1919
#pragma once
2020

21-
/** @namespace ${FETPAPI_ETP_NS} @brief The ${FETPAPI_ETP_NS} namespace. */
22-
#define ETP_NS ${FETPAPI_ETP_NS}
21+
/** @namespace @FETPAPI_ETP_NS@ @brief The @FETPAPI_ETP_NS@ namespace. */
22+
#define ETP_NS @FETPAPI_ETP_NS@
23+
24+
/** Build FETPAPI with ETP SSL support **/
25+
#cmakedefine01 WITH_ETP_SSL
26+
#cmakedefine01 USE_WINTLS_INSTEAD_OF_OPENSSL

cmake/modules/FindAVRO.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ Hints
3131
A user may set ``AVRO_ROOT`` to a avro installation root to tell this
3232
module where to look.
3333
#]=======================================================================]
34-
include(SelectLibraryConfigurations)
35-
3634
set(_AVRO_SEARCHES)
3735

3836
# Search AVRO_ROOT first if it is set.
@@ -69,6 +67,7 @@ if(NOT AVRO_LIBRARY)
6967
find_library(AVRO_LIBRARY_DEBUG NAMES ${AVRO_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
7068
endforeach()
7169

70+
include(SelectLibraryConfigurations)
7271
select_library_configurations(AVRO)
7372
endif()
7473

@@ -77,7 +76,7 @@ unset(AVRO_NAMES_DEBUG)
7776

7877
mark_as_advanced(AVRO_INCLUDE_DIR)
7978

80-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVRO REQUIRED_VARS AVRO_LIBRARY AVRO_INCLUDE_DIR)
79+
find_package_handle_standard_args(AVRO REQUIRED_VARS AVRO_LIBRARY AVRO_INCLUDE_DIR)
8180

8281
if(AVRO_FOUND)
8382
set(AVRO_INCLUDE_DIRS ${AVRO_INCLUDE_DIR})

cmake/modules/FindFESAPI.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ Hints
3131
A user may set ``FESAPI_ROOT`` to a fesapi installation root to tell this
3232
module where to look.
3333
#]=======================================================================]
34-
include(SelectLibraryConfigurations)
35-
3634
set(_FESAPI_SEARCHES)
3735

3836
# Search FESAPI_ROOT first if it is set.
@@ -70,6 +68,7 @@ if(NOT FESAPI_LIBRARY)
7068
find_library(FESAPI_LIBRARY_DEBUG NAMES ${FESAPI_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
7169
endforeach()
7270

71+
include(SelectLibraryConfigurations)
7372
select_library_configurations(FESAPI)
7473
endif()
7574

@@ -78,7 +77,7 @@ unset(FESAPI_NAMES_DEBUG)
7877

7978
mark_as_advanced(FESAPI_INCLUDE_DIR)
8079

81-
FIND_PACKAGE_HANDLE_STANDARD_ARGS(FESAPI REQUIRED_VARS FESAPI_LIBRARY FESAPI_INCLUDE_DIR)
80+
find_package_handle_standard_args(FESAPI REQUIRED_VARS FESAPI_LIBRARY FESAPI_INCLUDE_DIR)
8281

8382
if(FESAPI_FOUND)
8483
set(FESAPI_INCLUDE_DIRS ${FESAPI_INCLUDE_DIR})

cmake/modules/FindWINTLS.cmake

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2+
# file Copyright.txt or https://cmake.org/licensing for details.
3+
4+
#[=======================================================================[.rst:
5+
WINTLS
6+
--------
7+
8+
Find the native WinTLS includes.
9+
Heavily inspired by the official FindZLIB cmake module v3.27.
10+
11+
IMPORTED Targets
12+
^^^^^^^^^^^^^^^^
13+
14+
This module defines :prop_tgt:`IMPORTED` target ``WINTLS::WINTLS``, if
15+
WINTLS has been found.
16+
17+
Result Variables
18+
^^^^^^^^^^^^^^^^
19+
20+
This module defines the following variables:
21+
22+
::
23+
24+
WINTLS_INCLUDE_DIRS - where to find wintls.hpp
25+
WINTLS_FOUND - True if WINTLS found.
26+
27+
Hints
28+
^^^^^
29+
30+
A user may set ``WINTLS_ROOT`` to a WINTLS installation root to tell this
31+
module where to look.
32+
#]=======================================================================]
33+
34+
if(WINTLS_FIND_COMPONENTS AND NOT WINTLS_FIND_QUIETLY)
35+
message(AUTHOR_WARNING
36+
"WINTLS does not provide any COMPONENTS. Calling\n"
37+
" find_package(WINTLS COMPONENTS ...)\n"
38+
"will always fail."
39+
)
40+
endif()
41+
42+
set(_WINTLS_SEARCHES)
43+
44+
# Search WINTLS_ROOT first if it is set.
45+
if(WINTLS_ROOT)
46+
set(_WINTLS_SEARCH_ROOT PATHS ${WINTLS_ROOT} NO_DEFAULT_PATH)
47+
list(APPEND _WINTLS_SEARCHES _WINTLS_SEARCH_ROOT)
48+
endif()
49+
50+
# Normal search.
51+
set(_WINTLS_x86 "(x86)")
52+
set(_WINTLS_SEARCH_NORMAL
53+
PATHS "$ENV{ProgramFiles}/WINTLS"
54+
"$ENV{ProgramFiles${_WINTLS_x86}}/WINTLS")
55+
unset(_WINTLS_x86)
56+
list(APPEND _WINTLS_SEARCHES _WINTLS_SEARCH_NORMAL)
57+
58+
# Try each search configuration.
59+
foreach(search ${_WINTLS_SEARCHES})
60+
find_path(WINTLS_INCLUDE_DIR NAMES wintls.hpp ${${search}} PATH_SUFFIXES include)
61+
endforeach()
62+
63+
mark_as_advanced(WINTLS_INCLUDE_DIR)
64+
65+
find_package_handle_standard_args(WINTLS REQUIRED_VARS WINTLS_INCLUDE_DIR)
66+
67+
if(WINTLS_FOUND)
68+
set(WINTLS_INCLUDE_DIRS ${WINTLS_INCLUDE_DIR})
69+
70+
if(NOT TARGET WINTLS::WINTLS)
71+
add_library(WINTLS::WINTLS INTERFACE IMPORTED)
72+
set_target_properties(WINTLS::WINTLS PROPERTIES
73+
INTERFACE_INCLUDE_DIRECTORIES "${WINTLS_INCLUDE_DIRS}")
74+
endif()
75+
endif()

cmake/swigEtp1_2Include.i.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ under the License.
4040
%include "stdint.i"
4141
%include "std_string.i"
4242

43-
%include "../src/nsDefinitions.h"
43+
%include "../src/macroDefinitions.h"
4444

4545
//************************/
4646
// JAVA

cs/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ list (APPEND EXECUTE_COMMAND -csharp)
1717
if (WITH_FESAPI)
1818
list (APPEND EXECUTE_COMMAND -DWITH_FESAPI)
1919
endif (WITH_FESAPI)
20-
if (WITH_ETP_SSL)
21-
list (APPEND EXECUTE_COMMAND -DWITH_ETP_SSL)
22-
endif (WITH_ETP_SSL)
2320
list (APPEND EXECUTE_COMMAND -dllimport)
2421
list (APPEND EXECUTE_COMMAND ${PROJECT_NAME}${CMAKE_RELEASE_POSTFIX}-${Fetpapi_VERSION_MAJOR}.${Fetpapi_VERSION_MINOR}.dll)
2522
list (APPEND EXECUTE_COMMAND -namespace)

0 commit comments

Comments
 (0)