Skip to content

Commit 97aa1f9

Browse files
authored
Fix mbedtls-3.0 problem (#322)
* Fix mbedtls-3.0 problem This cause CI to fail on macOS. See this migration guide => https://github.com/ARMmbed/mbedtls/blob/development/docs/3.0-migration-guide.md * cmake change find header file * define macro for mbedtls >= 3 * update api call * Update IXWebSocketVersion.h * Update CHANGELOG.md
1 parent 3f1fc69 commit 97aa1f9

6 files changed

+18
-2
lines changed

CMake/FindMbedTLS.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h)
22

3+
# mbedtls-3.0 changed headers files, and we need to ifdef'out a few things
4+
find_path(MBEDTLS_VERSION_GREATER_THAN_3 mbedtls/build_info.h)
5+
36
find_library(MBEDTLS_LIBRARY mbedtls)
47
find_library(MBEDX509_LIBRARY mbedx509)
58
find_library(MBEDCRYPTO_LIBRARY mbedcrypto)

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,11 @@ if (USE_TLS)
195195
# This MBEDTLS_FOUND check is to help find a cmake manually configured MbedTLS
196196
if (NOT MBEDTLS_FOUND)
197197
find_package(MbedTLS REQUIRED)
198+
199+
if (MBEDTLS_VERSION_GREATER_THAN_3)
200+
target_compile_definitions(ixwebsocket PRIVATE IXWEBSOCKET_USE_MBED_TLS_MIN_VERSION_3)
201+
endif()
202+
198203
endif()
199204
target_include_directories(ixwebsocket PUBLIC $<BUILD_INTERFACE:${MBEDTLS_INCLUDE_DIRS}>)
200205
target_link_libraries(ixwebsocket ${MBEDTLS_LIBRARIES})

docs/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All changes to this project will be documented in this file.
44

5+
## [11.3.1] - 2021-10-22
6+
7+
(library/cmake) Compatible with MbedTLS 3 + fix a bug on Windows where the incorrect remote port is computed (#320)
8+
59
## [11.3.0] - 2021-09-20
610

711
(library/cmake) Only find OpenSSL, MbedTLS, zlib if they have not already been found, make CMake install optional (#317) + Use GNUInstallDirs in cmake (#318)

ixwebsocket/IXSocketMbedTLS.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ namespace ix
132132
errMsg = "Cannot parse cert file '" + _tlsOptions.certFile + "'";
133133
return false;
134134
}
135+
#ifdef IXWEBSOCKET_USE_MBED_TLS_MIN_VERSION_3
136+
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "", mbedtls_ctr_drbg_random, &_ctr_drbg) < 0)
137+
#else
135138
if (mbedtls_pk_parse_keyfile(&_pkey, _tlsOptions.keyFile.c_str(), "") < 0)
139+
#endif
136140
{
137141
errMsg = "Cannot parse key file '" + _tlsOptions.keyFile + "'";
138142
return false;

ixwebsocket/IXSocketMbedTLS.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <mbedtls/debug.h>
1414
#include <mbedtls/entropy.h>
1515
#include <mbedtls/error.h>
16-
#include <mbedtls/net.h>
16+
#include <mbedtls/net_sockets.h>
1717
#include <mbedtls/platform.h>
1818
#include <mbedtls/x509.h>
1919
#include <mbedtls/x509_crt.h>

ixwebsocket/IXWebSocketVersion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
#pragma once
88

9-
#define IX_WEBSOCKET_VERSION "11.3.0"
9+
#define IX_WEBSOCKET_VERSION "11.3.1"

0 commit comments

Comments
 (0)