From 0e651dd4fd7b468cab3aff43b5a08e64cd5cfb5c Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 19 Feb 2023 11:53:14 +0100 Subject: [PATCH] Pre-create the required folders for the self signed cert files automatically. --- modules/http_server_simple/http_server_simple.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/http_server_simple/http_server_simple.cpp b/modules/http_server_simple/http_server_simple.cpp index f41766f60..2adc4e57c 100644 --- a/modules/http_server_simple/http_server_simple.cpp +++ b/modules/http_server_simple/http_server_simple.cpp @@ -30,6 +30,8 @@ #include "http_server_simple.h" +#include "core/os/dir_access.h" + #include "http_parser.h" #include "modules/web/http/web_server_cookie.h" #include "simple_web_server_request.h" @@ -436,6 +438,12 @@ void HTTPServerSimple::_stop_workers() { void HTTPServerSimple::_set_internal_certs(Ref p_crypto) { const String cache_path = "user://cache/web/"; + + DirAccess *dir = DirAccess::create(DirAccess::ACCESS_USERDATA); + ERR_FAIL_COND(!dir); + dir->make_dir_recursive(cache_path); + memdelete(dir); + const String key_path = cache_path.plus_file("http_server_simple_cert.key"); const String crt_path = cache_path.plus_file("http_server_simple_cert.crt"); bool regen = !FileAccess::exists(key_path) || !FileAccess::exists(crt_path);