[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.

(cherry picked from commit eeac6f8c7f)
This commit is contained in:
Fabio Alessandrelli
2023-05-18 19:22:23 +02:00
committed by Yuri Sizov
parent 7d5d5b7bd1
commit 238b8357a3
3 changed files with 6 additions and 1 deletions

View File

@@ -332,7 +332,7 @@ void WSLPeer::_do_client_handshake() {
if (connection == tcp) {
// Start SSL handshake
tls = Ref<StreamPeerTLS>(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.
@@ -504,6 +504,8 @@ Error WSLPeer::connect_to_url(const String &p_url, Ref<TLSOptions> 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;