Project

General

Profile

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