Misc fixes from live

This commit is contained in:
Deon George
2015-09-29 11:54:45 +10:00
parent df74512105
commit 425ea9ff10
10 changed files with 80 additions and 35 deletions

View File

@@ -20,12 +20,16 @@ class Controller_Reseller_SSL extends Controller_SSL {
);
public function action_list() {
$o = ORM::factory('SSL_CA')->where_authorised($this->ao);
if ($this->request->param('id') != 'Y')
$o->where_active();
Block::factory()
->title('SSL CA Certificates')
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('ca')
->data(ORM::factory('SSL_CA')->where_authorised($this->ao)->where_active()->find_all())
->data($o->find_all())
->columns(array(
'id'=>'ID',
'sign_cert'=>'Cert',

View File

@@ -56,8 +56,12 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
public function __call($name,$args) {
$m = 'get_'.$name;
if (method_exists($this->_so,$m))
if ($this->isCSR() AND method_exists($this,$m))
return $this->{$m}($args);
elseif (method_exists($this->_so,$m))
return $this->_so->{$m}($args);
else
throw new Kohana_Exception('Unknown method :method',array(':method'=>$name));
}
@@ -72,6 +76,13 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $this;
}
/**
* Is this just a CSR?
*/
public function isCSR() {
return ! $this->cert AND $this->csr;
}
/**
* Return all our CA Certs for this certificate
*/
@@ -103,16 +114,32 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
return $output;
}
public function get_dn() {
return SSL::csrsubject($this->csr);
}
public function get_valid_to() {
// @todo
return 'Unknown';
}
/**
* Renew an SSL Certificate
*/
// @todo: Renew renews the expiry date as 1 day too early.
public function renew($force=FALSE) {
$sslo = SSL::instance($this->cert);
$ssl_conf = Kohana::$config->load('ssl');
// If our certificate is not old enough skip
if ($sslo->get_valid_to() > time()+$ssl_conf['min_renew_days']*86400 AND ! $force)
return FALSE;
if ($this->cert) {
$sslo = SSL::instance($this->cert);
// If our certificate is not old enough skip
if ($sslo->get_valid_to() > time()+$ssl_conf['min_renew_days']*86400 AND ! $force)
return FALSE;
} elseif (! $this->csr) {
throw new Kohana_Exception('Unable to renew, no CERT or CSR');
}
$today = mktime(0,0,0,date('n'),date('j'),date('Y'));
$days = (int)(($this->service->invoiced_to()-$today)/86400);

View File

@@ -28,7 +28,7 @@ class SSL {
private static function _dec_to_hex($number) {
$hex = array();
if ($number == 0)
if ($number == 0 OR ! $number)
return '00';
while ($number > 0) {