import_users: generate client certificate

This commit is contained in:
Li Chen 2013-11-12 22:41:10 +01:00
parent ecd35df7af
commit c78d379527
2 changed files with 32 additions and 17 deletions

View file

@ -2,23 +2,6 @@
if (!defined('ONYX')) exit; if (!defined('ONYX')) exit;
if (isset($_GET['newca']))
{
//TODO handle if already exist
putenv("OPENSSL_CONF=".ONYX. '../misc/openssl.cnf');
putenv("TOP_DIR=".ONYX. '../misc/fic_pki');
$output = shell_exec(ONYX . '../misc/CA.sh -newca');
//TODO handle the path ?
$ca_file = ONYX . '../misc/fic_pki/cacert.crt';
//TODO check permission ?
if (file_exists($ca_file))
{
$data = openssl_x509_parse(file_get_contents(ONYX . '../misc/fic_pki/cacert.crt'));
$template->assign("cert", $data);
}
}
function remove_directory($dir) function remove_directory($dir)
{ {
if (is_dir($dir)) if (is_dir($dir))
@ -39,6 +22,31 @@ function remove_directory($dir)
} }
} }
function new_client($name)
{
//TODO handle if already exist
putenv("OPENSSL_CONF=".ONYX. '../misc/openssl.cnf');
putenv("TOP_DIR=".ONYX. '../misc/fic_pki');
$output = shell_exec(ONYX . "../misc/CA.sh -newclient $name");
}
if (isset($_GET['newca']))
{
//TODO handle if already exist
putenv("OPENSSL_CONF=".ONYX. '../misc/openssl.cnf');
putenv("TOP_DIR=".ONYX. '../misc/fic_pki');
$output = shell_exec(ONYX . '../misc/CA.sh -newca');
//TODO handle the path ?
$ca_file = ONYX . '../misc/fic_pki/cacert.crt';
//TODO check permission ?
if (file_exists($ca_file))
{
$data = openssl_x509_parse(file_get_contents(ONYX . '../misc/fic_pki/cacert.crt'));
$template->assign("cert", $data);
}
}
if (isset($_GET['deleteca'])) if (isset($_GET['deleteca']))
{ {
//TODO handle var path //TODO handle var path

View file

@ -2,6 +2,8 @@
if(!defined('ONYX')) exit; if(!defined('ONYX')) exit;
include 'certificate.php';
if (!empty($_FILES["inputFile"]['tmp_name'])) if (!empty($_FILES["inputFile"]['tmp_name']))
{ {
//TODO use a variable to define the path //TODO use a variable to define the path
@ -60,6 +62,11 @@ if (!empty($_FILES["inputFile"]['tmp_name']))
$team->members[] = $user; $team->members[] = $user;
} }
} }
if (!empty($team->team_name))
{
//TODO save the certificate subject
new_client($team->team_name);
}
} }
} }
erreur("Fichier XML importé avec succès.", "success"); erreur("Fichier XML importé avec succès.", "success");