-
Notifications
You must be signed in to change notification settings - Fork 5
/
action-viewcertificate.inc
54 lines (42 loc) · 2.01 KB
/
action-viewcertificate.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
if (!defined ("LOCAL_SECURITY_KEY"))
die ();
include_once ('include/openvpn-functions.inc');
include_once ('include/openssl-functions.inc');
openvpn_load_server_conf ();
if (!isset ($openvpn['Server'])) html_error ("The OpenVPN server has no configuration file");
openvpn_load_status ();
if (!isset ($openvpn['Server']['Title'])) html_error ("The OpenVPN server has no status file");
openssl_load_database ();
openvpn_find_connected ();
// load Smarty library
require('Smarty.class.php');
$smarty = new Smarty;
// Decoration
$smarty->assign ('Company_Name', $config['Company_Name']);
$smarty->assign ('Company_Logo', $config['Company_Logo']);
$smarty->assign ('URL_Home_Page', $config['URL_Home_Page']);
$smarty->assign ('title', 'OpenVPN Web GUI : OpenSSL certificate');
// Status Bar
$smarty->assign ('Server', $openvpn['Server']);
$smarty->assign ('Seconds_Ago', time () - $openvpn['Server']['Time']);
$smarty->assign ('Certificates', $openssl['Database']);
// Action
$smarty->assign ('action', 'CERTIFICATES');
$smarty->assign ('subaction', 'VIEW');
// Action-Specific
$GETidDEC = $_GET['id'];
$tmpArray = openssl_get_database_contents($GETidDEC);
$tmpArray['ExpDate'] = str_openssldata_to_string ($tmpArray['ExpDate']);
$tmpArray['RevDate'] = str_openssldata_to_string ($tmpArray['RevDate']);
$smarty->assign ('Certificate', $tmpArray);
$smarty->assign ('CertificateFileCRT', openssl_get_filename(str_replace_spaces ($tmpArray['CN']), '.crt'));
$smarty->assign ('CertificateFileKEY', openssl_get_filename(str_replace_spaces ($tmpArray['CN']), '.key'));
$smarty->assign ('CertificateFileCSR', openssl_get_filename(str_replace_spaces ($tmpArray['CN']), '.csr'));
$smarty->assign ('Password', openssl_read_password($GETidDEC, $config['openssl']['passworddb']));
// Display
$smarty->assign ('PluginPath', $config['PluginsAbsolutePath']);
$smarty->assign ('Plugins', $config['Plugins']);
$smarty->assign ('Page', 'action-viewcertificate.tpl');
$smarty->display ('page.tpl');
?>