From 5bea1b1c639424c178ae8d029774b34f2d62b0e2 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 7 Apr 2023 21:50:14 +0100 Subject: [PATCH] [Minor] Fix key type in output --- lualib/rspamadm/dkim_keygen.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lualib/rspamadm/dkim_keygen.lua b/lualib/rspamadm/dkim_keygen.lua index c00371298..5fff5707f 100644 --- a/lualib/rspamadm/dkim_keygen.lua +++ b/lualib/rspamadm/dkim_keygen.lua @@ -85,12 +85,13 @@ end local function print_public_key_dns(opts, base64_pk) + local key_type = opts.type == 'rsa' and 'rsa' or 'ed25519' if #base64_pk < 255 - 2 then - io.write(string.format('%s._domainkey IN TXT ( "v=DKIM1; k=rsa;" \n\t"p=%s" ) ;\n', opts.selector, base64_pk)) + io.write(string.format('%s._domainkey IN TXT ( "v=DKIM1; k=%s;" \n\t"p=%s" ) ;\n', opts.selector, key_type, base64_pk)) else -- Split it by parts local parts = split_string(base64_pk) - io.write(string.format('%s._domainkey IN TXT ( "v=DKIM1; k=rsa; "\n', opts.selector)) + io.write(string.format('%s._domainkey IN TXT ( "v=DKIM1; k=%s; "\n', opts.selector, key_type)) for i,part in ipairs(parts) do if i == 1 then io.write(string.format('\t"p=%s"\n', part)) @@ -104,6 +105,7 @@ local function print_public_key_dns(opts, base64_pk) end local function print_public_key(opts, pk) + local key_type = opts.type == 'rsa' and 'rsa' or 'ed25519' local base64_pk = tostring(rspamd_util.encode_base64(pk)) if opts.output == 'plain' then io.write(base64_pk) @@ -111,7 +113,7 @@ local function print_public_key(opts, pk) elseif opts.output == 'dns' then print_public_key_dns(opts, base64_pk) elseif opts.output == 'dnskey' then - io.write(string.format('v=DKIM1; k=rsa; p=%s\n', base64_pk)) + io.write(string.format('v=DKIM1; k=%s; p=%s\n', key_type, base64_pk)) end end -- 2.39.5