diff options
author | Matthew Wild <mwild1@gmail.com> | 2021-05-13 11:17:13 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2021-05-13 11:17:13 +0100 |
commit | 5bc8b2a379e21901429e4d7f5e10e424ca85e403 (patch) | |
tree | dc46f3423a4319e09fe85402fa76f15568ad89d1 /plugins/mod_dialback.lua | |
parent | 37ad3b8fb2039684273b3cb63b5b573e879b04d7 (diff) | |
parent | a95576d485eda2a273b4d66c4c2b363f88c5c43a (diff) | |
download | prosody-5bc8b2a379e21901429e4d7f5e10e424ca85e403.tar.gz prosody-5bc8b2a379e21901429e4d7f5e10e424ca85e403.zip |
Merge 0.11->trunk
Diffstat (limited to 'plugins/mod_dialback.lua')
-rw-r--r-- | plugins/mod_dialback.lua | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/plugins/mod_dialback.lua b/plugins/mod_dialback.lua index 7396e07e..0df8d36f 100644 --- a/plugins/mod_dialback.lua +++ b/plugins/mod_dialback.lua @@ -13,6 +13,7 @@ local log = module._log; local st = require "util.stanza"; local sha256_hash = require "util.hashes".sha256; local sha256_hmac = require "util.hashes".hmac_sha256; +local secure_equals = require "util.hashes".equals; local nameprep = require "util.encodings".stringprep.nameprep; local uuid_gen = require"util.uuid".generate; @@ -21,20 +22,6 @@ local xmlns_stream = "http://etherx.jabber.org/streams"; local dialback_requests = setmetatable({}, { __mode = 'v' }); local dialback_secret = sha256_hash(module:get_option_string("dialback_secret", uuid_gen()), true); -local dwd = module:get_option_boolean("dialback_without_dialback", false); - ---- Helper to check that a session peer's certificate is valid -function check_cert_status(session) - local host = session.direction == "outgoing" and session.to_host or session.from_host - local conn = session.conn:socket() - local cert - if conn.getpeercertificate then - cert = conn:getpeercertificate() - end - - return module:fire_event("s2s-check-certificate", { host = host, session = session, cert = cert }); -end - function module.save() return { dialback_secret = dialback_secret }; @@ -56,7 +43,7 @@ function initiate_dialback(session) end function verify_dialback(id, to, from, key) - return key == generate_dialback(id, to, from); + return secure_equals(key, generate_dialback(id, to, from)); end module:hook("stanza/jabber:server:dialback:verify", function(event) @@ -110,15 +97,6 @@ module:hook("stanza/jabber:server:dialback:result", function(event) return true; end - if dwd and origin.secure then - if check_cert_status(origin, from) == false then - return - elseif origin.cert_chain_status == "valid" and origin.cert_identity_status == "valid" then - origin.sends2s(st.stanza("db:result", { to = from, from = to, id = attr.id, type = "valid" })); - module:fire_event("s2s-authenticated", { session = origin, host = from, mechanism = "dialback" }); - return true; - end - end origin.hosts[from] = { dialback_key = stanza[1] }; |