Skip to content

Commit

Permalink
[Minor] Fix key type in output
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Apr 7, 2023
1 parent 81c36ce commit 5bea1b1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lualib/rspamadm/dkim_keygen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -104,14 +105,15 @@ 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)
io.write("\n")
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

Expand Down

0 comments on commit 5bea1b1

Please sign in to comment.