2016-07-27 04:25:17 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides SSL management
|
|
|
|
*
|
|
|
|
* @package SSL
|
|
|
|
* @category Controllers
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
|
|
|
class Controller_SSL extends Controller_TemplateDefault {
|
|
|
|
protected $auth_required = false;
|
2016-07-29 13:04:34 +00:00
|
|
|
protected $icon = 'fa fa-certificate';
|
2016-07-27 04:25:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Render out an SSL CA certificate
|
|
|
|
*/
|
|
|
|
public function action_ca() {
|
|
|
|
$o = ORM::factory('SSL_CA',$this->request->param('id'));
|
|
|
|
|
|
|
|
$this->response->body($o->loaded() ? $o->sign_cert."\n" : NULL);
|
|
|
|
|
|
|
|
$this->response->headers(array('Content-Type' => 'text/plain'));
|
|
|
|
if ($o->loaded() AND ! is_null($this->request->query('download')))
|
|
|
|
$this->response->headers('Content-Disposition','attachment; filename="'.$o->id.'.ca.crt"');
|
|
|
|
$this->auto_render = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the public certificate of a service
|
|
|
|
*/
|
|
|
|
public function action_cert() {
|
|
|
|
$o = ORM::factory('Service',$this->request->param('id'));
|
|
|
|
|
|
|
|
if ($o->loaded() and ($o->plugin() instanceof Model_Service_Plugin))
|
|
|
|
$this->response->body($o->plugin()->cert."\n");
|
|
|
|
|
|
|
|
$this->response->headers(array('Content-Type' => 'text/plain'));
|
|
|
|
if ($o->loaded() AND ! is_null($this->request->query('download')))
|
|
|
|
$this->response->headers('Content-Disposition','attachment; filename="'.$o->id.'.crt"');
|
|
|
|
$this->auto_render = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render out an SSL CA chain
|
|
|
|
*/
|
|
|
|
public function action_chain() {
|
|
|
|
$result = '';
|
|
|
|
|
|
|
|
$o = ORM::factory('Service',$this->request->param('id'));
|
|
|
|
|
|
|
|
if ($o->loaded() and $o->plugin() instanceof Model_Service_Plugin_Ssl) {
|
|
|
|
foreach ($o->plugin()->chain() as $cao)
|
|
|
|
$result .= $cao->sign_cert."\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->response->body($result);
|
|
|
|
$this->response->headers(array('Content-Type' => 'text/plain'));
|
|
|
|
if ($o->loaded() AND ! is_null($this->request->query('download')))
|
|
|
|
$this->response->headers('Content-Disposition','attachment; filename="ca.crts"');
|
|
|
|
$this->auto_render = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|