mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-08-21 09:35:02 +00:00
Add WebSocketClient::enable_server_hostname_verification
WebSocketClient's TLS setup already threaded ClientTlsSessionOptions::server_hostname_verification through setup_client_tls_session(), the same path SSLClient uses, but never exposed a way to set it: create_stream() called setup_client_tls_session() without an options argument, so the default (verification on) was the only reachable value. Add the public setter, mirroring ClientImpl/SSLClient/Client, and wire it into create_stream()'s ClientTlsSessionOptions. Last open item from issue #2531's WebSocketClient/SSLClient API alignment.
This commit is contained in:
@@ -188,6 +188,7 @@ void set_ca_cert_path(const std::string &ca_cert_file_path,
|
||||
const std::string &ca_cert_dir_path = std::string());
|
||||
void set_ca_cert_store(tls::ca_store_t store);
|
||||
void enable_server_certificate_verification(bool enabled);
|
||||
void enable_server_hostname_verification(bool enabled);
|
||||
```
|
||||
|
||||
## Examples
|
||||
@@ -395,6 +396,7 @@ if (ws.connect()) {
|
||||
httplib::ws::WebSocketClient ws("wss://example.com/ws");
|
||||
ws.set_ca_cert_path("/path/to/ca-bundle.crt");
|
||||
ws.enable_server_certificate_verification(true);
|
||||
ws.enable_server_hostname_verification(true); // default; false skips the identity check
|
||||
|
||||
if (ws.connect()) {
|
||||
ws.send("secure message");
|
||||
|
||||
Reference in New Issue
Block a user