mod_tls: Log error when TLS initialization fails 0.9.3
authorMatthew Wild <mwild1@gmail.com>
Sun, 12 Jan 2014 06:16:49 -0500
changeset 5976 872ff4851c9b
parent 5975 0d219631d47b
child 5977 3f22f0de30f8
mod_tls: Log error when TLS initialization fails
plugins/mod_tls.lua
--- a/plugins/mod_tls.lua	Sun Jan 05 22:21:50 2014 +0100
+++ b/plugins/mod_tls.lua	Sun Jan 12 06:16:49 2014 -0500
@@ -91,14 +91,21 @@
 	return true;
 end);
 
+local function assert_log(ret, err)
+	if not ret then
+		module:log("error", "Unable to initialize TLS: %s", err);
+	end
+	return ret;
+end
+
 function module.load()
 	local ssl_config = config.rawget(module.host, "ssl");
 	if not ssl_config then
 		local base_host = module.host:match("%.(.*)");
 		ssl_config = config.get(base_host, "ssl");
 	end
-	host.ssl_ctx = create_context(host.host, "client", ssl_config); -- for outgoing connections
-	host.ssl_ctx_in = create_context(host.host, "server", ssl_config); -- for incoming connections
+	host.ssl_ctx = assert_log(create_context(host.host, "client", ssl_config)); -- for outgoing connections
+	host.ssl_ctx_in = assert_log(create_context(host.host, "server", ssl_config)); -- for incoming connections
 end
 
 function module.unload()