FALSE, ); public function action_download() { $id = $_POST['sid']; $so = ORM::factory('Service',$id); if (! $so->loaded()) HTTP::redirect('welcome/index'); $passwd = $_POST['passwd']; if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) { SystemMessage::add(array( 'title'=>_('Validation failed'), 'type'=>'error', 'body'=>_('Your requested password is too short.'), )); HTTP::redirect(URL::link('user','service/view/'.$so->id)); } if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) { $this->template->content = 'Unauthorised or doesnt exist?'; return FALSE; } // Log the download $smo = $so->service_memo; $smo->service_id = $so->id; $smo->account_id = $this->ao->id; $smo->memo = sprintf('SSL Certificate %s Downloaded.',$so->plugin()->serial()); $smo->save(); $file = sprintf('%s/%s.pkcs12',Kohana::$config->load('config')->tmpdir,$so->name()); openssl_pkcs12_export_to_file($so->plugin()->cert,$file,$so->plugin()->pk,$passwd,array('extracerts'=>$so->plugin()->cacerts())); $x = file_get_contents($file); unlink($file); $this->response->headers('Content-Type','application/pks12'); $this->response->headers('Content-Disposition','attachment; filename="'.basename($file).'"'); $this->response->body($x); $this->auto_render = FALSE; } } ?>