changeset 6523:c9836434a9d5

mod_push2: warn instead of crash on bad/empty key
author Stephen Paul Weber <singpolyma@singpolyma.net>
date Tue, 28 Apr 2026 21:40:23 -0500
parents c4d3f0c208e9
children aaf92bf929e5
files mod_push2/mod_push2.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_push2/mod_push2.lua	Fri Apr 24 12:49:43 2026 +0200
+++ b/mod_push2/mod_push2.lua	Tue Apr 28 21:40:23 2026 -0500
@@ -319,7 +319,13 @@
 		key = "-----BEGIN PRIVATE KEY-----\n"..key.."\n-----END PRIVATE KEY-----"
 	end
 
-	local public_key = crypto.import_private_pem(key):public_raw()
+	local private_key = crypto.import_private_pem(key)
+	if not private_key then
+		module:log("warn", "Bad key for %q", match)
+		return
+	end
+
+	local public_key = private_key:public_raw()
 	local signer = jwt.new_signer(match.jwt_alg, key)
 	local payload = {}
 	for k, v in pairs(match.jwt_claims or {}) do