mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-20 11:29:38 +00:00
Bring the READMEs and the docs pages (en and ja) in line with the current header: - Fix the client sample that does not compile, the Transfer-Encoding statement for default headers, the verifier callback comment, the thread pool spawn rule, the sanitize_filename description, and the inverted Accept-Encoding sentence. - Describe recent behaviour: TLS errors behind Read/Write failures, Host validation, Connection: close for a body without length, content_reader rules, refused CONNECT, WebSocketClient proxies, CPPHTTPLIB_INTERIM_RESPONSE_MAX_COUNT, the SSE event size limit, and the payload limit of the Stream API. - Complete the API references of WebSocket, WebSocketClient and the stream:: helpers, and the SSE reconnect rules. - Fix cookbook pages: keychain loading on every backend, received Close status, a multipart sample that trusted the client's file name, an echo sample that sent binary as text, SNI, pre-request handler scope, stop() with WebSocket handlers, and the thread pool notes. - Restore the mutex in the LLM app's Chapter 5 code.
50 lines
2.2 KiB
Markdown
50 lines
2.2 KiB
Markdown
---
|
|
title: "T01. Choosing Between OpenSSL, mbedTLS, and wolfSSL"
|
|
order: 43
|
|
status: "draft"
|
|
---
|
|
|
|
cpp-httplib doesn't ship its own TLS implementation — it uses one of three backends that you pick at build time via a macro.
|
|
|
|
| Backend | Macro | Character |
|
|
| --- | --- | --- |
|
|
| OpenSSL | `CPPHTTPLIB_OPENSSL_SUPPORT` | Most widely used, richest feature set |
|
|
| mbedTLS | `CPPHTTPLIB_MBEDTLS_SUPPORT` | Lightweight, aimed at embedded |
|
|
| wolfSSL | `CPPHTTPLIB_WOLFSSL_SUPPORT` | Embedded-friendly, commercial support available |
|
|
|
|
## Build-time selection
|
|
|
|
Define the macro for your chosen backend before including `httplib.h`:
|
|
|
|
```cpp
|
|
#define CPPHTTPLIB_OPENSSL_SUPPORT
|
|
#include <httplib.h>
|
|
```
|
|
|
|
You'll also need to link against the backend's libraries (`libssl`, `libcrypto`, `libmbedtls`, `libwolfssl`, etc.).
|
|
|
|
## Which to pick
|
|
|
|
**When in doubt, OpenSSL**
|
|
It has the most features and the best documentation. For normal server use or Linux desktop apps, start here — you probably won't need anything else.
|
|
|
|
**To shrink binary size or target embedded**
|
|
mbedTLS or wolfSSL are a better fit. They're far more compact than OpenSSL and run on memory-constrained devices.
|
|
|
|
**When you need commercial support**
|
|
wolfSSL offers commercial licensing and support. If you're shipping in a product, it's worth considering.
|
|
|
|
## Supporting multiple backends
|
|
|
|
The usual approach is to treat each backend as a build variant and recompile the same source with different macros. cpp-httplib smooths over most of the API differences, but the backends are not 100% identical — always test.
|
|
|
|
## APIs that work across all backends
|
|
|
|
Certificate verification control, standing up an SSLServer, reading the peer certificate — these all share the same API across backends:
|
|
|
|
- [T02. Control SSL certificate verification](../t02-cert-verification)
|
|
- [T03. Start an SSL/TLS server](../t03-ssl-server)
|
|
- [T05. Access the peer certificate on the server](../t05-peer-cert)
|
|
|
|
> **Note:** On macOS, with any of the three backends, cpp-httplib automatically loads root certificates from the system keychain (via `CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN`, on by default). To disable this, define `CPPHTTPLIB_DISABLE_MACOSX_AUTOMATIC_ROOT_CERTIFICATES`.
|