From 78c396508907ee753363de2a988fe717283c36c4 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Fri, 14 Sep 2018 01:31:26 +0200 Subject: net.server_epoll: Catch errors from luasec.wrap It throws if given an invalid TLS context --- net/server_epoll.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'net') diff --git a/net/server_epoll.lua b/net/server_epoll.lua index a9440258..ad888ef4 100644 --- a/net/server_epoll.lua +++ b/net/server_epoll.lua @@ -463,7 +463,11 @@ function interface:tlshandskake() self._tls = true; log("debug", "Start TLS on %s now", self); self:del(); - local conn, err = luasec.wrap(self.conn, self.tls_ctx); + local ok, conn, err = pcall(luasec.wrap, self.conn, self.tls_ctx); + if not ok then + log("error", "Failed to initialize TLS: %s", conn); + conn, err = ok, conn; + end if not conn then self:on("disconnect", err); self:destroy(); -- cgit v1.2.3