diff options
Diffstat (limited to 'openssl-controller.lua')
-rw-r--r-- | openssl-controller.lua | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/openssl-controller.lua b/openssl-controller.lua index 78cbe2b..64dd307 100644 --- a/openssl-controller.lua +++ b/openssl-controller.lua @@ -3,7 +3,22 @@ module (..., package.seeall) require("getopts") -default_action = "read" +default_action = "status" + +mvc={} +mvc.pre_exec = function(self) + if self.conf.action ~= "status" and self.conf.action ~= "editconfigfile" then + local verify = self.model.verifyopenssl() + if verify.value == false then + redirect(self) + end + end +end + +-- Show openssl status +status = function(self) + return self.model.getstatus() +end -- View all pending and approved requests and revoked certificates readall = function(self) @@ -38,7 +53,7 @@ request = function(self) cmdresult = cfe({ value="Request submitted", label="Request result" }) self.sessiondata.cmdresult = cmdresult --request.descr = "Submitted request" - redirect(self, "readall") + redirect(self, "read") end else request = self.model.getnewrequest() @@ -116,5 +131,28 @@ getrevoked = function(self) end -- Put the CA cert +-- FIXME this won't work because haserl doesn't support file upload. Untested putcacert = function(self) + local retval = self.model.putca(self.clientdata.ca, self.clientdata.password, self.clientdata.Upload) + retval.type = "form" + retval.option = "Upload" + retval.label = "Upload CA Certificate" + return retval +end + +editconfigfile = function(self) + local saved = false + if self.clientdata.Save then + saved = self.model.setconfigfile(self.clientdata.filecontent) + end + local configfile = self.model.getconfigfile() + configfile.type = "form" + configfile.option = "Save" + configfile.label = "Edit config file" + if saved then + configfile.descr = "Saved config file" + elseif self.clientdata.Save then + configfile.errtxt = "Failed to save config file" + end + return configfile end |