Software /
code /
prosody
Comparison
net/server_epoll.lua @ 9431:c3c0523a37c6
net.server_epoll: Catch errors from luasec.wrap
It throws if given an invalid TLS context
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 14 Sep 2018 01:31:26 +0200 |
parent | 9430:412ff404bf58 |
child | 9432:2e3f66475cc8 |
comparison
equal
deleted
inserted
replaced
9430:412ff404bf58 | 9431:c3c0523a37c6 |
---|---|
461 self:setreadtimeout(false); | 461 self:setreadtimeout(false); |
462 if not self._tls then | 462 if not self._tls then |
463 self._tls = true; | 463 self._tls = true; |
464 log("debug", "Start TLS on %s now", self); | 464 log("debug", "Start TLS on %s now", self); |
465 self:del(); | 465 self:del(); |
466 local conn, err = luasec.wrap(self.conn, self.tls_ctx); | 466 local ok, conn, err = pcall(luasec.wrap, self.conn, self.tls_ctx); |
467 if not ok then | |
468 log("error", "Failed to initialize TLS: %s", conn); | |
469 conn, err = ok, conn; | |
470 end | |
467 if not conn then | 471 if not conn then |
468 self:on("disconnect", err); | 472 self:on("disconnect", err); |
469 self:destroy(); | 473 self:destroy(); |
470 return conn, err; | 474 return conn, err; |
471 end | 475 end |