Software /
code /
prosody
Changeset
5423:4acc1598f391
mod_s2s: Add COMPAT cahin verification code for older LuaSec versions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 04 Apr 2013 19:21:47 +0200 |
parents | 5422:396072d62695 |
children | 5424:7318527c6dea |
files | plugins/mod_s2s/mod_s2s.lua |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_s2s/mod_s2s.lua Wed Apr 03 15:48:49 2013 +0200 +++ b/plugins/mod_s2s/mod_s2s.lua Thu Apr 04 19:21:47 2013 +0200 @@ -15,6 +15,7 @@ local tostring, type = tostring, type; local t_insert = table.insert; local xpcall, traceback = xpcall, debug.traceback; +local NULL = {}; local add_task = require "util.timer".add_task; local st = require "util.stanza"; @@ -226,11 +227,19 @@ end if cert then - local chain_valid, errors = conn:getpeerverification() + local chain_valid, errors; + if conn.getpeerverification then + chain_valid, errors = conn:getpeerverification(); + elseif conn.getpeerchainvalid then -- COMPAT mw/luasec-hg + chain_valid, errors = conn:getpeerchainvalid(); + errors = (not chain_valid) and { { errors } } or nil; + else + chain_valid, errors = false, { { "Chain verification not supported by this version of LuaSec" } }; + end -- Is there any interest in printing out all/the number of errors here? if not chain_valid then (session.log or log)("debug", "certificate chain validation result: invalid"); - for depth, t in ipairs(errors) do + for depth, t in ipairs(errors or NULL) do (session.log or log)("debug", "certificate error(s) at depth %d: %s", depth-1, table.concat(t, ", ")) end session.cert_chain_status = "invalid";