core.certmanager: Resolve certs path relative to config dir
authorKim Alvefur <zash@zash.se>
Fri, 07 May 2021 16:35:37 +0200
changeset 11541 a09685a7b330
parent 11540 fb9bd9fa4356
child 11542 30feeb4d9d0b
core.certmanager: Resolve certs path relative to config dir Otherwise the default "certs" would be relative to $PWD, which works when testing from a source checkout, but not on installed systems where it usually points to the data directory. Also, the LuaFileSystem dir() iterator throws a hard error, which may cause a crash or other problems.
core/certmanager.lua
--- a/core/certmanager.lua	Wed May 05 17:54:44 2021 +0200
+++ b/core/certmanager.lua	Fri May 07 16:35:37 2021 +0200
@@ -158,7 +158,7 @@
 local function find_host_cert(host)
 	if not host then return nil; end
 	if not cert_index then
-		cert_index = index_certs(global_certificates);
+		cert_index = index_certs(resolve_path(config_path, global_certificates));
 	end
 	local certs = cert_index[host];
 	if certs then
@@ -177,7 +177,7 @@
 
 local function find_service_cert(service, port)
 	if not cert_index then
-		cert_index = index_certs(global_certificates);
+		cert_index = index_certs(resolve_path(config_path, global_certificates));
 	end
 	for _, certs in pairs(cert_index) do
 		for cert_filename, services in pairs(certs) do
@@ -346,7 +346,7 @@
 	if luasec_has.options.no_compression then
 		core_defaults.options.no_compression = configmanager.get("*", "ssl_compression") ~= true;
 	end
-	cert_index = index_certs(global_certificates);
+	cert_index = index_certs(resolve_path(config_path, global_certificates));
 end
 
 prosody.events.add_handler("config-reloaded", reload_ssl_config);