diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index feb40553ea4..de1af96a370 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1117,6 +1117,10 @@ The TLS certificate bundle to use for HTTP requests made within the editor (e.g. from the AssetLib tab). If left empty, the [url=https://github.com/godotengine/godot/blob/master/thirdparty/certs/ca-certificates.crt]included Mozilla certificate bundle[/url] will be used. + + If [code]true[/code], enable TLSv1.3 negotiation. + [b]Note:[/b] Only supported when using Mbed TLS 3.0 or later (Linux distribution packages may be compiled against older system Mbed TLS packages), otherwise the maximum supported TLS version is always TLSv1.2. + The renderer type that will be checked off by default when creating a new project. Accepted strings are "forward_plus", "mobile" or "gl_compatibility". diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index c0c5bc04c15..e54bd231536 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -2204,9 +2204,8 @@ The CA certificates bundle to use for TLS connections. If this is set to a non-empty value, this will [i]override[/i] Godot's default [url=https://github.com/godotengine/godot/blob/master/thirdparty/certs/ca-certificates.crt]Mozilla certificate bundle[/url]. If left empty, the default certificate bundle will be used. If in doubt, leave this setting empty. - + If [code]true[/code], enable TLSv1.3 negotiation. - [b]Note:[/b] This is experimental, and may cause connections to fail in some cases (notably, if the remote server uses TLS handshake fragmentation). [b]Note:[/b] Only supported when using Mbed TLS 3.0 or later (Linux distribution packages may be compiled against older system Mbed TLS packages), otherwise the maximum supported TLS version is always TLSv1.2. diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 04fc8d15d63..a246249cfe3 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -974,6 +974,7 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { // SSL EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_GLOBAL_FILE, "network/tls/editor_tls_certificates", _SYSTEM_CERTS_PATH, "*.crt,*.pem", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "network/tls/enable_tls_v1.3", true, "") // Debug _initial_set("network/debug/remote_host", "127.0.0.1"); // Hints provided in setup_network diff --git a/modules/mbedtls/register_types.cpp b/modules/mbedtls/register_types.cpp index c0eca6ee18e..a38e833a7b5 100644 --- a/modules/mbedtls/register_types.cpp +++ b/modules/mbedtls/register_types.cpp @@ -52,7 +52,7 @@ void initialize_mbedtls_module(ModuleInitializationLevel p_level) { return; } - GLOBAL_DEF("network/tls/enable_tls_v1.3", false); + GLOBAL_DEF("network/tls/enable_tls_v1.3", true); #if MBEDTLS_VERSION_MAJOR >= 3 int status = psa_crypto_init(); diff --git a/modules/mbedtls/tls_context_mbedtls.cpp b/modules/mbedtls/tls_context_mbedtls.cpp index f7d3422f9fa..01e52efc444 100644 --- a/modules/mbedtls/tls_context_mbedtls.cpp +++ b/modules/mbedtls/tls_context_mbedtls.cpp @@ -32,6 +32,10 @@ #include "core/config/project_settings.h" +#ifdef TOOLS_ENABLED +#include "editor/editor_settings.h" +#endif // TOOLS_ENABLED + static void my_debug(void *ctx, int level, const char *file, int line, const char *str) { @@ -148,8 +152,17 @@ Error TLSContextMbedTLS::init_server(int p_transport, Ref p_options, } #if MBEDTLS_VERSION_MAJOR >= 3 - if (Engine::get_singleton()->is_editor_hint() || !(bool)GLOBAL_GET("network/tls/enable_tls_v1.3")) { - mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2); +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + if (!EditorSettings::get_singleton()->get_setting("network/tls/enable_tls_v1.3").operator bool()) { + mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2); + } + } else +#endif + { + if (!GLOBAL_GET("network/tls/enable_tls_v1.3").operator bool()) { + mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2); + } } #endif @@ -197,8 +210,17 @@ Error TLSContextMbedTLS::init_client(int p_transport, const String &p_hostname, } #if MBEDTLS_VERSION_MAJOR >= 3 - if (Engine::get_singleton()->is_editor_hint() || !(bool)GLOBAL_GET("network/tls/enable_tls_v1.3")) { - mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2); +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + if (!EditorSettings::get_singleton()->get_setting("network/tls/enable_tls_v1.3").operator bool()) { + mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2); + } + } else +#endif + { + if (!GLOBAL_GET("network/tls/enable_tls_v1.3").operator bool()) { + mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2); + } } #endif