From eeac6f8c7f070a9f4674bfa51ec35c57516311c0 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Fri, 12 May 2023 19:55:58 +0200 Subject: [TLS] Fix crashes trying to use TLS when not available. If no StreamPeerTLS implementation is available, HTTPClient and WebSocketPeer will now correctly refuse to connect using TLS returning ERR_UNAVAILABLE. Similarly, ENetConnection will refuse to setup DTLS when PacketPeerDTLS is not available. --- modules/websocket/wsl_peer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'modules') diff --git a/modules/websocket/wsl_peer.cpp b/modules/websocket/wsl_peer.cpp index 816d5276b9..109d5102c3 100644 --- a/modules/websocket/wsl_peer.cpp +++ b/modules/websocket/wsl_peer.cpp @@ -332,7 +332,7 @@ void WSLPeer::_do_client_handshake() { if (connection == tcp) { // Start SSL handshake tls = Ref(StreamPeerTLS::create()); - ERR_FAIL_COND_MSG(tls.is_null(), "SSL is not available in this build."); + ERR_FAIL_COND(tls.is_null()); if (tls->connect_to_stream(tcp, requested_host, tls_options) != OK) { close(-1); return; // Error. @@ -501,6 +501,8 @@ Error WSLPeer::connect_to_url(const String &p_url, Ref p_options) { path = "/"; } + ERR_FAIL_COND_V_MSG(use_tls && !StreamPeerTLS::is_available(), ERR_UNAVAILABLE, "WSS is not available in this build."); + requested_url = p_url; requested_host = host; -- cgit v1.2.3