summaryrefslogtreecommitdiffstats
path: root/openssl-model.lua
blob: bbb5f60da7adaaa8d252e3fa0383e65ac30e89a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module(..., package.seeall)

local configfile = "/etc/ssl/openssl.cnf"

-- list of request entries that can be edited
local distinguished_names = { "countryName", "stateOrProvinceName", "localityName", "organizationName", "organizationalUnitName", "commonName", "emailAddress" }

local validate_distinguished_names = function(clientdata)
	local config = getopts.getoptsfromfile(configfile)
	local distinguished_name = config.req.distinguished_name or ""

	for i, name in ipairs(distinguished_names) do
		if config[distinguished_name][name.."_min"] then
		end
	end			
end

getdefaults = function()
	local defaults = cfe({ type="group", value={} })
	local config = getopts.getoptsfromfile(configfile)
	local distinguished_name = config.req.distinguished_name or ""

	for i, name in ipairs(distinguished_names) do
		defaults.value[name] = cfe({ label=name,
			value=config[distinguished_name][name .. "_default"] or "",
			descr=config[distinguished_name][name] })
	end			

	return defaults
end

setdefaults = function(clientdata)
	-- validate values
	validate_distinguished_names(clientdata)

end