mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-13 22:50:19 +02:00
problem: unsecured websocket is rarely used in production
Solution: support websocket with tls (wss)
This commit is contained in:
@@ -114,8 +114,14 @@ zmq::session_base_t::session_base_t (class io_thread_t *io_thread_,
|
||||
_socket (socket_),
|
||||
_io_thread (io_thread_),
|
||||
_has_linger_timer (false),
|
||||
_addr (addr_)
|
||||
_addr (addr_),
|
||||
_wss_hostname (NULL)
|
||||
{
|
||||
if (options_.wss_hostname.length () > 0) {
|
||||
_wss_hostname = (char *) malloc (options_.wss_hostname.length () + 1);
|
||||
assert (_wss_hostname);
|
||||
strcpy (_wss_hostname, options_.wss_hostname.c_str ());
|
||||
}
|
||||
}
|
||||
|
||||
const zmq::endpoint_uri_pair_t &zmq::session_base_t::get_endpoint () const
|
||||
@@ -138,6 +144,9 @@ zmq::session_base_t::~session_base_t ()
|
||||
if (_engine)
|
||||
_engine->terminate ();
|
||||
|
||||
if (_wss_hostname)
|
||||
free (_wss_hostname);
|
||||
|
||||
LIBZMQ_DELETE (_addr);
|
||||
}
|
||||
|
||||
@@ -563,6 +572,10 @@ zmq::session_base_t::connecter_factory_entry_t
|
||||
connecter_factory_entry_t (protocol_name::ws,
|
||||
&zmq::session_base_t::create_connecter_ws),
|
||||
#endif
|
||||
#ifdef ZMQ_HAVE_WSS
|
||||
connecter_factory_entry_t (protocol_name::wss,
|
||||
&zmq::session_base_t::create_connecter_wss),
|
||||
#endif
|
||||
#if !defined ZMQ_HAVE_WINDOWS && !defined ZMQ_HAVE_OPENVMS \
|
||||
&& !defined ZMQ_HAVE_VXWORKS
|
||||
connecter_factory_entry_t (protocol_name::ipc,
|
||||
@@ -690,7 +703,16 @@ zmq::own_t *zmq::session_base_t::create_connecter_ws (io_thread_t *io_thread_,
|
||||
bool wait_)
|
||||
{
|
||||
return new (std::nothrow)
|
||||
ws_connecter_t (io_thread_, this, options, _addr, wait_);
|
||||
ws_connecter_t (io_thread_, this, options, _addr, wait_, false, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef ZMQ_HAVE_WSS
|
||||
zmq::own_t *zmq::session_base_t::create_connecter_wss (io_thread_t *io_thread_,
|
||||
bool wait_)
|
||||
{
|
||||
return new (std::nothrow) ws_connecter_t (io_thread_, this, options, _addr,
|
||||
wait_, true, _wss_hostname);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user