aboutsummaryrefslogtreecommitdiffstats
path: root/lualib
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2023-08-11 14:33:33 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2023-08-11 14:33:33 +0100
commit0c038ee69711a6d01fcc29bd2abbc24a962f12da (patch)
tree4d7adeda40ea35b659a452bd8bb0236bf3f74237 /lualib
parent6d132913b9d0f6387e00834adadb6b5cf35d1ae3 (diff)
downloadrspamd-0c038ee69711a6d01fcc29bd2abbc24a962f12da.tar.gz
rspamd-0c038ee69711a6d01fcc29bd2abbc24a962f12da.zip
[Fix] Fix output of non-RSA DKIM keys
Issue: #4570
Diffstat (limited to 'lualib')
-rw-r--r--lualib/rspamadm/dkim_keygen.lua12
1 files changed, 7 insertions, 5 deletions
diff --git a/lualib/rspamadm/dkim_keygen.lua b/lualib/rspamadm/dkim_keygen.lua
index 3d51903dc..211094dfc 100644
--- a/lualib/rspamadm/dkim_keygen.lua
+++ b/lualib/rspamadm/dkim_keygen.lua
@@ -104,14 +104,14 @@ local function print_public_key_dns(opts, base64_pk)
end
-local function print_public_key(opts, pk)
+local function print_public_key(opts, pk, need_base64)
local key_type = opts.type == 'rsa' and 'rsa' or 'ed25519'
- local base64_pk = tostring(rspamd_util.encode_base64(pk))
+ local base64_pk = need_base64 and tostring(rspamd_util.encode_base64(pk)) or tostring(pk)
if opts.output == 'plain' then
io.write(base64_pk)
io.write("\n")
elseif opts.output == 'dns' then
- print_public_key_dns(opts, base64_pk)
+ print_public_key_dns(opts, base64_pk, false)
elseif opts.output == 'dnskey' then
io.write(string.format('v=DKIM1; k=%s; p=%s\n', key_type, base64_pk))
end
@@ -130,7 +130,8 @@ local function gen_rsa_key(opts)
sk:save("-", opts.priv_output)
end
- print_public_key(opts, tostring(pk))
+ -- We generate key directly via lua_rsa and it returns unencoded raw data
+ print_public_key(opts, tostring(pk), true)
end
local function gen_eddsa_key(opts)
@@ -149,7 +150,8 @@ local function gen_eddsa_key(opts)
io.flush()
end
- print_public_key(opts, tostring(pk))
+ -- gen_dkim_keypair function returns everything encoded in base64, so no need to do anything
+ print_public_key(opts, tostring(pk), false)
end
local function handler(args)