aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-03-22 17:35:26 +0100
committerKim Alvefur <zash@zash.se>2020-03-22 17:35:26 +0100
commit9e95f5e9f6a5447b9b68fc20b3a490b553d6b06c (patch)
tree86b32af9cedd4b54b6b1059604c329f1851f566c
parent773203771da3d2b443ec7e05b6a180456e195b84 (diff)
downloadprosody-9e95f5e9f6a5447b9b68fc20b3a490b553d6b06c.tar.gz
prosody-9e95f5e9f6a5447b9b68fc20b3a490b553d6b06c.zip
mod_admin_telnet: Handle unavailable cipher info (fixes #1510)
The LuaSec :info() method gathers info using the OpenSSL function SSL_get_current_cipher(). Documentation for this function states that it may return NULL if no session has been established (yet). If so, the LuaSec functions wrapping this return nil, triggering a nil-indexing error in mod_admin_telnet.
-rw-r--r--plugins/mod_admin_telnet.lua13
1 files changed, 8 insertions, 5 deletions
diff --git a/plugins/mod_admin_telnet.lua b/plugins/mod_admin_telnet.lua
index 59eca28b..b0e349da 100644
--- a/plugins/mod_admin_telnet.lua
+++ b/plugins/mod_admin_telnet.lua
@@ -528,11 +528,14 @@ local function tls_info(session, line)
common_info(session, line);
if session.secure then
local sock = session.conn and session.conn.socket and session.conn:socket();
- if sock and sock.info then
- local info = sock:info();
- line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher);
- else
- line[#line+1] = "(cipher info unavailable)";
+ if sock then
+ local info = sock.info and sock:info();
+ if info then
+ line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher);
+ else
+ -- TLS session might not be ready yet
+ line[#line+1] = "(cipher info unavailable)";
+ end
end
else
line[#line+1] = "(insecure)";