This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/ssl/classes/Controller/User/Ssl.php

51 lines
1.5 KiB
PHP
Raw Normal View History

2011-12-16 23:31:35 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides User SSL functions
*
2013-03-19 22:35:19 +00:00
* @package SSL
* @category Controllers/User
2011-12-16 23:31:35 +00:00
* @author Deon George
2013-03-19 22:35:19 +00:00
* @copyright (c) 2009-2013 Open Source Billing
2011-12-16 23:31:35 +00:00
* @license http://dev.osbill.net/license.html
*/
class Controller_User_SSL extends Controller_TemplateDefault_User {
protected $secure_actions = array(
'download'=>FALSE,
);
public function action_download() {
$id = $_POST['sid'];
2012-11-09 23:13:57 +00:00
$so = ORM::factory('Service',$id);
2011-12-16 23:31:35 +00:00
if (! $so->loaded())
2012-11-09 23:13:57 +00:00
HTTP::redirect('welcome/index');
2011-12-16 23:31:35 +00:00
$passwd = $_POST['passwd'];
2012-11-09 23:13:57 +00:00
if (strlen($passwd) < Kohana::$config->load('ssl')->minpass_length) {
2011-12-16 23:31:35 +00:00
SystemMessage::add(array(
2012-08-01 12:43:33 +00:00
'title'=>_('Validation failed'),
2011-12-16 23:31:35 +00:00
'type'=>'error',
'body'=>_('Your requested password is too short.'),
));
HTTP::redirect(URL::link('user','service/view/'.$so->id));
2011-12-16 23:31:35 +00:00
}
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account)) {
2011-12-16 23:31:35 +00:00
$this->template->content = 'Unauthorised or doesnt exist?';
return FALSE;
}
2012-11-09 23:13:57 +00:00
$file = sprintf('%s/%s.pkcs12',Kohana::$config->load('config')->tmpdir,$so->name());
2011-12-16 23:31:35 +00:00
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;
}
}
?>