Minor fixes to ssl and core

This commit is contained in:
Deon George
2011-12-30 10:54:54 +11:00
parent 4a68621fc7
commit 125407656d
9 changed files with 77 additions and 13 deletions

View File

@@ -34,7 +34,36 @@ class Model_SSL_CA extends ORMOSB {
return SSL::issuer($this->sign_cert);
}
public function subject() {
return SSL::subject($this->sign_cert);
}
// @todo SAVE: auto work out the parent_ssl_ca_id
public function save(Validation $validation = NULL) {
// If our parent_ssl_ca_id is null, we'll need to work it out
if (is_null($this->parent_ssl_ca_id)) {
$i = SSL::issuer($this->sign_cert);
$po = NULL;
foreach (ORM::factory('ssl_ca')->find_all() as $sco)
if ($sco->subject() == $i) {
$po = $sco;
break;
}
if (is_null($po)) {
SystemMessage::add(array(
'title'=>'Certificate NOT Recorded',
'type'=>'warning',
'body'=>sprintf('Parent Certificate is not available (%s)',$this->issuer()),
));
return FALSE;
} else
$this->parent_ssl_ca_id = $po->id;
}
// Save the record
return parent::save($validation);
}
}
?>