From d4b0d4617b022a2f6e037c027e35d04c9d8544d7 Mon Sep 17 00:00:00 2001 From: John McKay Date: Sat, 26 Jan 2019 11:27:15 +0000 Subject: keys from config and http arrayized --- src/plugins/lua/arc.lua | 10 ++++++++++ src/plugins/lua/dkim_signing.lua | 36 ++++++++++-------------------------- 2 files changed, 20 insertions(+), 26 deletions(-) (limited to 'src/plugins/lua') diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua index cec738df7..d22114b59 100644 --- a/src/plugins/lua/arc.lua +++ b/src/plugins/lua/arc.lua @@ -514,6 +514,16 @@ local function arc_signing_cb(task) return end + -- TODO: support multiple signatures here and not this hack + if #p.keys > 0 then + p.selector = p.keys[1].selector + if p.keys[1].type == "raw" then + p.rawkey = p.keys[1].key + else + p.key = p.keys[1].key + end + end + p.arc_cv = 'none' p.arc_idx = 1 p.no_cache = true diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua index b510a437e..a65356448 100644 --- a/src/plugins/lua/dkim_signing.lua +++ b/src/plugins/lua/dkim_signing.lua @@ -151,35 +151,19 @@ local function dkim_signing_cb(task) try_redis_key(p.selector) end else - if ((p.key or p.rawkey) and p.selector) then - if p.key then + if #p.keys > 0 then + for _, k in ipairs(p.keys) do -- templates - p.key = lua_util.template(p.key, { + k.key = lua_util.template(k.key, { domain = p.domain, - selector = p.selector + selector = k.selector }) - local exists,err = rspamd_util.file_exists(p.key) - if not exists then - if err and err == 'No such file or directory' then - lua_util.debugm(N, task, 'cannot read key from "%s": %s', p.key, err) - else - rspamd_logger.warnx(task, 'cannot read key from "%s": %s', p.key, err) - end - return false - end - - lua_util.debugm(N, task, 'key found at "%s", use selector "%s" for domain "%s"', + -- TODO: pass this to the function instead of setting some variable + p.selector = k.selector + p.key = k.key + -- TODO: push handling of multiples keys into sign code + lua_util.debugm(N, task, 'using key "%s", use selector "%s" for domain "%s"', p.key, p.selector, p.domain) - end - -- TODO: push handling of multiples keys into sign code - if #p.keys > 0 then - lua_util.debugm(N, task, 'signing for multiple selectors, %1', #p.keys); - for _, k in ipairs(p.keys) do - p.selector = k.selector - p.key = k.key - do_sign() - end - else do_sign() end else @@ -232,4 +216,4 @@ rspamd_config:register_symbol({ }) -- Add dependency on DKIM checks -rspamd_config:register_dependency(settings['symbol'], 'DKIM_CHECK') \ No newline at end of file +rspamd_config:register_dependency(settings['symbol'], 'DKIM_CHECK') -- cgit v1.2.3