diff options
Diffstat (limited to 'openssl-controller.lua')
-rw-r--r-- | openssl-controller.lua | 43 |
1 files changed, 35 insertions, 8 deletions
diff --git a/openssl-controller.lua b/openssl-controller.lua index af92ec5..ff9fb91 100644 --- a/openssl-controller.lua +++ b/openssl-controller.lua @@ -5,19 +5,21 @@ require("getopts") default_action = "status" +local sslstatus + 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 + sslstatus = self.model.getstatus() + if (sslstatus.value.version.errtxt and self.conf.action ~= "status") + or (sslstatus.value.conffile.errtxt and self.conf.action ~= "status" and self.conf.action ~= "editconfigfile") + or ((sslstatus.value.cacert.errtxt or sslstatus.value.cakey.errtxt) and self.conf.action ~= "status" and self.conf.action ~= "editconfigfile" and self.conf.action ~= "putcacert" and self.conf.action ~= "generatecacert") then + redirect(self) end end -- Show openssl status status = function(self) - return self.model.getstatus() + return sslstatus end -- View all pending and approved requests and revoked certificates @@ -143,15 +145,40 @@ 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) + if self.clientdata.Upload then + if not retval.errtxt then + redirect(self) + end + end retval.type = "form" - retval.option = "Upload" retval.label = "Upload CA Certificate" + retval.option = "Upload" + return retval end +-- Generate a self-signed CA +generatecacert = function(self) + local request + if self.clientdata.Generate then + -- Try to submit the request + request = self.model.generateca(self.clientdata) + if not request.errtxt then + redirect(self) + end + else + request = self.model.getnewcarequest() + end + + request.type = "form" + request.label = "Generate CA Certificate" + request.option = "Generate" + + return request +end + editconfigfile = function(self) local saved = false if self.clientdata.Save then |