Skip to content

Commit fe84b84

Browse files
committed
[mbedTLS] Enable TLS 1.3 negotiation by default
1 parent af0bc17 commit fe84b84

File tree

5 files changed

+33
-7
lines changed

5 files changed

+33
-7
lines changed

doc/classes/EditorSettings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@
11171117
<member name="network/tls/editor_tls_certificates" type="String" setter="" getter="">
11181118
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.
11191119
</member>
1120+
<member name="network/tls/enable_tls_v1.3" type="bool" setter="" getter="">
1121+
If [code]true[/code], enable TLSv1.3 negotiation.
1122+
[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.
1123+
</member>
11201124
<member name="project_manager/default_renderer" type="String" setter="" getter="">
11211125
The renderer type that will be checked off by default when creating a new project. Accepted strings are "forward_plus", "mobile" or "gl_compatibility".
11221126
</member>

doc/classes/ProjectSettings.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2204,9 +2204,8 @@
22042204
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.
22052205
If in doubt, leave this setting empty.
22062206
</member>
2207-
<member name="network/tls/enable_tls_v1.3" type="bool" setter="" getter="" default="false">
2207+
<member name="network/tls/enable_tls_v1.3" type="bool" setter="" getter="" default="true">
22082208
If [code]true[/code], enable TLSv1.3 negotiation.
2209-
[b]Note:[/b] This is experimental, and may cause connections to fail in some cases (notably, if the remote server uses TLS handshake fragmentation).
22102209
[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.
22112210
</member>
22122211
<member name="physics/2d/default_angular_damp" type="float" setter="" getter="" default="1.0">

editor/editor_settings.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
974974

975975
// SSL
976976
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);
977+
EDITOR_SETTING_BASIC(Variant::BOOL, PROPERTY_HINT_NONE, "network/tls/enable_tls_v1.3", true, "")
977978

978979
// Debug
979980
_initial_set("network/debug/remote_host", "127.0.0.1"); // Hints provided in setup_network

modules/mbedtls/register_types.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void initialize_mbedtls_module(ModuleInitializationLevel p_level) {
5252
return;
5353
}
5454

55-
GLOBAL_DEF("network/tls/enable_tls_v1.3", false);
55+
GLOBAL_DEF("network/tls/enable_tls_v1.3", true);
5656

5757
#if MBEDTLS_VERSION_MAJOR >= 3
5858
int status = psa_crypto_init();

modules/mbedtls/tls_context_mbedtls.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232

3333
#include "core/config/project_settings.h"
3434

35+
#ifdef TOOLS_ENABLED
36+
#include "editor/editor_settings.h"
37+
#endif // TOOLS_ENABLED
38+
3539
static void my_debug(void *ctx, int level,
3640
const char *file, int line,
3741
const char *str) {
@@ -148,8 +152,17 @@ Error TLSContextMbedTLS::init_server(int p_transport, Ref<TLSOptions> p_options,
148152
}
149153

150154
#if MBEDTLS_VERSION_MAJOR >= 3
151-
if (Engine::get_singleton()->is_editor_hint() || !(bool)GLOBAL_GET("network/tls/enable_tls_v1.3")) {
152-
mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2);
155+
#ifdef TOOLS_ENABLED
156+
if (Engine::get_singleton()->is_editor_hint()) {
157+
if (!EditorSettings::get_singleton()->get_setting("network/tls/enable_tls_v1.3").operator bool()) {
158+
mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2);
159+
}
160+
} else
161+
#endif
162+
{
163+
if (!GLOBAL_GET("network/tls/enable_tls_v1.3").operator bool()) {
164+
mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2);
165+
}
153166
}
154167
#endif
155168

@@ -197,8 +210,17 @@ Error TLSContextMbedTLS::init_client(int p_transport, const String &p_hostname,
197210
}
198211

199212
#if MBEDTLS_VERSION_MAJOR >= 3
200-
if (Engine::get_singleton()->is_editor_hint() || !(bool)GLOBAL_GET("network/tls/enable_tls_v1.3")) {
201-
mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2);
213+
#ifdef TOOLS_ENABLED
214+
if (Engine::get_singleton()->is_editor_hint()) {
215+
if (!EditorSettings::get_singleton()->get_setting("network/tls/enable_tls_v1.3").operator bool()) {
216+
mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2);
217+
}
218+
} else
219+
#endif
220+
{
221+
if (!GLOBAL_GET("network/tls/enable_tls_v1.3").operator bool()) {
222+
mbedtls_ssl_conf_max_tls_version(&conf, MBEDTLS_SSL_VERSION_TLS1_2);
223+
}
202224
}
203225
#endif
204226

0 commit comments

Comments
 (0)