From 015bf6faee9044c6cc6ca76f34e247ac3f33b214 Mon Sep 17 00:00:00 2001 From: "Jerry.Wang" Date: Fri, 29 Aug 2025 15:51:45 +0800 Subject: [PATCH] added set_tls_verifier_callback --- src/internal/sio_client_impl.h | 9 +++++++++ src/sio_client.cpp | 9 +++++++++ src/sio_client.h | 8 ++++++++ 3 files changed, 26 insertions(+) diff --git a/src/internal/sio_client_impl.h b/src/internal/sio_client_impl.h index f4f02aa5..87868a8b 100644 --- a/src/internal/sio_client_impl.h +++ b/src/internal/sio_client_impl.h @@ -87,6 +87,7 @@ namespace sio #undef SYNTHESIS_SETTER + void clear_con_listeners() { @@ -188,6 +189,14 @@ namespace sio void update_ping_timeout_timer(); #if SIO_TLS + std::function verify_callback_cb; + + template + void set_tls_verify_callback(VerifyCallback callback) + { + verify_callback_cb = callback; + } + typedef websocketpp::lib::shared_ptr context_ptr; context_ptr on_tls_init(connection_hdl con); diff --git a/src/sio_client.cpp b/src/sio_client.cpp index 1cdb7f7c..e2de5157 100644 --- a/src/sio_client.cpp +++ b/src/sio_client.cpp @@ -74,6 +74,15 @@ namespace sio m_impl->set_proxy_basic_auth(uri, username, password); } + #if SIO_TLS + void client::set_tls_verify_callback(std::function callback) + { + if (m_impl) { + m_impl->set_tls_verify_callback(callback); + } + } + #endif + void client::connect(const std::string& uri) { m_impl->connect(uri, {}, {}, {}); diff --git a/src/sio_client.h b/src/sio_client.h index a8cbb9fe..632c25c3 100644 --- a/src/sio_client.h +++ b/src/sio_client.h @@ -11,6 +11,10 @@ #include "sio_message.h" #include "sio_socket.h" +#if SIO_TLS +#include "websocketpp/config/asio_client.hpp" +#endif + namespace asio { class io_context; } @@ -61,6 +65,10 @@ namespace sio void clear_con_listeners(); void clear_socket_listeners(); + + #if SIO_TLS + void set_tls_verify_callback(std::function callback); + #endif // Client Functions - such as send, etc. void connect(const std::string& uri);