diff options
Diffstat (limited to 'openssl-model.lua')
-rw-r--r-- | openssl-model.lua | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/openssl-model.lua b/openssl-model.lua index 04a8cb9..2a02129 100644 --- a/openssl-model.lua +++ b/openssl-model.lua @@ -34,7 +34,7 @@ local ca_mandatory_entries = { "new_certs_dir", "certificate", "private_key", "d -- Create a cfe with the distinguished name defaults local getdefaults = function() local defaults = cfe({ type="group", value={} }) - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") local distinguished_name = config.req.distinguished_name or "" -- Get the distinguished name defaults @@ -50,7 +50,7 @@ end -- Validate the values of distinguished names using the min/max found in the config file local validate_distinguished_names = function(values) - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") local distinguished_name = config.req.distinguished_name or "" local success = true @@ -79,13 +79,13 @@ end local write_distinguished_names = function(file, values, ignorevalues) local reverseignore = {} for i,value in ipairs(ignorevalues) do reverseignore[value]=i end - config = config or format.parse_configfile2(file) + config = config or format.parse_ini_file(file) local distinguished_name = config.req.distinguished_name or "" for name,value in pairs(values.value) do if not reverseignore[name] then local wname = name.."_default" - file = format.update_configfile2(file, distinguished_name, wname, value.value) + file = format.update_ini_file(file, distinguished_name, wname, value.value) end end config = nil @@ -118,7 +118,7 @@ local create_subject_string = function(values, ignorevalues) end local getconfigentry = function(section, value) - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") local result = config[section][value] or config[""][value] or "" while string.find(result, "%$[%w_]+") do local sub = string.match(result, "%$[%w_]+") @@ -129,7 +129,7 @@ end -- Find the sections of the config file that define ca's (ca -name option) local find_ca_sections = function() - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") local cert_types = {} for section in pairs(config) do @@ -167,8 +167,8 @@ local validate_request = function(defaults, noextensionsections) end if defaults.value.extensions then - config = config or format.parse_configfile2(fs.read_file(configfile)) - local extensions = format.parse_configfile2(defaults.value.extensions.value) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") + local extensions = format.parse_ini_file(defaults.value.extensions.value) for name,value in pairs(extensions or {}) do if name ~= "" and noextensionsections then defaults.value.extensions.errtxt = "Cannot contain sections" @@ -184,7 +184,7 @@ local validate_request = function(defaults, noextensionsections) end local copyca = function(cacert, cakey) - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") local certpath = getconfigentry(config.ca.default_ca, "certificate") local cmd = "cp "..cacert.." "..certpath local f = io.popen(cmd) @@ -262,7 +262,7 @@ getstatus = function() cacertcontents.errtxt="" cakey.errtxt="File not defined" else - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") if (not config) or (not config.ca) or (not config.ca.default_ca) then conffile.errtxt="Invalid config file" cacert.errtxt="File not defined" @@ -309,9 +309,9 @@ getreqdefaults = function() -- Add in the extensions local extensions = "" local content = fs.read_file(configfile) - config = config or format.parse_configfile2(content) + config = config or format.parse_ini_file(content) if config.req.req_extensions then - extensions = format.get_section(content, config.req.req_extensions) + extensions = format.get_ini_section(content, config.req.req_extensions) end defaults.value.extensions = cfe({ type="longtext", label="Additional x509 Extensions", value=extensions, descr="These extensions can be overridden by the Certificate Type" }) @@ -324,18 +324,18 @@ setreqdefaults = function(defaults) -- If success, write the values to the config file if success then local fileval = fs.read_file(configfile) - config = config or format.parse_configfile2(fileval) + config = config or format.parse_ini_file(fileval) local ext_section if not config.req or not config.req.req_extensions then ext_section = "v3_req" while config[ext_section] do ext_section = "v3_req_"..tostring(os.time()) end - fileval = format.update_configfile2(fileval, "req", "req_extensions", ext_section) + fileval = format.update_ini_file(fileval, "req", "req_extensions", ext_section) else ext_section = config.req.req_extensions end config = nil - fileval = format.set_section(fileval, ext_section, defaults.value.extensions.value) - fileval = format.update_configfile2(fileval, "ca", "default_ca", defaults.value.certtype.value) + fileval = format.set_ini_section(fileval, ext_section, defaults.value.extensions.value) + fileval = format.update_ini_file(fileval, "ca", "default_ca", defaults.value.certtype.value) fileval = write_distinguished_names(fileval, defaults, {"certtype", "extensions"}) fs.write_file(configfile, fileval) end @@ -385,7 +385,7 @@ submitrequest = function(defaults, user) -- Generate a temp config file for this request local fileval = fs.read_file(configfile) - config = config or format.parse_configfile2(fileval) + config = config or format.parse_ini_file(fileval) local temp = defaults.value.extensions.value local ext_section if not config.req or not config.req.req_extensions then @@ -394,21 +394,21 @@ submitrequest = function(defaults, user) else ext_section = config.req.req_extensions for name,value in pairs(config[ext_section] or {}) do - temp = format.update_configfile2(temp, "", name, value) + temp = format.update_ini_file(temp, "", name, value) end end if config[defaults.value.certtype.value].x509_extensions then ext_section = config[defaults.value.certtype.value].x509_extensions for name,value in pairs(config[ext_section] or {}) do if not string.find(value, "issuer") then - temp = format.update_configfile2(temp, "", name, value) + temp = format.update_ini_file(temp, "", name, value) end end end if temp ~= "" then - fileval = format.set_section(fileval, ext_section, temp) - fileval = format.update_configfile2(fileval, "req", "req_extensions", ext_section) + fileval = format.set_ini_section(fileval, ext_section, temp) + fileval = format.update_ini_file(fileval, "req", "req_extensions", ext_section) end fs.write_file(configfile..".tmp", fileval) @@ -634,7 +634,7 @@ renewcert = function(cert, approve) end listrevoked = function() - config = config or format.parse_configfile2(fs.read_file(configfile)) + 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) @@ -810,7 +810,7 @@ checkenvironment = function(set) errtxt[#errtxt+1], cmdline[#cmdline+1] = checkdir("request directory", requestdir) -- Then check for the config file entries - config = config or format.parse_configfile2(fs.read_file(configfile)) + config = config or format.parse_ini_file(fs.read_file(configfile) or "") if config then local chkpath = getconfigentry(config.ca.default_ca, "new_certs_dir") |