Changeset

13752:49bbdc22846d 13.0

certmanager: Add more debug logging around cert indexing Currently it's not obvious which directories have been indexed (especially when the resulting index is empty), or why certain files have been skipped.
author Matthew Wild <mwild1@gmail.com>
date Mon, 24 Feb 2025 17:48:58 +0000
parents 13750:53c39fdb007f
children 13753:07b6a669f7f1
files core/certmanager.lua
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/core/certmanager.lua	Sat Feb 22 21:48:07 2025 +0100
+++ b/core/certmanager.lua	Mon Feb 24 17:48:58 2025 +0000
@@ -91,7 +91,7 @@
 				index_certs(full, files_by_name, depth_limit-1);
 			end
 		elseif file:find("%.crt$") or file:find("fullchain") then -- This should catch most fullchain files
-			local f = io_open(full);
+			local f, err = io_open(full);
 			if f then
 				-- TODO look for chained certificates
 				local firstline = f:read();
@@ -113,13 +113,17 @@
 								files_by_name[name] = { [full] = services; };
 							end
 						end
+					else
+						log("debug", "Skipping expired certificate: %s", full);
 					end
 				end
 				f:close();
+			elseif err then
+				log("debug", "Failed to open file for indexing: %s", full);
 			end
 		end
 	end
-	log("debug", "Certificate index: %q", files_by_name);
+	log("debug", "Certificate index in %s: %q", dir, files_by_name);
 	-- | hostname | filename | service |
 	return files_by_name;
 end