Do not create 'certificates' on 'cfg' if it does not exist

This commit is contained in:
Bruno Silvestre 2019-02-26 15:49:51 -03:00
parent 1c3bf23551
commit c0cb85d77f

View File

@ -74,21 +74,13 @@ local function newcontext(cfg)
-- Mode -- Mode
succ, msg = context.setmode(ctx, cfg.mode) succ, msg = context.setmode(ctx, cfg.mode)
if not succ then return nil, msg end if not succ then return nil, msg end
if not cfg.certificates then local certificates = cfg.certificates
cfg.certificates = {} if not certificates then
certificates = {
{ certificate = cfg.certificate, key = cfg.key, password = cfg.password }
}
end end
local singularcertificate = {} for _, certificate in ipairs(certificates) do
local singularexists = false
for _, prop in pairs({ "key", "certificate", "password" }) do
if cfg[prop] then
singularexists = true
singularcertificate[prop] = cfg[prop]
end
end
if singularexists then
table.insert(crt.certificates, singularcertificate)
end
for _, certificate in pairs(cfg.certificates) do
-- Load the key -- Load the key
if certificate.key then if certificate.key then
if certificate.password and if certificate.password and