mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-11-29 21:18:29 +00:00
Require Mbed TLS built with MBEDTLS_THREADING_C
SSLServer runs TLS handshakes on several pool threads, and SSLClients may be used from several threads. Mbed TLS is thread-safe only when it is built with MBEDTLS_THREADING_C, which its default configuration leaves off. Without it, concurrent handshakes race on the PSA key store and the shared CTR-DRBG and corrupt memory. Stop the build with an #error when the option is missing, and document the requirement in the README. Define CPPHTTPLIB_MBEDTLS_SINGLE_THREADED to build anyway when Mbed TLS is only ever used from one thread. Distribution packages (Debian, Ubuntu, Homebrew) already enable the option, so builds against them are unaffected.
This commit is contained in:
1 parent
c76e1b6a98
commit
30d5f21b43
2 files changed
+10
No files matched your search
@@ -565,6 +565,13 @@ using socket_t = int;
|
||||
#define CPPHTTPLIB_MBEDTLS_V3
|
||||
#endif
|
||||
|
||||
// SSLServer (and SSLClients on several threads) use Mbed TLS concurrently.
|
||||
#if !defined(MBEDTLS_THREADING_C) && \
|
||||
!defined(CPPHTTPLIB_MBEDTLS_SINGLE_THREADED)
|
||||
#error \
|
||||
"Mbed TLS must be built with MBEDTLS_THREADING_C. Define CPPHTTPLIB_MBEDTLS_SINGLE_THREADED if it is only ever used from one thread."
|
||||
#endif
|
||||
|
||||
#endif // CPPHTTPLIB_MBEDTLS_SUPPORT
|
||||
|
||||
#ifdef CPPHTTPLIB_WOLFSSL_SUPPORT
|
||||
|
||||
Reference in new issue
Block a user