mod_tls: Log error when TLS initialization fails
authorMatthew Wild <mwild1@gmail.com>
Sun, 12 Jan 2014 11:16:49 +0000 (06:16 -0500)
committerMatthew Wild <mwild1@gmail.com>
Sun, 12 Jan 2014 11:16:49 +0000 (06:16 -0500)
plugins/mod_tls.lua

index 80b56abbb41b8b6482ecf1846ea9cb75d2142a43..54c69873aa20d359606756b1054cb5dbc438f1d0 100644 (file)
@@ -91,14 +91,21 @@ module:hook_stanza(xmlns_starttls, "proceed", function (session, stanza)
        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()