Comparison

plugins/mod_tls.lua @ 5976:872ff4851c9b 0.9.3

mod_tls: Log error when TLS initialization fails
author Matthew Wild <mwild1@gmail.com>
date Sun, 12 Jan 2014 06:16:49 -0500
parent 5378:ec3accda44d3
child 5978:d21ea6001bba
child 5987:bd90250ee1ee
comparison
equal deleted inserted replaced
5975:0d219631d47b 5976:872ff4851c9b
89 session.conn:starttls(ssl_ctx); 89 session.conn:starttls(ssl_ctx);
90 session.secure = false; 90 session.secure = false;
91 return true; 91 return true;
92 end); 92 end);
93 93
94 local function assert_log(ret, err)
95 if not ret then
96 module:log("error", "Unable to initialize TLS: %s", err);
97 end
98 return ret;
99 end
100
94 function module.load() 101 function module.load()
95 local ssl_config = config.rawget(module.host, "ssl"); 102 local ssl_config = config.rawget(module.host, "ssl");
96 if not ssl_config then 103 if not ssl_config then
97 local base_host = module.host:match("%.(.*)"); 104 local base_host = module.host:match("%.(.*)");
98 ssl_config = config.get(base_host, "ssl"); 105 ssl_config = config.get(base_host, "ssl");
99 end 106 end
100 host.ssl_ctx = create_context(host.host, "client", ssl_config); -- for outgoing connections 107 host.ssl_ctx = assert_log(create_context(host.host, "client", ssl_config)); -- for outgoing connections
101 host.ssl_ctx_in = create_context(host.host, "server", ssl_config); -- for incoming connections 108 host.ssl_ctx_in = assert_log(create_context(host.host, "server", ssl_config)); -- for incoming connections
102 end 109 end
103 110
104 function module.unload() 111 function module.unload()
105 host.ssl_ctx = nil; 112 host.ssl_ctx = nil;
106 host.ssl_ctx_in = nil; 113 host.ssl_ctx_in = nil;