diff options
Diffstat (limited to 'openssl-model.lua')
-rw-r--r-- | openssl-model.lua | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/openssl-model.lua b/openssl-model.lua index 01edc07..470d9ba 100644 --- a/openssl-model.lua +++ b/openssl-model.lua @@ -308,7 +308,7 @@ getreqdefaults = function() value=config.ca.default_ca, option=find_ca_sections() }) -- Add in the extensions local extensions = "" - local content = fs.read_file(configfile) + local content = fs.read_file(configfile) or "" config = config or format.parse_ini_file(content) if config.req.req_extensions then extensions = format.get_ini_section(content, config.req.req_extensions) @@ -323,7 +323,7 @@ setreqdefaults = function(defaults) -- If success, write the values to the config file if success then - local fileval = fs.read_file(configfile) + local fileval = fs.read_file(configfile) or "" config = config or format.parse_ini_file(fileval) local ext_section if not config.req or not config.req.req_extensions then @@ -384,7 +384,7 @@ submitrequest = function(defaults, user) local subject = create_subject_string(defaults, {"password", "password_confirm", "certtype", "extensions"}) -- Generate a temp config file for this request - local fileval = fs.read_file(configfile) + local fileval = fs.read_file(configfile) or "" config = config or format.parse_ini_file(fileval) local temp = format.dostounix(defaults.value.extensions.value) local ext_section @@ -468,7 +468,7 @@ approverequest = function(request) -- Add the serial number to the end of the cert file name local serialpath = getconfigentry(certtype, "serial") - local serialfile = fs.read_file(serialpath) + local serialfile = fs.read_file(serialpath) or "" local serial = string.match(serialfile, "%x%x") local certname = certdir..request.."."..serial @@ -562,7 +562,7 @@ viewcert = function(cert) end getcert = function(cert) - local f = fs.read_file(certdir..cert..".pfx") + local f = fs.read_file(certdir..cert..".pfx") or "" local a,b,c,d = string.match(cert, "([^%.]*)%.([^%.]*)%.([^%.]*).([^%.]*)") c = string.gsub(unhashname(c), "[^%w_-]", "") return cfe({ type="raw", value=f, label=c..".pfx", option="application/x-pkcs12" }) @@ -640,7 +640,7 @@ listrevoked = function() config = config or format.parse_ini_file(fs.read_file(configfile) or "") local databasepath = getconfigentry(config.ca.default_ca, "database") local revoked = {} - local database = fs.read_file_as_array(databasepath) + local database = fs.read_file_as_array(databasepath) or {} for x,line in ipairs(database) do if string.sub(line,1,1) == "R" then revoked[#revoked + 1] = string.match(line, "^%S+%s+%S+%s+%S+%s+(%S+)") @@ -659,12 +659,12 @@ getcrl = function(crltype) f:close() if crltype == "DER" then crlfile.label = "ca-der-crl.crl" - crlfile.value = fs.read_file(crlfile.label) + crlfile.value = fs.read_file(crlfile.label) or "" elseif crltype == "PEM" then crlfile.label = "ca-crl.crl" - crlfile.value = fs.read_file(crlfile.label) + crlfile.value = fs.read_file(crlfile.label) or "" else - crlfile.value = fs.read_file("ca-crl.crl") + crlfile.value = fs.read_file("ca-crl.crl") or "" end return crlfile end |