diff options
Diffstat (limited to 'modules/mbedtls/ssl_context_mbedtls.cpp')
-rw-r--r-- | modules/mbedtls/ssl_context_mbedtls.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/modules/mbedtls/ssl_context_mbedtls.cpp b/modules/mbedtls/ssl_context_mbedtls.cpp index 1ffb9bda05..cbb532587f 100644 --- a/modules/mbedtls/ssl_context_mbedtls.cpp +++ b/modules/mbedtls/ssl_context_mbedtls.cpp @@ -5,8 +5,8 @@ /* GODOT ENGINE */ /* https://godotengine.org */ /*************************************************************************/ -/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */ +/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2021 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 */ @@ -33,7 +33,6 @@ static void my_debug(void *ctx, int level, const char *file, int line, const char *str) { - printf("%s:%04d: %s", file, line, str); fflush(stdout); } @@ -68,15 +67,15 @@ Error CookieContextMbedTLS::setup() { } void CookieContextMbedTLS::clear() { - if (!inited) + if (!inited) { return; + } mbedtls_ctr_drbg_free(&ctr_drbg); mbedtls_entropy_free(&entropy); mbedtls_ssl_cookie_free(&cookie_ctx); } CookieContextMbedTLS::CookieContextMbedTLS() { - inited = false; } CookieContextMbedTLS::~CookieContextMbedTLS() { @@ -121,10 +120,12 @@ Error SSLContextMbedTLS::init_server(int p_transport, int p_authmode, Ref<Crypto // Locking key and certificate(s) pkey = p_pkey; certs = p_cert; - if (pkey.is_valid()) + if (pkey.is_valid()) { pkey->lock(); - if (certs.is_valid()) + } + if (certs.is_valid()) { certs->lock(); + } // Adding key and certificate int ret = mbedtls_ssl_conf_own_cert(&conf, &(certs->cert), &(pkey->pkey)); @@ -176,19 +177,22 @@ Error SSLContextMbedTLS::init_client(int p_transport, int p_authmode, Ref<X509Ce } void SSLContextMbedTLS::clear() { - if (!inited) + if (!inited) { return; + } mbedtls_ssl_free(&ssl); mbedtls_ssl_config_free(&conf); mbedtls_ctr_drbg_free(&ctr_drbg); mbedtls_entropy_free(&entropy); // Unlock and key and certificates - if (certs.is_valid()) + if (certs.is_valid()) { certs->unlock(); + } certs = Ref<X509Certificate>(); - if (pkey.is_valid()) + if (pkey.is_valid()) { pkey->unlock(); + } pkey = Ref<CryptoKeyMbedTLS>(); cookies = Ref<CookieContextMbedTLS>(); inited = false; @@ -200,7 +204,6 @@ mbedtls_ssl_context *SSLContextMbedTLS::get_context() { } SSLContextMbedTLS::SSLContextMbedTLS() { - inited = false; } SSLContextMbedTLS::~SSLContextMbedTLS() { |