Mercurial > prosody-hg
comparison plugins/mod_admin_telnet.lua @ 10699:fd77b6cec38d 0.11
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.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 22 Mar 2020 17:35:26 +0100 |
| parents | 232841373711 |
| children | 929c95e518f0 |
comparison
equal
deleted
inserted
replaced
| 10690:27d15097c235 | 10699:fd77b6cec38d |
|---|---|
| 526 local function tls_info(session, line) | 526 local function tls_info(session, line) |
| 527 line = line or {}; | 527 line = line or {}; |
| 528 common_info(session, line); | 528 common_info(session, line); |
| 529 if session.secure then | 529 if session.secure then |
| 530 local sock = session.conn and session.conn.socket and session.conn:socket(); | 530 local sock = session.conn and session.conn.socket and session.conn:socket(); |
| 531 if sock and sock.info then | 531 if sock then |
| 532 local info = sock:info(); | 532 local info = sock.info and sock:info(); |
| 533 line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher); | 533 if info then |
| 534 else | 534 line[#line+1] = ("(%s with %s)"):format(info.protocol, info.cipher); |
| 535 line[#line+1] = "(cipher info unavailable)"; | 535 else |
| 536 -- TLS session might not be ready yet | |
| 537 line[#line+1] = "(cipher info unavailable)"; | |
| 538 end | |
| 536 end | 539 end |
| 537 else | 540 else |
| 538 line[#line+1] = "(insecure)"; | 541 line[#line+1] = "(insecure)"; |
| 539 end | 542 end |
| 540 return table.concat(line, " "); | 543 return table.concat(line, " "); |
