Do not wrap the PSK callbacks

This commit is contained in:
Bruno Silvestre 2023-02-16 10:37:59 -03:00
parent 4f28db9f53
commit 6708ccc381

View File

@ -203,25 +203,17 @@ local function newcontext(cfg)
-- PSK -- PSK
if cfg.psk then if cfg.psk then
if type(cfg.psk) == "function" then if type(cfg.psk) ~= "function" then
local pskcb = cfg.psk return nil, "invalid PSK callback parameter"
end
if cfg.mode == "client" then if cfg.mode == "client" then
succ, msg = context.setclientpskcb(ctx, function(hint, max_psk_len) succ, msg = context.setclientpskcb(ctx, cfg.psk)
local identity, psk = pskcb(hint, max_psk_len)
return identity, psk
end)
if not succ then return nil, msg end if not succ then return nil, msg end
else elseif cfg.mode == "server" then
succ, msg = context.setserverpskcb(ctx, function(identity, max_psk_len) succ, msg = context.setserverpskcb(ctx, cfg.psk)
local psk = pskcb(identity, max_psk_len)
return psk
end)
if not succ then return nil, msg end if not succ then return nil, msg end
end end
else
return nil, "invalid PSK Callback parameter"
end
end end
if config.capabilities.dane and cfg.dane then if config.capabilities.dane and cfg.dane then