diff util/sslconfig.lua @ 13502:61da4491eebc

util.sslconfig: Support DH parameters as literal string Simplifies shipping well-known DH parameters in the config
author Kim Alvefur <zash@zash.se>
date Fri, 12 Jul 2024 15:21:08 +0200
parents d10957394a3c
children 2f754817bf4b
line wrap: on
line diff
--- a/util/sslconfig.lua	Thu Jul 11 15:25:57 2024 +0200
+++ b/util/sslconfig.lua	Fri Jul 12 15:21:08 2024 +0200
@@ -84,8 +84,18 @@
 finalisers.certificate = finalisers.key;
 finalisers.cafile = finalisers.key;
 finalisers.capath = finalisers.key;
--- XXX: copied from core/certmanager.lua, but this seems odd, because it would remove a dhparam function from the config
-finalisers.dhparam = finalisers.key;
+
+function finalisers.dhparam(value, config)
+	if type(value) == "string" then
+		if value:sub(1, 10) == "-----BEGIN" then
+			-- literal value
+			return value;
+		else
+			-- assume a filename
+			return resolve_path(config._basedir, value);
+		end
+	end
+end
 
 -- protocol = "x" should enable only that protocol
 -- protocol = "x+" should enable x and later versions