1 |
64cc39d3
|
Matthew Grooms
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
system_camanager.php
|
4 |
|
|
|
5 |
|
|
Copyright (C) 2008 Shrew Soft Inc.
|
6 |
|
|
All rights reserved.
|
7 |
|
|
|
8 |
|
|
Redistribution and use in source and binary forms, with or without
|
9 |
|
|
modification, are permitted provided that the following conditions are met:
|
10 |
|
|
|
11 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
12 |
|
|
this list of conditions and the following disclaimer.
|
13 |
|
|
|
14 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
15 |
|
|
notice, this list of conditions and the following disclaimer in the
|
16 |
|
|
documentation and/or other materials provided with the distribution.
|
17 |
|
|
|
18 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
19 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
20 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
21 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
22 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
23 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
24 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
25 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
26 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
28 |
|
|
*/
|
29 |
1d333258
|
Scott Ullrich
|
/*
|
30 |
|
|
pfSense_MODULE: certificate_managaer
|
31 |
|
|
*/
|
32 |
64cc39d3
|
Matthew Grooms
|
|
33 |
|
|
##|+PRIV
|
34 |
|
|
##|*IDENT=page-system-camanager
|
35 |
|
|
##|*NAME=System: CA Manager
|
36 |
|
|
##|*DESCR=Allow access to the 'System: CA Manager' page.
|
37 |
|
|
##|*MATCH=system_camanager.php*
|
38 |
|
|
##|-PRIV
|
39 |
|
|
|
40 |
|
|
require("guiconfig.inc");
|
41 |
742d9c2d
|
Ermal Lu?i
|
require_once("certs.inc");
|
42 |
64cc39d3
|
Matthew Grooms
|
|
43 |
|
|
$ca_methods = array(
|
44 |
a37753d7
|
Vinicius Coque
|
"existing" => gettext("Import an existing Certificate Authority"),
|
45 |
95c8cf48
|
Evgeny Yurchenko
|
"internal" => gettext("Create an internal Certificate Authority"),
|
46 |
|
|
"intermediate" => gettext("Create an intermediate Certificate Authority"));
|
47 |
64cc39d3
|
Matthew Grooms
|
|
48 |
|
|
$ca_keylens = array( "512", "1024", "2048", "4096");
|
49 |
|
|
|
50 |
a37753d7
|
Vinicius Coque
|
$pgtitle = array(gettext("System"), gettext("Certificate Authority Manager"));
|
51 |
64cc39d3
|
Matthew Grooms
|
|
52 |
|
|
$id = $_GET['id'];
|
53 |
|
|
if (isset($_POST['id']))
|
54 |
|
|
$id = $_POST['id'];
|
55 |
|
|
|
56 |
b4e6524c
|
jim-p
|
if (!is_array($config['ca']))
|
57 |
|
|
$config['ca'] = array();
|
58 |
64cc39d3
|
Matthew Grooms
|
|
59 |
b4e6524c
|
jim-p
|
$a_ca =& $config['ca'];
|
60 |
64cc39d3
|
Matthew Grooms
|
|
61 |
b4e6524c
|
jim-p
|
if (!is_array($config['cert']))
|
62 |
|
|
$config['cert'] = array();
|
63 |
64cc39d3
|
Matthew Grooms
|
|
64 |
b4e6524c
|
jim-p
|
$a_cert =& $config['cert'];
|
65 |
64cc39d3
|
Matthew Grooms
|
|
66 |
461aa9d0
|
jim-p
|
if (!is_array($config['crl']))
|
67 |
|
|
$config['crl'] = array();
|
68 |
|
|
|
69 |
|
|
$a_crl =& $config['crl'];
|
70 |
|
|
|
71 |
64cc39d3
|
Matthew Grooms
|
$act = $_GET['act'];
|
72 |
|
|
if ($_POST['act'])
|
73 |
|
|
$act = $_POST['act'];
|
74 |
|
|
|
75 |
|
|
if ($act == "del") {
|
76 |
|
|
|
77 |
|
|
if (!$a_ca[$id]) {
|
78 |
|
|
pfSenseHeader("system_camanager.php");
|
79 |
|
|
exit;
|
80 |
|
|
}
|
81 |
|
|
|
82 |
|
|
$index = count($a_cert) - 1;
|
83 |
|
|
for (;$index >=0; $index--)
|
84 |
|
|
if ($a_cert[$index]['caref'] == $a_ca[$id]['refid'])
|
85 |
|
|
unset($a_cert[$index]);
|
86 |
|
|
|
87 |
461aa9d0
|
jim-p
|
$index = count($a_crl) - 1;
|
88 |
|
|
for (;$index >=0; $index--)
|
89 |
|
|
if ($a_crl[$index]['caref'] == $a_ca[$id]['refid'])
|
90 |
|
|
unset($a_crl[$index]);
|
91 |
|
|
|
92 |
f2a86ca9
|
jim-p
|
$name = $a_ca[$id]['descr'];
|
93 |
64cc39d3
|
Matthew Grooms
|
unset($a_ca[$id]);
|
94 |
|
|
write_config();
|
95 |
461aa9d0
|
jim-p
|
$savemsg = sprintf(gettext("Certificate Authority %s and its CRLs (if any) successfully deleted"), $name) . "<br/>";
|
96 |
2f51259b
|
jim-p
|
pfSenseHeader("system_camanager.php");
|
97 |
|
|
exit;
|
98 |
64cc39d3
|
Matthew Grooms
|
}
|
99 |
|
|
|
100 |
bfa992bc
|
jim-p
|
if ($act == "edit") {
|
101 |
|
|
if (!$a_ca[$id]) {
|
102 |
|
|
pfSenseHeader("system_camanager.php");
|
103 |
|
|
exit;
|
104 |
|
|
}
|
105 |
|
|
$pconfig['descr'] = $a_ca[$id]['descr'];
|
106 |
|
|
$pconfig['refid'] = $a_ca[$id]['refid'];
|
107 |
|
|
$pconfig['cert'] = base64_decode($a_ca[$id]['crt']);
|
108 |
|
|
$pconfig['serial'] = $a_ca[$id]['serial'];
|
109 |
|
|
if (!empty($a_ca[$id]['prv']))
|
110 |
|
|
$pconfig['key'] = base64_decode($a_ca[$id]['prv']);
|
111 |
|
|
}
|
112 |
|
|
|
113 |
64cc39d3
|
Matthew Grooms
|
if ($act == "new") {
|
114 |
|
|
$pconfig['method'] = $_GET['method'];
|
115 |
|
|
$pconfig['keylen'] = "2048";
|
116 |
cf360495
|
Chris Buechler
|
$pconfig['lifetime'] = "3650";
|
117 |
64cc39d3
|
Matthew Grooms
|
$pconfig['dn_commonname'] = "internal-ca";
|
118 |
|
|
}
|
119 |
|
|
|
120 |
93823b10
|
Matthew Grooms
|
if ($act == "exp") {
|
121 |
|
|
|
122 |
|
|
if (!$a_ca[$id]) {
|
123 |
|
|
pfSenseHeader("system_camanager.php");
|
124 |
|
|
exit;
|
125 |
|
|
}
|
126 |
|
|
|
127 |
f2a86ca9
|
jim-p
|
$exp_name = urlencode("{$a_ca[$id]['descr']}.crt");
|
128 |
93823b10
|
Matthew Grooms
|
$exp_data = base64_decode($a_ca[$id]['crt']);
|
129 |
|
|
$exp_size = strlen($exp_data);
|
130 |
|
|
|
131 |
|
|
header("Content-Type: application/octet-stream");
|
132 |
|
|
header("Content-Disposition: attachment; filename={$exp_name}");
|
133 |
|
|
header("Content-Length: $exp_size");
|
134 |
|
|
echo $exp_data;
|
135 |
|
|
exit;
|
136 |
|
|
}
|
137 |
|
|
|
138 |
ecefc738
|
jim-p
|
if ($act == "expkey") {
|
139 |
|
|
|
140 |
|
|
if (!$a_ca[$id]) {
|
141 |
|
|
pfSenseHeader("system_camanager.php");
|
142 |
|
|
exit;
|
143 |
|
|
}
|
144 |
|
|
|
145 |
f2a86ca9
|
jim-p
|
$exp_name = urlencode("{$a_ca[$id]['descr']}.key");
|
146 |
ecefc738
|
jim-p
|
$exp_data = base64_decode($a_ca[$id]['prv']);
|
147 |
|
|
$exp_size = strlen($exp_data);
|
148 |
|
|
|
149 |
|
|
header("Content-Type: application/octet-stream");
|
150 |
|
|
header("Content-Disposition: attachment; filename={$exp_name}");
|
151 |
|
|
header("Content-Length: $exp_size");
|
152 |
|
|
echo $exp_data;
|
153 |
|
|
exit;
|
154 |
|
|
}
|
155 |
|
|
|
156 |
64cc39d3
|
Matthew Grooms
|
if ($_POST) {
|
157 |
|
|
|
158 |
95c8cf48
|
Evgeny Yurchenko
|
unset($input_errors);
|
159 |
64cc39d3
|
Matthew Grooms
|
$pconfig = $_POST;
|
160 |
|
|
|
161 |
|
|
/* input validation */
|
162 |
|
|
if ($pconfig['method'] == "existing") {
|
163 |
5293bfec
|
jim-p
|
$reqdfields = explode(" ", "descr cert");
|
164 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = array(
|
165 |
|
|
gettext("Descriptive name"),
|
166 |
|
|
gettext("Certificate data"));
|
167 |
396cfe2e
|
jim-p
|
if ($_POST['cert'] && (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE")))
|
168 |
|
|
$input_errors[] = gettext("This certificate does not appear to be valid.");
|
169 |
46698c3f
|
jim-p
|
if ($_POST['key'] && strstr($_POST['key'], "ENCRYPTED"))
|
170 |
|
|
$input_errors[] = gettext("Encrypted private keys are not yet supported.");
|
171 |
64cc39d3
|
Matthew Grooms
|
}
|
172 |
|
|
if ($pconfig['method'] == "internal") {
|
173 |
|
|
$reqdfields = explode(" ",
|
174 |
5293bfec
|
jim-p
|
"descr keylen lifetime dn_country dn_state dn_city ".
|
175 |
64cc39d3
|
Matthew Grooms
|
"dn_organization dn_email dn_commonname");
|
176 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = array(
|
177 |
|
|
gettext("Descriptive name"),
|
178 |
|
|
gettext("Key length"),
|
179 |
|
|
gettext("Lifetime"),
|
180 |
|
|
gettext("Distinguished name Country Code"),
|
181 |
|
|
gettext("Distinguished name State or Province"),
|
182 |
|
|
gettext("Distinguished name City"),
|
183 |
|
|
gettext("Distinguished name Organization"),
|
184 |
|
|
gettext("Distinguished name Email Address"),
|
185 |
a37753d7
|
Vinicius Coque
|
gettext("Distinguished name Common Name"));
|
186 |
64cc39d3
|
Matthew Grooms
|
}
|
187 |
95c8cf48
|
Evgeny Yurchenko
|
if ($pconfig['method'] == "intermediate") {
|
188 |
|
|
$reqdfields = explode(" ",
|
189 |
|
|
"descr caref keylen lifetime dn_country dn_state dn_city ".
|
190 |
|
|
"dn_organization dn_email dn_commonname");
|
191 |
|
|
$reqdfieldsn = array(
|
192 |
|
|
gettext("Descriptive name"),
|
193 |
|
|
gettext("Signing Certificate Authority"),
|
194 |
|
|
gettext("Key length"),
|
195 |
|
|
gettext("Lifetime"),
|
196 |
|
|
gettext("Distinguished name Country Code"),
|
197 |
|
|
gettext("Distinguished name State or Province"),
|
198 |
|
|
gettext("Distinguished name City"),
|
199 |
|
|
gettext("Distinguished name Organization"),
|
200 |
|
|
gettext("Distinguished name Email Address"),
|
201 |
|
|
gettext("Distinguished name Common Name"));
|
202 |
|
|
}
|
203 |
64cc39d3
|
Matthew Grooms
|
|
204 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
205 |
21cc2faa
|
Evgeny Yurchenko
|
if ($pconfig['method'] != "existing")
|
206 |
|
|
/* Make sure we do not have invalid characters in the fields for the certificate */
|
207 |
|
|
for ($i = 0; $i < count($reqdfields); $i++) {
|
208 |
|
|
if ($reqdfields[$i] == 'dn_email'){
|
209 |
|
|
if (preg_match("/[\!\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST["dn_email"]))
|
210 |
|
|
array_push($input_errors, "The field 'Distinguished name Email Address' contains invalid characters.");
|
211 |
|
|
}else if ($reqdfields[$i] == 'dn_commonname'){
|
212 |
|
|
if (preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST["dn_commonname"]))
|
213 |
|
|
array_push($input_errors, "The field 'Distinguished name Common Name' contains invalid characters.");
|
214 |
|
|
}else if (preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\.\"\']/", $_POST["$reqdfields[$i]"]))
|
215 |
|
|
array_push($input_errors, "The field '" . $reqdfieldsn[$i] . "' contains invalid characters.");
|
216 |
|
|
}
|
217 |
64cc39d3
|
Matthew Grooms
|
|
218 |
|
|
/* if this is an AJAX caller then handle via JSON */
|
219 |
|
|
if (isAjax() && is_array($input_errors)) {
|
220 |
|
|
input_errors2Ajax($input_errors);
|
221 |
|
|
exit;
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
/* save modifications */
|
225 |
|
|
if (!$input_errors) {
|
226 |
|
|
|
227 |
|
|
$ca = array();
|
228 |
bfa992bc
|
jim-p
|
if (!isset($pconfig['refid']) || empty($pconfig['refid']))
|
229 |
|
|
$ca['refid'] = uniqid();
|
230 |
|
|
else
|
231 |
|
|
$ca['refid'] = $pconfig['refid'];
|
232 |
|
|
|
233 |
64cc39d3
|
Matthew Grooms
|
if (isset($id) && $a_ca[$id])
|
234 |
|
|
$ca = $a_ca[$id];
|
235 |
|
|
|
236 |
bfa992bc
|
jim-p
|
$ca['descr'] = $pconfig['descr'];
|
237 |
|
|
|
238 |
|
|
if ($_POST['edit'] == "edit") {
|
239 |
|
|
$ca['descr'] = $pconfig['descr'];
|
240 |
|
|
$ca['refid'] = $pconfig['refid'];
|
241 |
|
|
$ca['serial'] = $pconfig['serial'];
|
242 |
|
|
$ca['crt'] = base64_encode($pconfig['cert']);
|
243 |
|
|
if (!empty($pconfig['key']))
|
244 |
|
|
$ca['prv'] = base64_encode($pconfig['key']);
|
245 |
|
|
} else {
|
246 |
1b6d9fa5
|
Evgeny Yurchenko
|
$old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warings directly to a page screwing menu tab */
|
247 |
bfa992bc
|
jim-p
|
if ($pconfig['method'] == "existing")
|
248 |
|
|
ca_import($ca, $pconfig['cert'], $pconfig['key'], $pconfig['serial']);
|
249 |
|
|
|
250 |
95c8cf48
|
Evgeny Yurchenko
|
else if ($pconfig['method'] == "internal") {
|
251 |
bfa992bc
|
jim-p
|
$dn = array(
|
252 |
|
|
'countryName' => $pconfig['dn_country'],
|
253 |
|
|
'stateOrProvinceName' => $pconfig['dn_state'],
|
254 |
|
|
'localityName' => $pconfig['dn_city'],
|
255 |
|
|
'organizationName' => $pconfig['dn_organization'],
|
256 |
|
|
'emailAddress' => $pconfig['dn_email'],
|
257 |
|
|
'commonName' => $pconfig['dn_commonname']);
|
258 |
1b6d9fa5
|
Evgeny Yurchenko
|
if (!ca_create($ca, $pconfig['keylen'], $pconfig['lifetime'], $dn)){
|
259 |
|
|
while($ssl_err = openssl_error_string()){
|
260 |
|
|
$input_errors = array();
|
261 |
|
|
array_push($input_errors, "openssl library returns: " . $ssl_err);
|
262 |
|
|
}
|
263 |
|
|
}
|
264 |
bfa992bc
|
jim-p
|
}
|
265 |
95c8cf48
|
Evgeny Yurchenko
|
else if ($pconfig['method'] == "intermediate") {
|
266 |
|
|
$dn = array(
|
267 |
|
|
'countryName' => $pconfig['dn_country'],
|
268 |
|
|
'stateOrProvinceName' => $pconfig['dn_state'],
|
269 |
|
|
'localityName' => $pconfig['dn_city'],
|
270 |
|
|
'organizationName' => $pconfig['dn_organization'],
|
271 |
|
|
'emailAddress' => $pconfig['dn_email'],
|
272 |
|
|
'commonName' => $pconfig['dn_commonname']);
|
273 |
|
|
if (!ca_inter_create($ca, $pconfig['keylen'], $pconfig['lifetime'], $dn, $pconfig['caref'])){
|
274 |
|
|
while($ssl_err = openssl_error_string()){
|
275 |
|
|
$input_errors = array();
|
276 |
|
|
array_push($input_errors, "openssl library returns: " . $ssl_err);
|
277 |
|
|
}
|
278 |
|
|
}
|
279 |
|
|
}
|
280 |
1b6d9fa5
|
Evgeny Yurchenko
|
error_reporting($old_err_level);
|
281 |
64cc39d3
|
Matthew Grooms
|
}
|
282 |
|
|
|
283 |
|
|
if (isset($id) && $a_ca[$id])
|
284 |
|
|
$a_ca[$id] = $ca;
|
285 |
|
|
else
|
286 |
|
|
$a_ca[] = $ca;
|
287 |
|
|
|
288 |
95c8cf48
|
Evgeny Yurchenko
|
if (!$input_errors)
|
289 |
|
|
write_config();
|
290 |
64cc39d3
|
Matthew Grooms
|
|
291 |
|
|
// pfSenseHeader("system_camanager.php");
|
292 |
|
|
}
|
293 |
|
|
}
|
294 |
|
|
|
295 |
|
|
include("head.inc");
|
296 |
|
|
?>
|
297 |
|
|
|
298 |
|
|
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
|
299 |
|
|
<?php include("fbegin.inc"); ?>
|
300 |
|
|
<script type="text/javascript">
|
301 |
|
|
<!--
|
302 |
|
|
|
303 |
|
|
function method_change() {
|
304 |
|
|
|
305 |
|
|
method = document.iform.method.selectedIndex;
|
306 |
|
|
|
307 |
|
|
switch (method) {
|
308 |
|
|
case 0:
|
309 |
|
|
document.getElementById("existing").style.display="";
|
310 |
|
|
document.getElementById("internal").style.display="none";
|
311 |
95c8cf48
|
Evgeny Yurchenko
|
document.getElementById("intermediate").style.display="none";
|
312 |
64cc39d3
|
Matthew Grooms
|
break;
|
313 |
|
|
case 1:
|
314 |
|
|
document.getElementById("existing").style.display="none";
|
315 |
|
|
document.getElementById("internal").style.display="";
|
316 |
95c8cf48
|
Evgeny Yurchenko
|
document.getElementById("intermediate").style.display="none";
|
317 |
|
|
break;
|
318 |
|
|
case 2:
|
319 |
|
|
document.getElementById("existing").style.display="none";
|
320 |
|
|
document.getElementById("internal").style.display="";
|
321 |
|
|
document.getElementById("intermediate").style.display="";
|
322 |
64cc39d3
|
Matthew Grooms
|
break;
|
323 |
|
|
}
|
324 |
|
|
}
|
325 |
|
|
|
326 |
|
|
//-->
|
327 |
|
|
</script>
|
328 |
|
|
<?php
|
329 |
|
|
if ($input_errors)
|
330 |
|
|
print_input_errors($input_errors);
|
331 |
|
|
if ($savemsg)
|
332 |
|
|
print_info_box($savemsg);
|
333 |
9d2d65f3
|
Evgeny Yurchenko
|
|
334 |
|
|
// Load valid country codes
|
335 |
|
|
$dn_cc = array();
|
336 |
|
|
if (file_exists("/etc/ca_countries")){
|
337 |
|
|
$dn_cc_file=file("/etc/ca_countries");
|
338 |
|
|
foreach($dn_cc_file as $line)
|
339 |
|
|
if (preg_match('/^(\S*)\s(.*)$/', $line, $matches))
|
340 |
|
|
array_push($dn_cc, $matches[1]);
|
341 |
|
|
}
|
342 |
64cc39d3
|
Matthew Grooms
|
?>
|
343 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
344 |
|
|
<tr>
|
345 |
96c7a492
|
Matthew Grooms
|
<td>
|
346 |
64cc39d3
|
Matthew Grooms
|
<?php
|
347 |
|
|
$tab_array = array();
|
348 |
|
|
$tab_array[] = array(gettext("CAs"), true, "system_camanager.php");
|
349 |
|
|
$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php");
|
350 |
3d57d2d5
|
jim-p
|
$tab_array[] = array(gettext("Certificate Revocation"), false, "system_crlmanager.php");
|
351 |
64cc39d3
|
Matthew Grooms
|
display_top_tabs($tab_array);
|
352 |
|
|
?>
|
353 |
|
|
</td>
|
354 |
|
|
</tr>
|
355 |
|
|
<tr>
|
356 |
96c7a492
|
Matthew Grooms
|
<td id="mainarea">
|
357 |
|
|
<div class="tabcont">
|
358 |
|
|
|
359 |
bfa992bc
|
jim-p
|
<?php if ($act == "new" || $act == "edit" || $act == gettext("Save") || $input_errors): ?>
|
360 |
96c7a492
|
Matthew Grooms
|
|
361 |
|
|
<form action="system_camanager.php" method="post" name="iform" id="iform">
|
362 |
bfa992bc
|
jim-p
|
<?php if ($act == "edit"): ?>
|
363 |
|
|
<input type="hidden" name="edit" value="edit" id="edit">
|
364 |
|
|
<input type="hidden" name="id" value="<?php echo $id; ?>" id="id">
|
365 |
|
|
<input type="hidden" name="refid" value="<?php echo $pconfig['refid']; ?>" id="refid">
|
366 |
|
|
<?php endif; ?>
|
367 |
96c7a492
|
Matthew Grooms
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
368 |
|
|
<tr>
|
369 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
|
370 |
|
|
<td width="78%" class="vtable">
|
371 |
f2a86ca9
|
jim-p
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
|
372 |
96c7a492
|
Matthew Grooms
|
</td>
|
373 |
|
|
</tr>
|
374 |
bfa992bc
|
jim-p
|
<?php if (!isset($id) || $act == "edit"): ?>
|
375 |
96c7a492
|
Matthew Grooms
|
<tr>
|
376 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
|
377 |
|
|
<td width="78%" class="vtable">
|
378 |
|
|
<select name='method' id='method' class="formselect" onchange='method_change()'>
|
379 |
|
|
<?php
|
380 |
|
|
foreach($ca_methods as $method => $desc):
|
381 |
|
|
$selected = "";
|
382 |
|
|
if ($pconfig['method'] == $method)
|
383 |
|
|
$selected = "selected";
|
384 |
|
|
?>
|
385 |
|
|
<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option>
|
386 |
|
|
<?php endforeach; ?>
|
387 |
|
|
</select>
|
388 |
|
|
</td>
|
389 |
|
|
</tr>
|
390 |
|
|
<?php endif; ?>
|
391 |
|
|
</table>
|
392 |
|
|
|
393 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing">
|
394 |
|
|
<tr>
|
395 |
|
|
<td colspan="2" class="list" height="12"></td>
|
396 |
|
|
</tr>
|
397 |
|
|
<tr>
|
398 |
a37753d7
|
Vinicius Coque
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Existing Certificate Authority");?></td>
|
399 |
96c7a492
|
Matthew Grooms
|
</tr>
|
400 |
|
|
|
401 |
|
|
<tr>
|
402 |
a37753d7
|
Vinicius Coque
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td>
|
403 |
96c7a492
|
Matthew Grooms
|
<td width="78%" class="vtable">
|
404 |
dd5bf424
|
Scott Ullrich
|
<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea>
|
405 |
96c7a492
|
Matthew Grooms
|
<br>
|
406 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Paste a certificate in X.509 PEM format here.");?></td>
|
407 |
96c7a492
|
Matthew Grooms
|
</td>
|
408 |
|
|
</tr>
|
409 |
ecefc738
|
jim-p
|
<tr>
|
410 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate Private Key");?><br/><?=gettext("(optional)");?></td>
|
411 |
|
|
<td width="78%" class="vtable">
|
412 |
dd5bf424
|
Scott Ullrich
|
<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['key']);?></textarea>
|
413 |
ecefc738
|
jim-p
|
<br>
|
414 |
|
|
<?=gettext("Paste the private key for the above certificate here. This is optional in most cases, but required if you need to generate a Certificate Revocation List (CRL).");?></td>
|
415 |
|
|
</td>
|
416 |
|
|
</tr>
|
417 |
bfa992bc
|
jim-p
|
|
418 |
|
|
<?php if (!isset($id) || $act == "edit"): ?>
|
419 |
|
|
<tr>
|
420 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Serial");?></td>
|
421 |
|
|
<td width="78%" class="vtable">
|
422 |
|
|
<input name="serial" type="text" class="formfld unknown" id="serial" size="20" value="<?=htmlspecialchars($pconfig['serial']);?>"/>
|
423 |
|
|
</td>
|
424 |
|
|
</tr>
|
425 |
|
|
<?php endif; ?>
|
426 |
96c7a492
|
Matthew Grooms
|
</table>
|
427 |
|
|
|
428 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal">
|
429 |
|
|
<tr>
|
430 |
|
|
<td colspan="2" class="list" height="12"></td>
|
431 |
|
|
</tr>
|
432 |
|
|
<tr>
|
433 |
a37753d7
|
Vinicius Coque
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate Authority");?></td>
|
434 |
96c7a492
|
Matthew Grooms
|
</tr>
|
435 |
95c8cf48
|
Evgeny Yurchenko
|
<tr id='intermediate'>
|
436 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Signing Certificate Authority");?></td>
|
437 |
|
|
<td width="78%" class="vtable">
|
438 |
|
|
<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
|
439 |
|
|
<?php
|
440 |
|
|
foreach( $a_ca as $ca):
|
441 |
|
|
if (!$ca['prv'])
|
442 |
|
|
continue;
|
443 |
|
|
$selected = "";
|
444 |
|
|
if ($pconfig['caref'] == $ca['refid'])
|
445 |
|
|
$selected = "selected";
|
446 |
|
|
?>
|
447 |
|
|
<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['descr'];?></option>
|
448 |
|
|
<?php endforeach; ?>
|
449 |
|
|
</select>
|
450 |
|
|
</td>
|
451 |
|
|
</tr>
|
452 |
96c7a492
|
Matthew Grooms
|
<tr>
|
453 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
|
454 |
|
|
<td width="78%" class="vtable">
|
455 |
|
|
<select name='keylen' id='keylen' class="formselect">
|
456 |
|
|
<?php
|
457 |
|
|
foreach( $ca_keylens as $len):
|
458 |
|
|
$selected = "";
|
459 |
|
|
if ($pconfig['keylen'] == $len)
|
460 |
|
|
$selected = "selected";
|
461 |
|
|
?>
|
462 |
|
|
<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
|
463 |
|
|
<?php endforeach; ?>
|
464 |
|
|
</select>
|
465 |
ea53e38f
|
Renato Botelho
|
<?=gettext("bits");?>
|
466 |
96c7a492
|
Matthew Grooms
|
</td>
|
467 |
|
|
</tr>
|
468 |
|
|
<tr>
|
469 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
|
470 |
|
|
<td width="78%" class="vtable">
|
471 |
|
|
<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
|
472 |
ea53e38f
|
Renato Botelho
|
<?=gettext("days");?>
|
473 |
96c7a492
|
Matthew Grooms
|
</td>
|
474 |
|
|
</tr>
|
475 |
|
|
<tr>
|
476 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
|
477 |
|
|
<td width="78%" class="vtable">
|
478 |
|
|
<table border="0" cellspacing="0" cellpadding="2">
|
479 |
|
|
<tr>
|
480 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Country Code");?> : </td>
|
481 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
482 |
9d2d65f3
|
Evgeny Yurchenko
|
<select name='dn_country' class="formselect">
|
483 |
|
|
<?php
|
484 |
|
|
foreach( $dn_cc as $cc){
|
485 |
|
|
$selected = "";
|
486 |
|
|
if ($pconfig['dn_country'] == $cc) $selected = "selected";
|
487 |
|
|
print "<option value=\"$cc\" $selected>$cc</option>";
|
488 |
|
|
}
|
489 |
|
|
?>
|
490 |
|
|
</select>
|
491 |
96c7a492
|
Matthew Grooms
|
</td>
|
492 |
|
|
</tr>
|
493 |
|
|
<tr>
|
494 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("State or Province");?> : </td>
|
495 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
496 |
|
|
<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>"/>
|
497 |
|
|
|
498 |
ea53e38f
|
Renato Botelho
|
<em><?=gettext("ex:");?></em>
|
499 |
96c7a492
|
Matthew Grooms
|
|
500 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Texas");?>
|
501 |
96c7a492
|
Matthew Grooms
|
</td>
|
502 |
|
|
</tr>
|
503 |
|
|
<tr>
|
504 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("City");?> : </td>
|
505 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
506 |
|
|
<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>"/>
|
507 |
|
|
|
508 |
ea53e38f
|
Renato Botelho
|
<em><?=gettext("ex:");?></em>
|
509 |
96c7a492
|
Matthew Grooms
|
|
510 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Austin");?>
|
511 |
96c7a492
|
Matthew Grooms
|
</td>
|
512 |
|
|
</tr>
|
513 |
|
|
<tr>
|
514 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Organization");?> : </td>
|
515 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
516 |
|
|
<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>"/>
|
517 |
|
|
|
518 |
ea53e38f
|
Renato Botelho
|
<em><?=gettext("ex:");?></em>
|
519 |
96c7a492
|
Matthew Grooms
|
|
520 |
a37753d7
|
Vinicius Coque
|
<?=gettext("My Company Inc.");?>
|
521 |
96c7a492
|
Matthew Grooms
|
</td>
|
522 |
|
|
</tr>
|
523 |
|
|
<tr>
|
524 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Email Address");?> : </td>
|
525 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
526 |
|
|
<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/>
|
527 |
|
|
|
528 |
ea53e38f
|
Renato Botelho
|
<em><?=gettext("ex:");?></em>
|
529 |
96c7a492
|
Matthew Grooms
|
|
530 |
a37753d7
|
Vinicius Coque
|
<?=gettext("admin@mycompany.com");?>
|
531 |
96c7a492
|
Matthew Grooms
|
</td>
|
532 |
|
|
</tr>
|
533 |
|
|
<tr>
|
534 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Common Name");?> : </td>
|
535 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
536 |
|
|
<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/>
|
537 |
|
|
|
538 |
ea53e38f
|
Renato Botelho
|
<em><?=gettext("ex:");?></em>
|
539 |
96c7a492
|
Matthew Grooms
|
|
540 |
a37753d7
|
Vinicius Coque
|
<?=gettext("internal-ca");?>
|
541 |
96c7a492
|
Matthew Grooms
|
</td>
|
542 |
|
|
</tr>
|
543 |
|
|
</table>
|
544 |
|
|
</td>
|
545 |
|
|
</tr>
|
546 |
|
|
</table>
|
547 |
|
|
|
548 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
549 |
|
|
<tr>
|
550 |
|
|
<td width="22%" valign="top"> </td>
|
551 |
|
|
<td width="78%">
|
552 |
443ddf6f
|
Carlos Eduardo Ramos
|
<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
|
553 |
96c7a492
|
Matthew Grooms
|
<?php if (isset($id) && $a_ca[$id]): ?>
|
554 |
|
|
<input name="id" type="hidden" value="<?=$id;?>" />
|
555 |
|
|
<?php endif;?>
|
556 |
|
|
</td>
|
557 |
|
|
</tr>
|
558 |
|
|
</table>
|
559 |
|
|
</form>
|
560 |
|
|
|
561 |
|
|
<?php else: ?>
|
562 |
|
|
|
563 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
564 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
565 |
a37753d7
|
Vinicius Coque
|
<td width="20%" class="listhdrr"><?=gettext("Name");?></td>
|
566 |
|
|
<td width="10%" class="listhdrr"><?=gettext("Internal");?></td>
|
567 |
|
|
<td width="10%" class="listhdrr"><?=gettext("Issuer");?></td>
|
568 |
|
|
<td width="10%" class="listhdrr"><?=gettext("Certificates");?></td>
|
569 |
|
|
<td width="40%" class="listhdrr"><?=gettext("Distinguished Name");?></td>
|
570 |
96c7a492
|
Matthew Grooms
|
<td width="10%" class="list"></td>
|
571 |
64cc39d3
|
Matthew Grooms
|
</tr>
|
572 |
96c7a492
|
Matthew Grooms
|
<?php
|
573 |
|
|
$i = 0;
|
574 |
|
|
foreach($a_ca as $ca):
|
575 |
f2a86ca9
|
jim-p
|
$name = htmlspecialchars($ca['descr']);
|
576 |
96c7a492
|
Matthew Grooms
|
$subj = cert_get_subject($ca['crt']);
|
577 |
2cf6ddcb
|
Nigel Graham
|
$issuer = cert_get_issuer($ca['crt']);
|
578 |
|
|
if($subj == $issuer)
|
579 |
a37753d7
|
Vinicius Coque
|
$issuer_name = "<em>" . gettext("self-signed") . "</em>";
|
580 |
2cf6ddcb
|
Nigel Graham
|
else
|
581 |
a37753d7
|
Vinicius Coque
|
$issuer_name = "<em>" . gettext("external") . "</em>";
|
582 |
96c7a492
|
Matthew Grooms
|
$subj = htmlspecialchars($subj);
|
583 |
2cf6ddcb
|
Nigel Graham
|
$issuer = htmlspecialchars($issuer);
|
584 |
96c7a492
|
Matthew Grooms
|
$certcount = 0;
|
585 |
|
|
|
586 |
2cf6ddcb
|
Nigel Graham
|
$issuer_ca = lookup_ca($ca['caref']);
|
587 |
|
|
if ($issuer_ca)
|
588 |
f2a86ca9
|
jim-p
|
$issuer_name = $issuer_ca['descr'];
|
589 |
2cf6ddcb
|
Nigel Graham
|
|
590 |
96c7a492
|
Matthew Grooms
|
// TODO : Need gray certificate icon
|
591 |
|
|
|
592 |
|
|
if($ca['prv']) {
|
593 |
|
|
$caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
|
594 |
|
|
$internal = "YES";
|
595 |
|
|
|
596 |
|
|
} else {
|
597 |
|
|
$caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
|
598 |
|
|
$internal = "NO";
|
599 |
|
|
}
|
600 |
2cf6ddcb
|
Nigel Graham
|
foreach ($a_cert as $cert)
|
601 |
|
|
if ($cert['caref'] == $ca['refid'])
|
602 |
|
|
$certcount++;
|
603 |
|
|
foreach ($a_ca as $cert)
|
604 |
|
|
if ($cert['caref'] == $ca['refid'])
|
605 |
|
|
$certcount++;
|
606 |
96c7a492
|
Matthew Grooms
|
?>
|
607 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
608 |
96c7a492
|
Matthew Grooms
|
<td class="listlr">
|
609 |
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
610 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
611 |
96c7a492
|
Matthew Grooms
|
<td align="left" valign="center">
|
612 |
|
|
<img src="<?=$caimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
|
613 |
64cc39d3
|
Matthew Grooms
|
</td>
|
614 |
96c7a492
|
Matthew Grooms
|
<td align="left" valign="middle">
|
615 |
|
|
<?=$name;?>
|
616 |
64cc39d3
|
Matthew Grooms
|
</td>
|
617 |
|
|
</tr>
|
618 |
|
|
</table>
|
619 |
|
|
</td>
|
620 |
96c7a492
|
Matthew Grooms
|
<td class="listr"><?=$internal;?> </td>
|
621 |
2cf6ddcb
|
Nigel Graham
|
<td class="listr"><?=$issuer_name;?> </td>
|
622 |
96c7a492
|
Matthew Grooms
|
<td class="listr"><?=$certcount;?> </td>
|
623 |
|
|
<td class="listr"><?=$subj;?> </td>
|
624 |
|
|
<td valign="middle" nowrap class="list">
|
625 |
bfa992bc
|
jim-p
|
<a href="system_camanager.php?act=edit&id=<?=$i;?>")">
|
626 |
73800013
|
Chris Buechler
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit CA");?>" alt="<?=gettext("edit CA");?>" width="17" height="17" border="0" />
|
627 |
bfa992bc
|
jim-p
|
</a>
|
628 |
96c7a492
|
Matthew Grooms
|
<a href="system_camanager.php?act=exp&id=<?=$i;?>")">
|
629 |
73800013
|
Chris Buechler
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export CA cert");?>" alt="<?=gettext("export CA cert");?>" width="17" height="17" border="0" />
|
630 |
96c7a492
|
Matthew Grooms
|
</a>
|
631 |
ecefc738
|
jim-p
|
<?php if ($ca['prv']): ?>
|
632 |
|
|
<a href="system_camanager.php?act=expkey&id=<?=$i;?>")">
|
633 |
73800013
|
Chris Buechler
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export CA private key");?>" alt="<?=gettext("export CA private key");?>" width="17" height="17" border="0" />
|
634 |
ecefc738
|
jim-p
|
</a>
|
635 |
|
|
<?php endif; ?>
|
636 |
461aa9d0
|
jim-p
|
<a href="system_camanager.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate Authority and its CRLs, and unreference any associated certificates?");?>')">
|
637 |
2b33f342
|
Renato Botelho
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete ca");?>" alt="<?=gettext("delete ca"); ?>" width="17" height="17" border="0" />
|
638 |
96c7a492
|
Matthew Grooms
|
</a>
|
639 |
|
|
</td>
|
640 |
|
|
</tr>
|
641 |
|
|
<?php
|
642 |
|
|
$i++;
|
643 |
|
|
endforeach;
|
644 |
|
|
?>
|
645 |
|
|
<tr>
|
646 |
2cf6ddcb
|
Nigel Graham
|
<td class="list" colspan="5"></td>
|
647 |
96c7a492
|
Matthew Grooms
|
<td class="list">
|
648 |
|
|
<a href="system_camanager.php?act=new">
|
649 |
a37753d7
|
Vinicius Coque
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add or import ca");?>" alt="<?=gettext("add ca");?>" width="17" height="17" border="0" />
|
650 |
96c7a492
|
Matthew Grooms
|
</a>
|
651 |
|
|
</td>
|
652 |
64cc39d3
|
Matthew Grooms
|
</tr>
|
653 |
|
|
<tr>
|
654 |
2cf6ddcb
|
Nigel Graham
|
<td colspan="5">
|
655 |
96c7a492
|
Matthew Grooms
|
<p>
|
656 |
22a11a58
|
Larry Gilbert
|
<?=gettext("Additional trusted Certificate Authorities can be added here.");?>
|
657 |
96c7a492
|
Matthew Grooms
|
</p>
|
658 |
64cc39d3
|
Matthew Grooms
|
</td>
|
659 |
|
|
</tr>
|
660 |
|
|
</table>
|
661 |
|
|
|
662 |
96c7a492
|
Matthew Grooms
|
<?php endif; ?>
|
663 |
|
|
|
664 |
|
|
</div>
|
665 |
64cc39d3
|
Matthew Grooms
|
</td>
|
666 |
|
|
</tr>
|
667 |
|
|
</table>
|
668 |
|
|
<?php include("fend.inc");?>
|
669 |
|
|
<script type="text/javascript">
|
670 |
|
|
<!--
|
671 |
|
|
|
672 |
|
|
method_change();
|
673 |
|
|
|
674 |
|
|
//-->
|
675 |
|
|
</script>
|
676 |
|
|
|
677 |
|
|
</body>
|