Project

General

Profile

Download (4.57 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	vpn_openvpn_certs.php
4
	part of pfSense
5

    
6
	Copyright (C) 2008 Ermal Lu?i
7
	All rights reserved.
8

    
9
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11

    
12
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14

    
15
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18

    
19
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30

    
31
require("guiconfig.inc");
32

    
33
$pgtitle = array("OpenVPN", "Certificate management");
34
$ovpncapath = $g['varetc_path']."/openvpn/certificates";
35

    
36
if ($_GET['reset']) {
37
	mwexec("killall -9 openssl");
38
	if (is_dir($_GET['reset']))
39
		mwexec("rm -rf $ovpncapath/".$_GET['reset']);
40
}
41
if ($_GET['delete']) {
42
	if (!is_dir($ovpncapath."/".$_GET['delete'])) 
43
		$input_error[] = "Certificate does not exist!";
44
	else
45
	    mwexec("rm -rf ".$g['varetc_path']."/openvpn/certificates/".$_GET['delete']);
46
	if (is_array($config['openvpn']['keys'])) {
47
		if (is_array($config['openvpn']['keys'][$_GET['delete']])) {
48
			unset($config['openvpn']['keys'][$_GET['delete']]);
49
			if (count($config['openvpn']['keys']) < 1)
50
				unset($config['openvpn']);
51
			write_config();
52
		}
53
	}
54
}
55

    
56
if (!is_array($config['openvpn']['keys']))
57
	$config['openvpn']['keys'] = array();
58
$certificates = &$config['openvpn']['keys'];
59
	
60
include("head.inc");
61
?>
62

    
63
    <body link="#0000CC" vlink="#0000CC" alink="#0000CC">
64
    <?php include("fbegin.inc"); ?>
65
<?php if ($input_errors) print_input_errors($input_errors); ?>
66

    
67
<form action="vpn_openvpn_certs.php" method="post" name="iform" id="iform">
68
<?php if ($savemsg) print_info_box($savemsg); ?>
69

    
70
	  <table width="100%" border="0" cellpadding="6" cellspacing="0" >
71
	  <tr><td>
72
<?php
73
	$tab_array = array();
74
	$tab_array[] = array("Server", false, "/pkg.php?xml=openvpn.xml");
75
	$tab_array[] = array("Client", false, "/pkg.php?xml=openvpn_cli.xml");
76
	$tab_array[] = array("Client-specific overrides", false, "/pkg.php?xml=openvpn_csc.xml");
77
	$tab_array[] = array("Certificate Authority", true, "/vpn_openvpn_certs.php");	
78
	$tab_array[] = array("Users", false, "vpn_openvpn_users.php");
79
	display_top_tabs($tab_array);
80
?>
81
  	</td></tr>
82
	<tr><td>
83
	<table class="tabcont" width="100%" border="0" cellpadding="2" cellspacing="0">
84
	<tr>
85
		<td class="listhdrr" width="35%">Certificates</td>
86
		<td width="60%" class="listhdrr">Expires</td></tr>
87
	 <?php foreach ($certificates as $cert => $ca) { ?>
88
	  				<tr class="vtable">
89
                      <td class="listlr" width="35%">
90
                        <?php
91
                        	if($ca['descr'])
92
								echo $ca['descr'];
93
							else 
94
								echo $cert;
95
                        ?>
96
                        </td>
97
					<td class="listr" width="60%">
98
						<?=$ca['caexpire'];?>
99
					</td>
100
					<td><a href="
101
<?php
102
				 if ($ca['existing'] == "yes")
103
					echo "vpn_openvpn_certs_existing.php?ca=$cert";
104
				   else
105
					echo "vpn_openvpn_certs_create.php?ca=$cert";
106
?>
107
	"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit rule" width="17" height="17" border="0"></a></td>
108
					<td><a href="vpn_openvpn_certs.php?delete=<?=$cert;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="<?=gettext("delete certificate");?>" width="17" height="17" border="0" alt="" /></a></td>
109
                    </tr>
110
 	<?php } ?>
111
				<tr><td colspan="2"></td><td><a href="vpn_openvpn_certs_create.php?add=true"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="<?=gettext("add a new certificate");?>" width="17" height="17" border="0" alt="" /></a></td></tr>
112
		<tr>
113
		<td colspan="2" >To import existing certificates please <a href="vpn_openvpn_certs_existing.php">
114
			click this link.</a>
115
		</td></tr>
116
	</table>
117
	</td></tr>
118
	</table>
119
    <?php include("fend.inc"); ?>
120
</body>
121
</html>
122

    
123

    
(197-197/214)