From 528e791a5fa0032f335c6410d3e961851e29b325 Mon Sep 17 00:00:00 2001 From: Fabio Alessandrelli Date: Wed, 7 Sep 2022 00:46:12 +0200 Subject: [Net] Rename StreamPeerSSL to StreamPeerTLS. SSL has been deprectated almost 10 years ago. --- core/io/http_client_tcp.cpp | 22 ++++++------- core/io/stream_peer_ssl.cpp | 75 ------------------------------------------- core/io/stream_peer_ssl.h | 77 --------------------------------------------- core/io/stream_peer_tls.cpp | 75 +++++++++++++++++++++++++++++++++++++++++++ core/io/stream_peer_tls.h | 77 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 163 insertions(+), 163 deletions(-) delete mode 100644 core/io/stream_peer_ssl.cpp delete mode 100644 core/io/stream_peer_ssl.h create mode 100644 core/io/stream_peer_tls.cpp create mode 100644 core/io/stream_peer_tls.h (limited to 'core/io') diff --git a/core/io/http_client_tcp.cpp b/core/io/http_client_tcp.cpp index 9499a6f8e3..e898db4204 100644 --- a/core/io/http_client_tcp.cpp +++ b/core/io/http_client_tcp.cpp @@ -32,7 +32,7 @@ #include "http_client_tcp.h" -#include "core/io/stream_peer_ssl.h" +#include "core/io/stream_peer_tls.h" #include "core/version.h" HTTPClient *HTTPClientTCP::_create_func() { @@ -104,8 +104,8 @@ void HTTPClientTCP::set_connection(const Ref &p_connection) { ERR_FAIL_COND_MSG(p_connection.is_null(), "Connection is not a reference to a valid StreamPeer object."); if (ssl) { - ERR_FAIL_NULL_MSG(Object::cast_to(p_connection.ptr()), - "Connection is not a reference to a valid StreamPeerSSL object."); + ERR_FAIL_NULL_MSG(Object::cast_to(p_connection.ptr()), + "Connection is not a reference to a valid StreamPeerTLS object."); } if (connection == p_connection) { @@ -354,10 +354,10 @@ Error HTTPClientTCP::poll() { } break; } } else if (ssl) { - Ref ssl; + Ref ssl; if (!handshaking) { - // Connect the StreamPeerSSL and start handshaking. - ssl = Ref(StreamPeerSSL::create()); + // Connect the StreamPeerTLS and start handshaking. + ssl = Ref(StreamPeerTLS::create()); ssl->set_blocking_handshake_enabled(false); Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, conn_host); if (err != OK) { @@ -369,7 +369,7 @@ Error HTTPClientTCP::poll() { handshaking = true; } else { // We are already handshaking, which means we can use your already active SSL connection. - ssl = static_cast>(connection); + ssl = static_cast>(connection); if (ssl.is_null()) { close(); status = STATUS_SSL_HANDSHAKE_ERROR; @@ -379,13 +379,13 @@ Error HTTPClientTCP::poll() { ssl->poll(); // Try to finish the handshake. } - if (ssl->get_status() == StreamPeerSSL::STATUS_CONNECTED) { + if (ssl->get_status() == StreamPeerTLS::STATUS_CONNECTED) { // Handshake has been successful. handshaking = false; ip_candidates.clear(); status = STATUS_CONNECTED; return OK; - } else if (ssl->get_status() != StreamPeerSSL::STATUS_HANDSHAKING) { + } else if (ssl->get_status() != StreamPeerTLS::STATUS_HANDSHAKING) { // Handshake has failed. close(); status = STATUS_SSL_HANDSHAKE_ERROR; @@ -418,9 +418,9 @@ Error HTTPClientTCP::poll() { case STATUS_CONNECTED: { // Check if we are still connected. if (ssl) { - Ref tmp = connection; + Ref tmp = connection; tmp->poll(); - if (tmp->get_status() != StreamPeerSSL::STATUS_CONNECTED) { + if (tmp->get_status() != StreamPeerTLS::STATUS_CONNECTED) { status = STATUS_CONNECTION_ERROR; return ERR_CONNECTION_ERROR; } diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp deleted file mode 100644 index 5b90fb52a6..0000000000 --- a/core/io/stream_peer_ssl.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/*************************************************************************/ -/* stream_peer_ssl.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#include "stream_peer_ssl.h" - -#include "core/config/engine.h" - -StreamPeerSSL *(*StreamPeerSSL::_create)() = nullptr; - -StreamPeerSSL *StreamPeerSSL::create() { - if (_create) { - return _create(); - } - return nullptr; -} - -bool StreamPeerSSL::available = false; - -bool StreamPeerSSL::is_available() { - return available; -} - -void StreamPeerSSL::set_blocking_handshake_enabled(bool p_enabled) { - blocking_handshake = p_enabled; -} - -bool StreamPeerSSL::is_blocking_handshake_enabled() const { - return blocking_handshake; -} - -void StreamPeerSSL::_bind_methods() { - ClassDB::bind_method(D_METHOD("poll"), &StreamPeerSSL::poll); - ClassDB::bind_method(D_METHOD("accept_stream", "stream", "private_key", "certificate", "chain"), &StreamPeerSSL::accept_stream, DEFVAL(Ref())); - ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname", "valid_certificate"), &StreamPeerSSL::connect_to_stream, DEFVAL(false), DEFVAL(String()), DEFVAL(Ref())); - ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerSSL::get_status); - ClassDB::bind_method(D_METHOD("get_stream"), &StreamPeerSSL::get_stream); - ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerSSL::disconnect_from_stream); - ClassDB::bind_method(D_METHOD("set_blocking_handshake_enabled", "enabled"), &StreamPeerSSL::set_blocking_handshake_enabled); - ClassDB::bind_method(D_METHOD("is_blocking_handshake_enabled"), &StreamPeerSSL::is_blocking_handshake_enabled); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_handshake"), "set_blocking_handshake_enabled", "is_blocking_handshake_enabled"); - - BIND_ENUM_CONSTANT(STATUS_DISCONNECTED); - BIND_ENUM_CONSTANT(STATUS_HANDSHAKING); - BIND_ENUM_CONSTANT(STATUS_CONNECTED); - BIND_ENUM_CONSTANT(STATUS_ERROR); - BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); -} diff --git a/core/io/stream_peer_ssl.h b/core/io/stream_peer_ssl.h deleted file mode 100644 index fe68667adc..0000000000 --- a/core/io/stream_peer_ssl.h +++ /dev/null @@ -1,77 +0,0 @@ -/*************************************************************************/ -/* stream_peer_ssl.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ - -#ifndef STREAM_PEER_SSL_H -#define STREAM_PEER_SSL_H - -#include "core/crypto/crypto.h" -#include "core/io/stream_peer.h" - -class StreamPeerSSL : public StreamPeer { - GDCLASS(StreamPeerSSL, StreamPeer); - -protected: - static StreamPeerSSL *(*_create)(); - static void _bind_methods(); - - static bool available; - - bool blocking_handshake = true; - -public: - enum Status { - STATUS_DISCONNECTED, - STATUS_HANDSHAKING, - STATUS_CONNECTED, - STATUS_ERROR, - STATUS_ERROR_HOSTNAME_MISMATCH - }; - - void set_blocking_handshake_enabled(bool p_enabled); - bool is_blocking_handshake_enabled() const; - - virtual void poll() = 0; - virtual Error accept_stream(Ref p_base, Ref p_key, Ref p_cert, Ref p_ca_chain = Ref()) = 0; - virtual Error connect_to_stream(Ref p_base, bool p_validate_certs = false, const String &p_for_hostname = String(), Ref p_valid_cert = Ref()) = 0; - virtual Status get_status() const = 0; - virtual Ref get_stream() const = 0; - - virtual void disconnect_from_stream() = 0; - - static StreamPeerSSL *create(); - - static bool is_available(); - - StreamPeerSSL() {} -}; - -VARIANT_ENUM_CAST(StreamPeerSSL::Status); - -#endif // STREAM_PEER_SSL_H diff --git a/core/io/stream_peer_tls.cpp b/core/io/stream_peer_tls.cpp new file mode 100644 index 0000000000..b1adde018a --- /dev/null +++ b/core/io/stream_peer_tls.cpp @@ -0,0 +1,75 @@ +/*************************************************************************/ +/* stream_peer_tls.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "stream_peer_tls.h" + +#include "core/config/engine.h" + +StreamPeerTLS *(*StreamPeerTLS::_create)() = nullptr; + +StreamPeerTLS *StreamPeerTLS::create() { + if (_create) { + return _create(); + } + return nullptr; +} + +bool StreamPeerTLS::available = false; + +bool StreamPeerTLS::is_available() { + return available; +} + +void StreamPeerTLS::set_blocking_handshake_enabled(bool p_enabled) { + blocking_handshake = p_enabled; +} + +bool StreamPeerTLS::is_blocking_handshake_enabled() const { + return blocking_handshake; +} + +void StreamPeerTLS::_bind_methods() { + ClassDB::bind_method(D_METHOD("poll"), &StreamPeerTLS::poll); + ClassDB::bind_method(D_METHOD("accept_stream", "stream", "private_key", "certificate", "chain"), &StreamPeerTLS::accept_stream, DEFVAL(Ref())); + ClassDB::bind_method(D_METHOD("connect_to_stream", "stream", "validate_certs", "for_hostname", "valid_certificate"), &StreamPeerTLS::connect_to_stream, DEFVAL(false), DEFVAL(String()), DEFVAL(Ref())); + ClassDB::bind_method(D_METHOD("get_status"), &StreamPeerTLS::get_status); + ClassDB::bind_method(D_METHOD("get_stream"), &StreamPeerTLS::get_stream); + ClassDB::bind_method(D_METHOD("disconnect_from_stream"), &StreamPeerTLS::disconnect_from_stream); + ClassDB::bind_method(D_METHOD("set_blocking_handshake_enabled", "enabled"), &StreamPeerTLS::set_blocking_handshake_enabled); + ClassDB::bind_method(D_METHOD("is_blocking_handshake_enabled"), &StreamPeerTLS::is_blocking_handshake_enabled); + + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "blocking_handshake"), "set_blocking_handshake_enabled", "is_blocking_handshake_enabled"); + + BIND_ENUM_CONSTANT(STATUS_DISCONNECTED); + BIND_ENUM_CONSTANT(STATUS_HANDSHAKING); + BIND_ENUM_CONSTANT(STATUS_CONNECTED); + BIND_ENUM_CONSTANT(STATUS_ERROR); + BIND_ENUM_CONSTANT(STATUS_ERROR_HOSTNAME_MISMATCH); +} diff --git a/core/io/stream_peer_tls.h b/core/io/stream_peer_tls.h new file mode 100644 index 0000000000..ed7334fab3 --- /dev/null +++ b/core/io/stream_peer_tls.h @@ -0,0 +1,77 @@ +/*************************************************************************/ +/* stream_peer_tls.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef STREAM_PEER_TLS_H +#define STREAM_PEER_TLS_H + +#include "core/crypto/crypto.h" +#include "core/io/stream_peer.h" + +class StreamPeerTLS : public StreamPeer { + GDCLASS(StreamPeerTLS, StreamPeer); + +protected: + static StreamPeerTLS *(*_create)(); + static void _bind_methods(); + + static bool available; + + bool blocking_handshake = true; + +public: + enum Status { + STATUS_DISCONNECTED, + STATUS_HANDSHAKING, + STATUS_CONNECTED, + STATUS_ERROR, + STATUS_ERROR_HOSTNAME_MISMATCH + }; + + void set_blocking_handshake_enabled(bool p_enabled); + bool is_blocking_handshake_enabled() const; + + virtual void poll() = 0; + virtual Error accept_stream(Ref p_base, Ref p_key, Ref p_cert, Ref p_ca_chain = Ref()) = 0; + virtual Error connect_to_stream(Ref p_base, bool p_validate_certs = false, const String &p_for_hostname = String(), Ref p_valid_cert = Ref()) = 0; + virtual Status get_status() const = 0; + virtual Ref get_stream() const = 0; + + virtual void disconnect_from_stream() = 0; + + static StreamPeerTLS *create(); + + static bool is_available(); + + StreamPeerTLS() {} +}; + +VARIANT_ENUM_CAST(StreamPeerTLS::Status); + +#endif // STREAM_PEER_TLS_H -- cgit v1.2.3