1 |
64cc39d3
|
Matthew Grooms
|
<?php
|
2 |
|
|
/*
|
3 |
|
|
system_certmanager.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-certmanager
|
35 |
|
|
##|*NAME=System: Certificate Manager
|
36 |
|
|
##|*DESCR=Allow access to the 'System: Certificate Manager' page.
|
37 |
|
|
##|*MATCH=system_certmanager.php*
|
38 |
|
|
##|-PRIV
|
39 |
|
|
|
40 |
|
|
require("guiconfig.inc");
|
41 |
14f5ae08
|
Ermal Lu?i
|
require_once("certs.inc");
|
42 |
64cc39d3
|
Matthew Grooms
|
|
43 |
|
|
$cert_methods = array(
|
44 |
ad9b5c67
|
jim-p
|
"import" => gettext("Import an existing Certificate"),
|
45 |
a37753d7
|
Vinicius Coque
|
"internal" => gettext("Create an internal Certificate"),
|
46 |
ad9b5c67
|
jim-p
|
"external" => gettext("Create a Certificate Signing Request"),
|
47 |
|
|
);
|
48 |
64cc39d3
|
Matthew Grooms
|
|
49 |
|
|
$cert_keylens = array( "512", "1024", "2048", "4096");
|
50 |
|
|
|
51 |
51e4f7a3
|
Vinicius Coque
|
$pgtitle = array(gettext("System"), gettext("Certificate Manager"));
|
52 |
64cc39d3
|
Matthew Grooms
|
|
53 |
ad9b5c67
|
jim-p
|
$userid = $_GET['userid'];
|
54 |
|
|
if (isset($_POST['userid']))
|
55 |
|
|
$userid = $_POST['userid'];
|
56 |
|
|
if ($userid) {
|
57 |
|
|
$cert_methods["existing"] = gettext("Choose an existing certificate");
|
58 |
|
|
if (!is_array($config['system']['user']))
|
59 |
|
|
$config['system']['user'] = array();
|
60 |
|
|
$a_user =& $config['system']['user'];
|
61 |
|
|
}
|
62 |
|
|
|
63 |
64cc39d3
|
Matthew Grooms
|
$id = $_GET['id'];
|
64 |
|
|
if (isset($_POST['id']))
|
65 |
|
|
$id = $_POST['id'];
|
66 |
|
|
|
67 |
b4e6524c
|
jim-p
|
if (!is_array($config['ca']))
|
68 |
|
|
$config['ca'] = array();
|
69 |
64cc39d3
|
Matthew Grooms
|
|
70 |
b4e6524c
|
jim-p
|
$a_ca =& $config['ca'];
|
71 |
64cc39d3
|
Matthew Grooms
|
|
72 |
b4e6524c
|
jim-p
|
if (!is_array($config['cert']))
|
73 |
|
|
$config['cert'] = array();
|
74 |
64cc39d3
|
Matthew Grooms
|
|
75 |
b4e6524c
|
jim-p
|
$a_cert =& $config['cert'];
|
76 |
64cc39d3
|
Matthew Grooms
|
|
77 |
|
|
$internal_ca_count = 0;
|
78 |
|
|
foreach ($a_ca as $ca)
|
79 |
|
|
if ($ca['prv'])
|
80 |
|
|
$internal_ca_count++;
|
81 |
|
|
|
82 |
|
|
$act = $_GET['act'];
|
83 |
|
|
if ($_POST['act'])
|
84 |
|
|
$act = $_POST['act'];
|
85 |
|
|
|
86 |
|
|
if ($act == "del") {
|
87 |
|
|
|
88 |
|
|
if (!$a_cert[$id]) {
|
89 |
|
|
pfSenseHeader("system_certmanager.php");
|
90 |
|
|
exit;
|
91 |
|
|
}
|
92 |
|
|
|
93 |
f2a86ca9
|
jim-p
|
$name = $a_cert[$id]['descr'];
|
94 |
64cc39d3
|
Matthew Grooms
|
unset($a_cert[$id]);
|
95 |
|
|
write_config();
|
96 |
ea53e38f
|
Renato Botelho
|
$savemsg = sprintf(gettext("Certificate %s successfully deleted"), $name) . "<br/>";
|
97 |
2f51259b
|
jim-p
|
pfSenseHeader("system_certmanager.php");
|
98 |
|
|
exit;
|
99 |
64cc39d3
|
Matthew Grooms
|
}
|
100 |
|
|
|
101 |
|
|
if ($act == "new") {
|
102 |
|
|
$pconfig['method'] = $_GET['method'];
|
103 |
|
|
$pconfig['keylen'] = "2048";
|
104 |
cf360495
|
Chris Buechler
|
$pconfig['lifetime'] = "3650";
|
105 |
64cc39d3
|
Matthew Grooms
|
}
|
106 |
|
|
|
107 |
93823b10
|
Matthew Grooms
|
if ($act == "exp") {
|
108 |
|
|
|
109 |
|
|
if (!$a_cert[$id]) {
|
110 |
|
|
pfSenseHeader("system_certmanager.php");
|
111 |
|
|
exit;
|
112 |
|
|
}
|
113 |
|
|
|
114 |
f2a86ca9
|
jim-p
|
$exp_name = urlencode("{$a_cert[$id]['descr']}.crt");
|
115 |
93823b10
|
Matthew Grooms
|
$exp_data = base64_decode($a_cert[$id]['crt']);
|
116 |
|
|
$exp_size = strlen($exp_data);
|
117 |
|
|
|
118 |
|
|
header("Content-Type: application/octet-stream");
|
119 |
|
|
header("Content-Disposition: attachment; filename={$exp_name}");
|
120 |
|
|
header("Content-Length: $exp_size");
|
121 |
|
|
echo $exp_data;
|
122 |
|
|
exit;
|
123 |
|
|
}
|
124 |
|
|
|
125 |
73fbece8
|
mgrooms
|
if ($act == "key") {
|
126 |
|
|
|
127 |
|
|
if (!$a_cert[$id]) {
|
128 |
|
|
pfSenseHeader("system_certmanager.php");
|
129 |
|
|
exit;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
f2a86ca9
|
jim-p
|
$exp_name = urlencode("{$a_cert[$id]['descr']}.key");
|
133 |
73fbece8
|
mgrooms
|
$exp_data = base64_decode($a_cert[$id]['prv']);
|
134 |
|
|
$exp_size = strlen($exp_data);
|
135 |
|
|
|
136 |
|
|
header("Content-Type: application/octet-stream");
|
137 |
|
|
header("Content-Disposition: attachment; filename={$exp_name}");
|
138 |
|
|
header("Content-Length: $exp_size");
|
139 |
|
|
echo $exp_data;
|
140 |
|
|
exit;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
64cc39d3
|
Matthew Grooms
|
if ($act == "csr") {
|
144 |
|
|
|
145 |
|
|
if (!$a_cert[$id]) {
|
146 |
|
|
pfSenseHeader("system_certmanager.php");
|
147 |
|
|
exit;
|
148 |
|
|
}
|
149 |
|
|
|
150 |
f2a86ca9
|
jim-p
|
$pconfig['descr'] = $a_cert[$id]['descr'];
|
151 |
64cc39d3
|
Matthew Grooms
|
$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
if ($_POST) {
|
155 |
e64aa6f8
|
Carlos Eduardo Ramos
|
if ($_POST['save'] == gettext("Save")) {
|
156 |
21cc2faa
|
Evgeny Yurchenko
|
$input_errors = array();
|
157 |
64cc39d3
|
Matthew Grooms
|
$pconfig = $_POST;
|
158 |
|
|
|
159 |
|
|
/* input validation */
|
160 |
ad9b5c67
|
jim-p
|
if ($pconfig['method'] == "import") {
|
161 |
64cc39d3
|
Matthew Grooms
|
$reqdfields = explode(" ",
|
162 |
5293bfec
|
jim-p
|
"descr cert key");
|
163 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = array(
|
164 |
|
|
gettext("Descriptive name"),
|
165 |
|
|
gettext("Certificate data"),
|
166 |
|
|
gettext("Key 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 |
64cc39d3
|
Matthew Grooms
|
}
|
170 |
|
|
|
171 |
|
|
if ($pconfig['method'] == "internal") {
|
172 |
|
|
$reqdfields = explode(" ",
|
173 |
5293bfec
|
jim-p
|
"descr caref keylen lifetime dn_country dn_state dn_city ".
|
174 |
64cc39d3
|
Matthew Grooms
|
"dn_organization dn_email dn_commonname");
|
175 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = array(
|
176 |
|
|
gettext("Descriptive name"),
|
177 |
|
|
gettext("Certificate authority"),
|
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 |
|
|
|
188 |
|
|
if ($pconfig['method'] == "external") {
|
189 |
|
|
$reqdfields = explode(" ",
|
190 |
5293bfec
|
jim-p
|
"descr csr_keylen csr_dn_country csr_dn_state csr_dn_city ".
|
191 |
64cc39d3
|
Matthew Grooms
|
"csr_dn_organization csr_dn_email csr_dn_commonname");
|
192 |
38fb1109
|
Vinicius Coque
|
$reqdfieldsn = array(
|
193 |
|
|
gettext("Descriptive name"),
|
194 |
|
|
gettext("Key length"),
|
195 |
|
|
gettext("Distinguished name Country Code"),
|
196 |
|
|
gettext("Distinguished name State or Province"),
|
197 |
|
|
gettext("Distinguished name City"),
|
198 |
|
|
gettext("Distinguished name Organization"),
|
199 |
|
|
gettext("Distinguished name Email Address"),
|
200 |
a37753d7
|
Vinicius Coque
|
gettext("Distinguished name Common Name"));
|
201 |
64cc39d3
|
Matthew Grooms
|
}
|
202 |
|
|
|
203 |
ad9b5c67
|
jim-p
|
if ($pconfig['method'] == "existing") {
|
204 |
|
|
$reqdfields = array("certref");
|
205 |
|
|
$reqdfieldsn = array(gettext("Existing Certificate Choice"));
|
206 |
|
|
}
|
207 |
|
|
|
208 |
64cc39d3
|
Matthew Grooms
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
209 |
21cc2faa
|
Evgeny Yurchenko
|
if ($pconfig['method'] != "import")
|
210 |
|
|
/* Make sure we do not have invalid characters in the fields for the certificate */
|
211 |
|
|
for ($i = 0; $i < count($reqdfields); $i++) {
|
212 |
|
|
if (preg_match('/email/', $reqdfields[$i])){ /* dn_email or csr_dn_name */
|
213 |
|
|
if (preg_match("/[\!\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST["$reqdfields[$i]"]))
|
214 |
|
|
array_push($input_errors, "The field 'Distinguished name Email Address' contains invalid characters.");
|
215 |
|
|
}else if (preg_match('/commonname/', $reqdfields[$i])){ /* dn_commonname or csr_dn_commonname */
|
216 |
|
|
if (preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST["$reqdfields[$i]"]))
|
217 |
|
|
array_push($input_errors, "The field 'Distinguished name Common Name' contains invalid characters.");
|
218 |
|
|
}else if (preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\.\"\']/", $_POST["$reqdfields[$i]"]))
|
219 |
|
|
array_push($input_errors, "The field '" . $reqdfieldsn[$i] . "' contains invalid characters.");
|
220 |
|
|
}
|
221 |
64cc39d3
|
Matthew Grooms
|
|
222 |
|
|
/* if this is an AJAX caller then handle via JSON */
|
223 |
|
|
if (isAjax() && is_array($input_errors)) {
|
224 |
|
|
input_errors2Ajax($input_errors);
|
225 |
|
|
exit;
|
226 |
|
|
}
|
227 |
|
|
|
228 |
|
|
/* save modifications */
|
229 |
|
|
if (!$input_errors) {
|
230 |
|
|
|
231 |
ad9b5c67
|
jim-p
|
if ($pconfig['method'] == "existing") {
|
232 |
|
|
$cert = lookup_cert($pconfig['certref']);
|
233 |
|
|
if ($cert && $a_user)
|
234 |
|
|
$a_user[$userid]['cert'][] = $cert['refid'];
|
235 |
|
|
} else {
|
236 |
|
|
$cert = array();
|
237 |
|
|
$cert['refid'] = uniqid();
|
238 |
|
|
if (isset($id) && $a_cert[$id])
|
239 |
|
|
$cert = $a_cert[$id];
|
240 |
|
|
|
241 |
f2a86ca9
|
jim-p
|
$cert['descr'] = $pconfig['descr'];
|
242 |
ad9b5c67
|
jim-p
|
|
243 |
22b380aa
|
Evgeny Yurchenko
|
$old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warings directly to a page screwing menu tab */
|
244 |
|
|
|
245 |
ad9b5c67
|
jim-p
|
if ($pconfig['method'] == "import")
|
246 |
|
|
cert_import($cert, $pconfig['cert'], $pconfig['key']);
|
247 |
|
|
|
248 |
|
|
if ($pconfig['method'] == "internal") {
|
249 |
|
|
$dn = array(
|
250 |
|
|
'countryName' => $pconfig['dn_country'],
|
251 |
|
|
'stateOrProvinceName' => $pconfig['dn_state'],
|
252 |
|
|
'localityName' => $pconfig['dn_city'],
|
253 |
|
|
'organizationName' => $pconfig['dn_organization'],
|
254 |
|
|
'emailAddress' => $pconfig['dn_email'],
|
255 |
|
|
'commonName' => $pconfig['dn_commonname']);
|
256 |
|
|
|
257 |
22b380aa
|
Evgeny Yurchenko
|
if (!cert_create($cert, $pconfig['caref'], $pconfig['keylen'],
|
258 |
|
|
$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 |
ad9b5c67
|
jim-p
|
}
|
265 |
|
|
|
266 |
|
|
if ($pconfig['method'] == "external") {
|
267 |
|
|
$dn = array(
|
268 |
|
|
'countryName' => $pconfig['csr_dn_country'],
|
269 |
|
|
'stateOrProvinceName' => $pconfig['csr_dn_state'],
|
270 |
|
|
'localityName' => $pconfig['csr_dn_city'],
|
271 |
|
|
'organizationName' => $pconfig['csr_dn_organization'],
|
272 |
|
|
'emailAddress' => $pconfig['csr_dn_email'],
|
273 |
|
|
'commonName' => $pconfig['csr_dn_commonname']);
|
274 |
|
|
|
275 |
22b380aa
|
Evgeny Yurchenko
|
if(!csr_generate($cert, $pconfig['csr_keylen'], $dn)){
|
276 |
|
|
while($ssl_err = openssl_error_string()){
|
277 |
|
|
$input_errors = array();
|
278 |
|
|
array_push($input_errors, "openssl library returns: " . $ssl_err);
|
279 |
|
|
}
|
280 |
|
|
}
|
281 |
ad9b5c67
|
jim-p
|
}
|
282 |
22b380aa
|
Evgeny Yurchenko
|
error_reporting($old_err_level);
|
283 |
|
|
|
284 |
ad9b5c67
|
jim-p
|
if (isset($id) && $a_cert[$id])
|
285 |
|
|
$a_cert[$id] = $cert;
|
286 |
|
|
else
|
287 |
|
|
$a_cert[] = $cert;
|
288 |
|
|
if (isset($a_user) && isset($userid))
|
289 |
|
|
$a_user[$userid]['cert'][] = $cert['refid'];
|
290 |
64cc39d3
|
Matthew Grooms
|
}
|
291 |
|
|
|
292 |
22b380aa
|
Evgeny Yurchenko
|
if (!$input_errors)
|
293 |
|
|
write_config();
|
294 |
64cc39d3
|
Matthew Grooms
|
|
295 |
ad9b5c67
|
jim-p
|
if ($userid)
|
296 |
|
|
pfSenseHeader("system_usermanager.php?act=edit&id={$userid}");
|
297 |
64cc39d3
|
Matthew Grooms
|
}
|
298 |
|
|
}
|
299 |
|
|
|
300 |
a37753d7
|
Vinicius Coque
|
if ($_POST['save'] == gettext("Update")) {
|
301 |
64cc39d3
|
Matthew Grooms
|
unset($input_errors);
|
302 |
|
|
$pconfig = $_POST;
|
303 |
|
|
|
304 |
|
|
/* input validation */
|
305 |
5293bfec
|
jim-p
|
$reqdfields = explode(" ", "descr cert");
|
306 |
76d49f20
|
Renato Botelho
|
$reqdfieldsn = array(
|
307 |
|
|
gettext("Descriptive name"),
|
308 |
|
|
gettext("Final Certificate data"));
|
309 |
64cc39d3
|
Matthew Grooms
|
|
310 |
|
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
311 |
|
|
|
312 |
a828210b
|
yakatz
|
// old way
|
313 |
64cc39d3
|
Matthew Grooms
|
/* make sure this csr and certificate subjects match */
|
314 |
a828210b
|
yakatz
|
// $subj_csr = csr_get_subject($pconfig['csr'], false);
|
315 |
|
|
// $subj_cert = cert_get_subject($pconfig['cert'], false);
|
316 |
|
|
//
|
317 |
|
|
// if ( !isset($_POST['ignoresubjectmismatch']) && !($_POST['ignoresubjectmismatch'] == "yes") ) {
|
318 |
|
|
// if (strcmp($subj_csr,$subj_cert)) {
|
319 |
|
|
// $input_errors[] = sprintf(gettext("The certificate subject '%s' does not match the signing request subject."),$subj_cert);
|
320 |
|
|
// $subject_mismatch = true;
|
321 |
|
|
// }
|
322 |
|
|
// }
|
323 |
2594f401
|
yakatz
|
$mod_csr = csr_get_modulus($pconfig['csr'], false);
|
324 |
|
|
$mod_cert = cert_get_modulus($pconfig['cert'], false);
|
325 |
a828210b
|
yakatz
|
|
326 |
|
|
if (strcmp($mod_csr,$mod_cert)) {
|
327 |
|
|
// simply: if the moduli don't match, then the private key and public key won't match
|
328 |
|
|
$input_errors[] = sprintf(gettext("The certificate modulus does not match the signing request modulus."),$subj_cert);
|
329 |
|
|
$subject_mismatch = true;
|
330 |
|
|
}
|
331 |
64cc39d3
|
Matthew Grooms
|
|
332 |
|
|
/* if this is an AJAX caller then handle via JSON */
|
333 |
|
|
if (isAjax() && is_array($input_errors)) {
|
334 |
|
|
input_errors2Ajax($input_errors);
|
335 |
|
|
exit;
|
336 |
|
|
}
|
337 |
|
|
|
338 |
|
|
/* save modifications */
|
339 |
|
|
if (!$input_errors) {
|
340 |
|
|
|
341 |
|
|
$cert = $a_cert[$id];
|
342 |
|
|
|
343 |
f2a86ca9
|
jim-p
|
$cert['descr'] = $pconfig['descr'];
|
344 |
64cc39d3
|
Matthew Grooms
|
|
345 |
|
|
csr_complete($cert, $pconfig['cert']);
|
346 |
|
|
|
347 |
|
|
$a_cert[$id] = $cert;
|
348 |
|
|
|
349 |
|
|
write_config();
|
350 |
|
|
|
351 |
|
|
pfSenseHeader("system_certmanager.php");
|
352 |
|
|
}
|
353 |
|
|
}
|
354 |
|
|
}
|
355 |
|
|
|
356 |
|
|
include("head.inc");
|
357 |
|
|
?>
|
358 |
|
|
|
359 |
a828210b
|
yakatz
|
<body link="#000000" vlink="#000000" alink="#000000" onLoad="<?= $jsevents["body"]["onload"] ?>">
|
360 |
64cc39d3
|
Matthew Grooms
|
<?php include("fbegin.inc"); ?>
|
361 |
|
|
<script type="text/javascript">
|
362 |
|
|
<!--
|
363 |
|
|
|
364 |
|
|
function method_change() {
|
365 |
|
|
|
366 |
|
|
<?php
|
367 |
|
|
if ($internal_ca_count)
|
368 |
|
|
$submit_style = "";
|
369 |
|
|
else
|
370 |
|
|
$submit_style = "none";
|
371 |
|
|
?>
|
372 |
|
|
|
373 |
|
|
method = document.iform.method.selectedIndex;
|
374 |
|
|
|
375 |
|
|
switch (method) {
|
376 |
|
|
case 0:
|
377 |
ad9b5c67
|
jim-p
|
document.getElementById("import").style.display="";
|
378 |
64cc39d3
|
Matthew Grooms
|
document.getElementById("internal").style.display="none";
|
379 |
|
|
document.getElementById("external").style.display="none";
|
380 |
ad9b5c67
|
jim-p
|
document.getElementById("existing").style.display="none";
|
381 |
|
|
document.getElementById("descriptivename").style.display="";
|
382 |
96c7a492
|
Matthew Grooms
|
document.getElementById("submit").style.display="";
|
383 |
64cc39d3
|
Matthew Grooms
|
break;
|
384 |
|
|
case 1:
|
385 |
ad9b5c67
|
jim-p
|
document.getElementById("import").style.display="none";
|
386 |
64cc39d3
|
Matthew Grooms
|
document.getElementById("internal").style.display="";
|
387 |
|
|
document.getElementById("external").style.display="none";
|
388 |
ad9b5c67
|
jim-p
|
document.getElementById("existing").style.display="none";
|
389 |
|
|
document.getElementById("descriptivename").style.display="";
|
390 |
64cc39d3
|
Matthew Grooms
|
document.getElementById("submit").style.display="<?=$submit_style;?>";
|
391 |
|
|
break;
|
392 |
|
|
case 2:
|
393 |
ad9b5c67
|
jim-p
|
document.getElementById("import").style.display="none";
|
394 |
64cc39d3
|
Matthew Grooms
|
document.getElementById("internal").style.display="none";
|
395 |
|
|
document.getElementById("external").style.display="";
|
396 |
ad9b5c67
|
jim-p
|
document.getElementById("existing").style.display="none";
|
397 |
|
|
document.getElementById("descriptivename").style.display="";
|
398 |
|
|
document.getElementById("submit").style.display="";
|
399 |
|
|
break;
|
400 |
|
|
case 3:
|
401 |
|
|
document.getElementById("import").style.display="none";
|
402 |
|
|
document.getElementById("internal").style.display="none";
|
403 |
|
|
document.getElementById("external").style.display="none";
|
404 |
|
|
document.getElementById("existing").style.display="";
|
405 |
|
|
document.getElementById("descriptivename").style.display="none";
|
406 |
96c7a492
|
Matthew Grooms
|
document.getElementById("submit").style.display="";
|
407 |
64cc39d3
|
Matthew Grooms
|
break;
|
408 |
|
|
}
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
<?php if ($internal_ca_count): ?>
|
412 |
|
|
function internalca_change() {
|
413 |
|
|
|
414 |
|
|
index = document.iform.caref.selectedIndex;
|
415 |
|
|
caref = document.iform.caref[index].value;
|
416 |
|
|
|
417 |
|
|
switch (caref) {
|
418 |
|
|
<?php
|
419 |
|
|
foreach ($a_ca as $ca):
|
420 |
|
|
if (!$ca['prv'])
|
421 |
|
|
continue;
|
422 |
|
|
$subject = cert_get_subject_array($ca['crt']);
|
423 |
|
|
?>
|
424 |
|
|
case "<?=$ca['refid'];?>":
|
425 |
|
|
document.iform.dn_country.value = "<?=$subject[0]['v'];?>";
|
426 |
|
|
document.iform.dn_state.value = "<?=$subject[1]['v'];?>";
|
427 |
|
|
document.iform.dn_city.value = "<?=$subject[2]['v'];?>";
|
428 |
|
|
document.iform.dn_organization.value = "<?=$subject[3]['v'];?>";
|
429 |
ad9b5c67
|
jim-p
|
document.iform.dn_email.value = "<?=$subject[4]['v'];?>";
|
430 |
64cc39d3
|
Matthew Grooms
|
break;
|
431 |
|
|
<?php endforeach; ?>
|
432 |
|
|
}
|
433 |
|
|
}
|
434 |
|
|
<?php endif; ?>
|
435 |
|
|
|
436 |
|
|
//-->
|
437 |
|
|
</script>
|
438 |
|
|
<?php
|
439 |
|
|
if ($input_errors)
|
440 |
|
|
print_input_errors($input_errors);
|
441 |
|
|
if ($savemsg)
|
442 |
|
|
print_info_box($savemsg);
|
443 |
24cbe7a8
|
Evgeny Yurchenko
|
|
444 |
|
|
// Load valid country codes
|
445 |
|
|
$dn_cc = array();
|
446 |
|
|
if (file_exists("/etc/ca_countries")){
|
447 |
|
|
$dn_cc_file=file("/etc/ca_countries");
|
448 |
|
|
foreach($dn_cc_file as $line)
|
449 |
|
|
if (preg_match('/^(\S*)\s(.*)$/', $line, $matches))
|
450 |
|
|
array_push($dn_cc, $matches[1]);
|
451 |
|
|
}
|
452 |
64cc39d3
|
Matthew Grooms
|
?>
|
453 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
454 |
|
|
<tr>
|
455 |
|
|
<td class="tabnavtbl">
|
456 |
|
|
<?php
|
457 |
|
|
$tab_array = array();
|
458 |
|
|
$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
|
459 |
|
|
$tab_array[] = array(gettext("Certificates"), true, "system_certmanager.php");
|
460 |
3d57d2d5
|
jim-p
|
$tab_array[] = array(gettext("Certificate Revocation"), false, "system_crlmanager.php");
|
461 |
64cc39d3
|
Matthew Grooms
|
display_top_tabs($tab_array);
|
462 |
|
|
?>
|
463 |
|
|
</td>
|
464 |
|
|
</tr>
|
465 |
|
|
<tr>
|
466 |
96c7a492
|
Matthew Grooms
|
<td id="mainarea">
|
467 |
|
|
<div class="tabcont">
|
468 |
|
|
|
469 |
e64aa6f8
|
Carlos Eduardo Ramos
|
<?php if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)): ?>
|
470 |
96c7a492
|
Matthew Grooms
|
|
471 |
|
|
<form action="system_certmanager.php" method="post" name="iform" id="iform">
|
472 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
473 |
|
|
<?php if (!isset($id)): ?>
|
474 |
|
|
<tr>
|
475 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
|
476 |
|
|
<td width="78%" class="vtable">
|
477 |
|
|
<select name='method' id='method' class="formselect" onchange='method_change()'>
|
478 |
|
|
<?php
|
479 |
|
|
foreach($cert_methods as $method => $desc):
|
480 |
|
|
$selected = "";
|
481 |
|
|
if ($pconfig['method'] == $method)
|
482 |
|
|
$selected = "selected";
|
483 |
|
|
?>
|
484 |
|
|
<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option>
|
485 |
|
|
<?php endforeach; ?>
|
486 |
|
|
</select>
|
487 |
|
|
</td>
|
488 |
|
|
</tr>
|
489 |
|
|
<?php endif; ?>
|
490 |
ad9b5c67
|
jim-p
|
<tr id="descriptivename">
|
491 |
|
|
<?php
|
492 |
f2a86ca9
|
jim-p
|
if ($a_user && empty($pconfig['descr']))
|
493 |
|
|
$pconfig['descr'] = $a_user[$userid]['name'];
|
494 |
ad9b5c67
|
jim-p
|
?>
|
495 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
|
496 |
|
|
<td width="78%" class="vtable">
|
497 |
f2a86ca9
|
jim-p
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
|
498 |
ad9b5c67
|
jim-p
|
</td>
|
499 |
|
|
</tr>
|
500 |
96c7a492
|
Matthew Grooms
|
</table>
|
501 |
|
|
|
502 |
ad9b5c67
|
jim-p
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="import">
|
503 |
96c7a492
|
Matthew Grooms
|
<tr>
|
504 |
|
|
<td colspan="2" class="list" height="12"></td>
|
505 |
|
|
</tr>
|
506 |
|
|
<tr>
|
507 |
ad9b5c67
|
jim-p
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Import Certificate");?></td>
|
508 |
96c7a492
|
Matthew Grooms
|
</tr>
|
509 |
|
|
|
510 |
|
|
<tr>
|
511 |
a37753d7
|
Vinicius Coque
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td>
|
512 |
96c7a492
|
Matthew Grooms
|
<td width="78%" class="vtable">
|
513 |
dd5bf424
|
Scott Ullrich
|
<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea>
|
514 |
96c7a492
|
Matthew Grooms
|
<br>
|
515 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Paste a certificate in X.509 PEM format here.");?></td>
|
516 |
96c7a492
|
Matthew Grooms
|
</td>
|
517 |
|
|
</tr>
|
518 |
|
|
<tr>
|
519 |
a37753d7
|
Vinicius Coque
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Private key data");?></td>
|
520 |
96c7a492
|
Matthew Grooms
|
<td width="78%" class="vtable">
|
521 |
dd5bf424
|
Scott Ullrich
|
<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['key']);?></textarea>
|
522 |
96c7a492
|
Matthew Grooms
|
<br>
|
523 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Paste a private key in X.509 PEM format here.");?></td>
|
524 |
96c7a492
|
Matthew Grooms
|
</td>
|
525 |
|
|
</tr>
|
526 |
|
|
</table>
|
527 |
|
|
|
528 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal">
|
529 |
|
|
<tr>
|
530 |
|
|
<td colspan="2" class="list" height="12"></td>
|
531 |
|
|
</tr>
|
532 |
|
|
<tr>
|
533 |
a37753d7
|
Vinicius Coque
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate");?></td>
|
534 |
96c7a492
|
Matthew Grooms
|
</tr>
|
535 |
|
|
|
536 |
|
|
<?php if (!$internal_ca_count): ?>
|
537 |
|
|
|
538 |
|
|
<tr>
|
539 |
|
|
<td colspan="2" align="center" class="vtable">
|
540 |
a37753d7
|
Vinicius Coque
|
<?=gettext("No internal Certificate Authorities have been defined. You must");?>
|
541 |
|
|
<a href="system_camanager.php?act=new&method=internal"><?=gettext("create");?></a>
|
542 |
|
|
<?=gettext("an internal CA before creating an internal certificate.");?>
|
543 |
96c7a492
|
Matthew Grooms
|
</td>
|
544 |
|
|
</tr>
|
545 |
|
|
|
546 |
|
|
<?php else: ?>
|
547 |
|
|
|
548 |
|
|
<tr>
|
549 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
|
550 |
|
|
<td width="78%" class="vtable">
|
551 |
|
|
<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
|
552 |
|
|
<?php
|
553 |
|
|
foreach( $a_ca as $ca):
|
554 |
|
|
if (!$ca['prv'])
|
555 |
|
|
continue;
|
556 |
|
|
$selected = "";
|
557 |
|
|
if ($pconfig['caref'] == $ca['refid'])
|
558 |
|
|
$selected = "selected";
|
559 |
|
|
?>
|
560 |
f2a86ca9
|
jim-p
|
<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['descr'];?></option>
|
561 |
96c7a492
|
Matthew Grooms
|
<?php endforeach; ?>
|
562 |
|
|
</select>
|
563 |
|
|
</td>
|
564 |
|
|
</tr>
|
565 |
|
|
<tr>
|
566 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
|
567 |
|
|
<td width="78%" class="vtable">
|
568 |
|
|
<select name='keylen' class="formselect">
|
569 |
|
|
<?php
|
570 |
|
|
foreach( $cert_keylens as $len):
|
571 |
|
|
$selected = "";
|
572 |
|
|
if ($pconfig['keylen'] == $len)
|
573 |
|
|
$selected = "selected";
|
574 |
|
|
?>
|
575 |
|
|
<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
|
576 |
|
|
<?php endforeach; ?>
|
577 |
|
|
</select>
|
578 |
a37753d7
|
Vinicius Coque
|
<?=gettext("bits");?>
|
579 |
96c7a492
|
Matthew Grooms
|
</td>
|
580 |
|
|
</tr>
|
581 |
|
|
<tr>
|
582 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
|
583 |
|
|
<td width="78%" class="vtable">
|
584 |
|
|
<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
|
585 |
a37753d7
|
Vinicius Coque
|
<?=gettext("days");?>
|
586 |
96c7a492
|
Matthew Grooms
|
</td>
|
587 |
|
|
</tr>
|
588 |
|
|
<tr>
|
589 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
|
590 |
|
|
<td width="78%" class="vtable">
|
591 |
|
|
<table border="0" cellspacing="0" cellpadding="2">
|
592 |
|
|
<tr>
|
593 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Country Code");?> : </td>
|
594 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
595 |
0fcaf4f2
|
jim-p
|
<input name="dn_country" type="text" class="formfld unknown" maxlength="2" size="2" value="<?=htmlspecialchars($pconfig['dn_country']);?>"/>
|
596 |
96c7a492
|
Matthew Grooms
|
</td>
|
597 |
|
|
</tr>
|
598 |
|
|
<tr>
|
599 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("State or Province");?> : </td>
|
600 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
601 |
0fcaf4f2
|
jim-p
|
<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>"/>
|
602 |
96c7a492
|
Matthew Grooms
|
</td>
|
603 |
|
|
</tr>
|
604 |
|
|
<tr>
|
605 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("City");?> : </td>
|
606 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
607 |
0fcaf4f2
|
jim-p
|
<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>"/>
|
608 |
96c7a492
|
Matthew Grooms
|
</td>
|
609 |
|
|
</tr>
|
610 |
|
|
<tr>
|
611 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Organization");?> : </td>
|
612 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
613 |
0fcaf4f2
|
jim-p
|
<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>"/>
|
614 |
96c7a492
|
Matthew Grooms
|
</td>
|
615 |
|
|
</tr>
|
616 |
|
|
<tr>
|
617 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Email Address");?> : </td>
|
618 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
619 |
|
|
<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/>
|
620 |
|
|
|
621 |
|
|
<em>ex:</em>
|
622 |
|
|
|
623 |
a37753d7
|
Vinicius Coque
|
<?=gettext("webadmin@mycompany.com");?>
|
624 |
96c7a492
|
Matthew Grooms
|
</td>
|
625 |
|
|
</tr>
|
626 |
|
|
<tr>
|
627 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Common Name");?> : </td>
|
628 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
629 |
ad9b5c67
|
jim-p
|
<?php
|
630 |
|
|
if ($a_user && empty($pconfig['dn_commonname']))
|
631 |
|
|
$pconfig['dn_commonname'] = $a_user[$userid]['name'];
|
632 |
|
|
?>
|
633 |
96c7a492
|
Matthew Grooms
|
<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/>
|
634 |
|
|
|
635 |
|
|
<em>ex:</em>
|
636 |
|
|
|
637 |
a37753d7
|
Vinicius Coque
|
<?=gettext("www.example.com");?>
|
638 |
96c7a492
|
Matthew Grooms
|
</td>
|
639 |
|
|
</tr>
|
640 |
|
|
</table>
|
641 |
|
|
</td>
|
642 |
|
|
</tr>
|
643 |
64cc39d3
|
Matthew Grooms
|
|
644 |
|
|
<?php endif; ?>
|
645 |
|
|
|
646 |
96c7a492
|
Matthew Grooms
|
</table>
|
647 |
|
|
|
648 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="external">
|
649 |
|
|
<tr>
|
650 |
|
|
<td colspan="2" class="list" height="12"></td>
|
651 |
|
|
</tr>
|
652 |
|
|
<tr>
|
653 |
a37753d7
|
Vinicius Coque
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("External Signing Request");?></td>
|
654 |
96c7a492
|
Matthew Grooms
|
</tr>
|
655 |
|
|
<tr>
|
656 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
|
657 |
|
|
<td width="78%" class="vtable">
|
658 |
|
|
<select name='csr_keylen' class="formselect">
|
659 |
|
|
<?php
|
660 |
|
|
foreach( $cert_keylens as $len):
|
661 |
|
|
$selected = "";
|
662 |
|
|
if ($pconfig['keylen'] == $len)
|
663 |
|
|
$selected = "selected";
|
664 |
|
|
?>
|
665 |
|
|
<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
|
666 |
|
|
<?php endforeach; ?>
|
667 |
|
|
</select>
|
668 |
|
|
bits
|
669 |
|
|
</td>
|
670 |
|
|
</tr>
|
671 |
|
|
<tr>
|
672 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
|
673 |
|
|
<td width="78%" class="vtable">
|
674 |
|
|
<table border="0" cellspacing="0" cellpadding="2">
|
675 |
|
|
<tr>
|
676 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Country Code");?> : </td>
|
677 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
678 |
24cbe7a8
|
Evgeny Yurchenko
|
<select name='csr_dn_country' class="formselect">
|
679 |
|
|
<?php
|
680 |
|
|
foreach( $dn_cc as $cc){
|
681 |
|
|
$selected = "";
|
682 |
|
|
if ($pconfig['csr_dn_country'] == $cc) $selected = "selected";
|
683 |
|
|
print "<option value=\"$cc\" $selected>$cc</option>";
|
684 |
|
|
}
|
685 |
|
|
?>
|
686 |
|
|
</select>
|
687 |
96c7a492
|
Matthew Grooms
|
</td>
|
688 |
|
|
</tr>
|
689 |
|
|
<tr>
|
690 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("State or Province");?> : </td>
|
691 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
692 |
|
|
<input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_state']);?>" />
|
693 |
|
|
|
694 |
|
|
<em>ex:</em>
|
695 |
|
|
|
696 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Texas");?>
|
697 |
96c7a492
|
Matthew Grooms
|
</td>
|
698 |
|
|
</tr>
|
699 |
|
|
<tr>
|
700 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("City");?> : </td>
|
701 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
702 |
|
|
<input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_city']);?>" />
|
703 |
|
|
|
704 |
|
|
<em>ex:</em>
|
705 |
|
|
|
706 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Austin");?>
|
707 |
96c7a492
|
Matthew Grooms
|
</td>
|
708 |
|
|
</tr>
|
709 |
|
|
<tr>
|
710 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Organization");?> : </td>
|
711 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
712 |
|
|
<input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_organization']);?>" />
|
713 |
|
|
|
714 |
|
|
<em>ex:</em>
|
715 |
|
|
|
716 |
a37753d7
|
Vinicius Coque
|
<?=gettext("My Company Inc.");?>
|
717 |
96c7a492
|
Matthew Grooms
|
</td>
|
718 |
|
|
</tr>
|
719 |
|
|
<tr>
|
720 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Email Address");?> : </td>
|
721 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
722 |
|
|
<input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_email']);?>"/>
|
723 |
|
|
|
724 |
|
|
<em>ex:</em>
|
725 |
|
|
|
726 |
a37753d7
|
Vinicius Coque
|
<?=gettext("webadmin@mycompany.com");?>
|
727 |
96c7a492
|
Matthew Grooms
|
</td>
|
728 |
|
|
</tr>
|
729 |
|
|
<tr>
|
730 |
a37753d7
|
Vinicius Coque
|
<td align="right"><?=gettext("Common Name");?> : </td>
|
731 |
96c7a492
|
Matthew Grooms
|
<td align="left">
|
732 |
|
|
<input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_commonname']);?>"/>
|
733 |
|
|
|
734 |
|
|
<em>ex:</em>
|
735 |
|
|
|
736 |
a37753d7
|
Vinicius Coque
|
<?=gettext("www.example.com");?>
|
737 |
96c7a492
|
Matthew Grooms
|
</td>
|
738 |
|
|
</tr>
|
739 |
|
|
</table>
|
740 |
|
|
</td>
|
741 |
|
|
</tr>
|
742 |
|
|
</table>
|
743 |
|
|
|
744 |
ad9b5c67
|
jim-p
|
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing">
|
745 |
|
|
<tr>
|
746 |
|
|
<td colspan="2" class="list" height="12"></td>
|
747 |
|
|
</tr>
|
748 |
|
|
<tr>
|
749 |
|
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Choose an Existing Certificate");?></td>
|
750 |
|
|
</tr>
|
751 |
|
|
<tr>
|
752 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Existing Certificates");?></td>
|
753 |
|
|
<td width="78%" class="vtable">
|
754 |
|
|
<?php if (isset($userid) && $a_user): ?>
|
755 |
|
|
<input name="userid" type="hidden" value="<?=$userid;?>" />
|
756 |
|
|
<?php endif;?>
|
757 |
|
|
<select name='certref' class="formselect">
|
758 |
|
|
<?php
|
759 |
|
|
foreach ($config['cert'] as $cert):
|
760 |
|
|
$selected = "";
|
761 |
|
|
$caname = "";
|
762 |
|
|
$inuse = "";
|
763 |
6a0b3ea4
|
jim-p
|
$revoked = "";
|
764 |
ad9b5c67
|
jim-p
|
if (in_array($cert['refid'], $config['system']['user'][$userid]['cert']))
|
765 |
|
|
continue;
|
766 |
|
|
$ca = lookup_ca($cert['caref']);
|
767 |
|
|
if ($ca)
|
768 |
f2a86ca9
|
jim-p
|
$caname = " (CA: {$ca['descr']})";
|
769 |
ad9b5c67
|
jim-p
|
if ($pconfig['certref'] == $cert['refid'])
|
770 |
|
|
$selected = "selected";
|
771 |
|
|
if (cert_in_use($cert['refid']))
|
772 |
|
|
$inuse = " *In Use";
|
773 |
6a0b3ea4
|
jim-p
|
if (is_cert_revoked($cert))
|
774 |
|
|
$revoked = " *Revoked";
|
775 |
ad9b5c67
|
jim-p
|
?>
|
776 |
6a0b3ea4
|
jim-p
|
<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
|
777 |
ad9b5c67
|
jim-p
|
<?php endforeach; ?>
|
778 |
|
|
</select>
|
779 |
|
|
</td>
|
780 |
|
|
</tr>
|
781 |
|
|
</table>
|
782 |
|
|
|
783 |
96c7a492
|
Matthew Grooms
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
784 |
|
|
<tr>
|
785 |
|
|
<td width="22%" valign="top"> </td>
|
786 |
|
|
<td width="78%">
|
787 |
e64aa6f8
|
Carlos Eduardo Ramos
|
<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
|
788 |
96c7a492
|
Matthew Grooms
|
<?php if (isset($id) && $a_cert[$id]): ?>
|
789 |
|
|
<input name="id" type="hidden" value="<?=$id;?>" />
|
790 |
|
|
<?php endif;?>
|
791 |
|
|
</td>
|
792 |
|
|
</tr>
|
793 |
|
|
</table>
|
794 |
|
|
</form>
|
795 |
|
|
|
796 |
e64aa6f8
|
Carlos Eduardo Ramos
|
<?php elseif ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)):?>
|
797 |
96c7a492
|
Matthew Grooms
|
|
798 |
|
|
<form action="system_certmanager.php" method="post" name="iform" id="iform">
|
799 |
|
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
800 |
|
|
<tr>
|
801 |
|
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
|
802 |
|
|
<td width="78%" class="vtable">
|
803 |
f2a86ca9
|
jim-p
|
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
|
804 |
96c7a492
|
Matthew Grooms
|
</td>
|
805 |
|
|
</tr>
|
806 |
|
|
<tr>
|
807 |
|
|
<td colspan="2" class="list" height="12"></td>
|
808 |
|
|
</tr>
|
809 |
|
|
<tr>
|
810 |
a37753d7
|
Vinicius Coque
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Complete Signing Request");?></td>
|
811 |
96c7a492
|
Matthew Grooms
|
</tr>
|
812 |
|
|
|
813 |
|
|
<tr>
|
814 |
a37753d7
|
Vinicius Coque
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Signing Request data");?></td>
|
815 |
96c7a492
|
Matthew Grooms
|
<td width="78%" class="vtable">
|
816 |
dd5bf424
|
Scott Ullrich
|
<textarea name="csr" id="csr" cols="65" rows="7" class="formfld_cert" readonly><?=htmlspecialchars($pconfig['csr']);?></textarea>
|
817 |
96c7a492
|
Matthew Grooms
|
<br>
|
818 |
a37753d7
|
Vinicius Coque
|
<?=gettext("Copy the certificate signing data from here and forward it to your certificate authority for signing.");?></td>
|
819 |
96c7a492
|
Matthew Grooms
|
</td>
|
820 |
|
|
</tr>
|
821 |
|
|
<tr>
|
822 |
a37753d7
|
Vinicius Coque
|
<td width="22%" valign="top" class="vncellreq"><?=gettext("Final Certificate data");?></td>
|
823 |
96c7a492
|
Matthew Grooms
|
<td width="78%" class="vtable">
|
824 |
dd5bf424
|
Scott Ullrich
|
<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea>
|
825 |
96c7a492
|
Matthew Grooms
|
<br>
|
826 |
1dfb7795
|
Chris Buechler
|
<?=gettext("Paste the certificate received from your certificate authority here.");?></td>
|
827 |
96c7a492
|
Matthew Grooms
|
</td>
|
828 |
|
|
</tr>
|
829 |
|
|
<tr>
|
830 |
|
|
<td width="22%" valign="top"> </td>
|
831 |
|
|
<td width="78%">
|
832 |
a828210b
|
yakatz
|
<?php /* if ( isset($subject_mismatch) && $subject_mismatch === true): ?>
|
833 |
e2e934e0
|
yakatz
|
<input id="ignoresubjectmismatch" name="ignoresubjectmismatch" type="checkbox" class="formbtn" value="yes" />
|
834 |
|
|
<label for="ignoresubjectmismatch"><strong><?=gettext("Ignore certificate subject mismatch"); ?></strong></label><br />
|
835 |
|
|
<?php echo gettext("Warning: Using this option may create an " .
|
836 |
|
|
"invalid certificate. Check this box to disable the request -> " .
|
837 |
|
|
"response subject verification. ");
|
838 |
|
|
?><br/>
|
839 |
a828210b
|
yakatz
|
<?php endif; */ ?>
|
840 |
e64aa6f8
|
Carlos Eduardo Ramos
|
<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Update");?>" />
|
841 |
96c7a492
|
Matthew Grooms
|
<?php if (isset($id) && $a_cert[$id]): ?>
|
842 |
|
|
<input name="id" type="hidden" value="<?=$id;?>" />
|
843 |
|
|
<input name="act" type="hidden" value="csr" />
|
844 |
|
|
<?php endif;?>
|
845 |
|
|
</td>
|
846 |
|
|
</tr>
|
847 |
|
|
</table>
|
848 |
|
|
</form>
|
849 |
|
|
|
850 |
|
|
<?php else:?>
|
851 |
|
|
|
852 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
853 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
854 |
d590fa20
|
jim-p
|
<td width="15%" class="listhdrr"><?=gettext("Name");?></td>
|
855 |
|
|
<td width="15%" class="listhdrr"><?=gettext("Issuer");?></td>
|
856 |
a37753d7
|
Vinicius Coque
|
<td width="40%" class="listhdrr"><?=gettext("Distinguished Name");?></td>
|
857 |
d590fa20
|
jim-p
|
<td width="10%" class="listhdrr"><?=gettext("In Use");?></td>
|
858 |
96c7a492
|
Matthew Grooms
|
<td width="10%" class="list"></td>
|
859 |
64cc39d3
|
Matthew Grooms
|
</tr>
|
860 |
96c7a492
|
Matthew Grooms
|
<?php
|
861 |
|
|
$i = 0;
|
862 |
|
|
foreach($a_cert as $cert):
|
863 |
f2a86ca9
|
jim-p
|
$name = htmlspecialchars($cert['descr']);
|
864 |
a828210b
|
yakatz
|
|
865 |
96c7a492
|
Matthew Grooms
|
if ($cert['crt']) {
|
866 |
2cf6ddcb
|
Nigel Graham
|
$subj = cert_get_subject($cert['crt']);
|
867 |
|
|
$issuer = cert_get_issuer($cert['crt']);
|
868 |
|
|
if($subj==$issuer)
|
869 |
a37753d7
|
Vinicius Coque
|
$caname = "<em>" . gettext("self-signed") . "</em>";
|
870 |
2cf6ddcb
|
Nigel Graham
|
else
|
871 |
a37753d7
|
Vinicius Coque
|
$caname = "<em>" . gettext("external"). "</em>";
|
872 |
2cf6ddcb
|
Nigel Graham
|
$subj = htmlspecialchars($subj);
|
873 |
96c7a492
|
Matthew Grooms
|
}
|
874 |
|
|
|
875 |
|
|
if ($cert['csr']) {
|
876 |
|
|
$subj = htmlspecialchars(csr_get_subject($cert['csr']));
|
877 |
a37753d7
|
Vinicius Coque
|
$caname = "<em>" . gettext("external - signature pending") . "</em>";
|
878 |
96c7a492
|
Matthew Grooms
|
}
|
879 |
|
|
|
880 |
|
|
$ca = lookup_ca($cert['caref']);
|
881 |
|
|
if ($ca)
|
882 |
f2a86ca9
|
jim-p
|
$caname = $ca['descr'];
|
883 |
96c7a492
|
Matthew Grooms
|
|
884 |
|
|
if($cert['prv'])
|
885 |
|
|
$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
|
886 |
|
|
else
|
887 |
|
|
$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
|
888 |
|
|
?>
|
889 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
890 |
96c7a492
|
Matthew Grooms
|
<td class="listlr">
|
891 |
|
|
<table border="0" cellpadding="0" cellspacing="0">
|
892 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
893 |
96c7a492
|
Matthew Grooms
|
<td align="left" valign="center">
|
894 |
|
|
<img src="<?=$certimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
|
895 |
64cc39d3
|
Matthew Grooms
|
</td>
|
896 |
96c7a492
|
Matthew Grooms
|
<td align="left" valign="middle">
|
897 |
|
|
<?=$name;?>
|
898 |
64cc39d3
|
Matthew Grooms
|
</td>
|
899 |
|
|
</tr>
|
900 |
|
|
</table>
|
901 |
|
|
</td>
|
902 |
96c7a492
|
Matthew Grooms
|
<td class="listr"><?=$caname;?> </td>
|
903 |
|
|
<td class="listr"><?=$subj;?> </td>
|
904 |
d590fa20
|
jim-p
|
<td class="listr">
|
905 |
150bbe09
|
jim-p
|
<?php if (is_cert_revoked($cert)): ?>
|
906 |
|
|
<b>Revoked</b><br/>
|
907 |
|
|
<?php endif; ?>
|
908 |
d590fa20
|
jim-p
|
<?php if (is_webgui_cert($cert['refid'])): ?>
|
909 |
|
|
webConfigurator<br/>
|
910 |
|
|
<?php endif; ?>
|
911 |
|
|
<?php if (is_user_cert($cert['refid'])): ?>
|
912 |
|
|
User Cert<br/>
|
913 |
|
|
<?php endif; ?>
|
914 |
|
|
<?php if (is_openvpn_server_cert($cert['refid'])): ?>
|
915 |
|
|
OpenVPN Server<br/>
|
916 |
|
|
<?php endif; ?>
|
917 |
|
|
<?php if (is_openvpn_client_cert($cert['refid'])): ?>
|
918 |
|
|
OpenVPN Client<br/>
|
919 |
|
|
<?php endif; ?>
|
920 |
|
|
<?php if (is_ipsec_cert($cert['refid'])): ?>
|
921 |
|
|
IPsec Tunnel<br/>
|
922 |
|
|
<?php endif; ?>
|
923 |
|
|
</td>
|
924 |
96c7a492
|
Matthew Grooms
|
<td valign="middle" nowrap class="list">
|
925 |
ea53e38f
|
Renato Botelho
|
<a href="system_certmanager.php?act=exp&id=<?=$i;?>">
|
926 |
a37753d7
|
Vinicius Coque
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert");?>" alt="<?=gettext("export ca");?>" width="17" height="17" border="0" />
|
927 |
96c7a492
|
Matthew Grooms
|
</a>
|
928 |
ea53e38f
|
Renato Botelho
|
<a href="system_certmanager.php?act=key&id=<?=$i;?>">
|
929 |
a37753d7
|
Vinicius Coque
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export key");?>" alt="<?=gettext("export ca");?>" width="17" height="17" border="0" />
|
930 |
73fbece8
|
mgrooms
|
</a>
|
931 |
0879599c
|
jim-p
|
<?php if (!cert_in_use($cert['refid'])): ?>
|
932 |
a828210b
|
yakatz
|
<a href="system_certmanager.php?act=del&id=<?=$i;?>" onClick="return confirm('<?=gettext("Do you really want to delete this Certificate?");?>')">
|
933 |
a37753d7
|
Vinicius Coque
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete cert");?>" alt="<?=gettext("delete cert");?>" width="17" height="17" border="0" />
|
934 |
96c7a492
|
Matthew Grooms
|
</a>
|
935 |
0879599c
|
jim-p
|
<?php endif; ?>
|
936 |
96c7a492
|
Matthew Grooms
|
<?php if ($cert['csr']): ?>
|
937 |
|
|
|
938 |
|
|
<a href="system_certmanager.php?act=csr&id=<?=$i;?>">
|
939 |
a37753d7
|
Vinicius Coque
|
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("update csr");?>" alt="<?=gettext("update csr");?>" width="17" height="17" border="0" />
|
940 |
96c7a492
|
Matthew Grooms
|
</a>
|
941 |
|
|
<?php endif; ?>
|
942 |
64cc39d3
|
Matthew Grooms
|
</td>
|
943 |
|
|
</tr>
|
944 |
96c7a492
|
Matthew Grooms
|
<?php
|
945 |
|
|
$i++;
|
946 |
|
|
endforeach;
|
947 |
|
|
?>
|
948 |
64cc39d3
|
Matthew Grooms
|
<tr>
|
949 |
0879599c
|
jim-p
|
<td class="list" colspan="4"></td>
|
950 |
96c7a492
|
Matthew Grooms
|
<td class="list">
|
951 |
|
|
<a href="system_certmanager.php?act=new">
|
952 |
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" />
|
953 |
96c7a492
|
Matthew Grooms
|
</a>
|
954 |
64cc39d3
|
Matthew Grooms
|
</td>
|
955 |
|
|
</tr>
|
956 |
0879599c
|
jim-p
|
<tr>
|
957 |
|
|
<td> </td>
|
958 |
9338cf35
|
Warren Baker
|
<td colspan="3"><?=gettext("Note: You can only delete a certificate if it is not currently in use.");?></td>
|
959 |
0879599c
|
jim-p
|
</tr>
|
960 |
64cc39d3
|
Matthew Grooms
|
</table>
|
961 |
|
|
|
962 |
96c7a492
|
Matthew Grooms
|
<?php endif; ?>
|
963 |
64cc39d3
|
Matthew Grooms
|
|
964 |
96c7a492
|
Matthew Grooms
|
</div>
|
965 |
64cc39d3
|
Matthew Grooms
|
</td>
|
966 |
|
|
</tr>
|
967 |
|
|
</table>
|
968 |
|
|
<?php include("fend.inc");?>
|
969 |
|
|
<script type="text/javascript">
|
970 |
|
|
<!--
|
971 |
|
|
|
972 |
|
|
method_change();
|
973 |
|
|
internalca_change();
|
974 |
|
|
|
975 |
|
|
//-->
|
976 |
|
|
</script>
|
977 |
|
|
|
978 |
|
|
</body>
|