Software /
code /
prosody-modules
File
mod_s2s_auth_fingerprint/mod_s2s_auth_fingerprint.lua @ 960:d773a51af9b1
mod_firewall: Add actions EVENT (fire an event), JUMP EVENT (transfer control to the handlers of an event), JUMP CHAIN (transfer control to another mod_firewall chain)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 05 Apr 2013 18:08:16 +0100 |
parent | 939:1415fc2a0ac0 |
child | 1131:e7b69d12fbfb |
line wrap: on
line source
-- Copyright (C) 2013 Kim Alvefur -- This file is MIT/X11 licensed. module:set_global(); local digest_algo = module:get_option_string(module:get_name().."_digest", "sha1"); local fingerprints = {}; local function hashprep(h) return tostring(h):lower():gsub(":",""); end for host, set in pairs(module:get_option("s2s_trusted_fingerprints", {})) do local host_set = {} if type(set) == "table" then -- list of fingerprints for i=1,#set do host_set[hashprep(set[i])] = true; end else -- assume single fingerprint host_set[hashprep(set)] = true; end fingerprints[host] = host_set; end module:hook("s2s-check-certificate", function(event) local session, host, cert = event.session, event.host, event.cert; local host_fingerprints = fingerprints[host]; if cert and host_fingerprints then local digest = cert:digest(digest_algo); if host_fingerprints[digest] then session.cert_chain_status = "valid"; session.cert_identity_status = "valid"; return true; end end end);