Project

General

Profile

Download (22.9 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	system_crlmanager.php
4

    
5
	Copyright (C) 2010 Jim Pingle
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	All rights reserved.
8

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

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

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

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

    
34
##|+PRIV
35
##|*IDENT=page-system-crlmanager
36
##|*NAME=System: CRL Manager
37
##|*DESCR=Allow access to the 'System: CRL Manager' page.
38
##|*MATCH=system_crlmanager.php*
39
##|-PRIV
40

    
41
require("guiconfig.inc");
42
require_once("certs.inc");
43
require_once('openvpn.inc');
44

    
45
global $openssl_crl_status;
46

    
47
$pgtitle = array(gettext("System"), gettext("Certificate Revocation List Manager"));
48

    
49
$crl_methods = array(
50
	"internal" => gettext("Create an internal Certificate Revocation List"),
51
	"existing" => gettext("Import an existing Certificate Revocation List"));
52

    
53
if (ctype_alnum($_GET['id'])) {
54
	$id = $_GET['id'];
55
}
56
if (isset($_POST['id']) && ctype_alnum($_POST['id'])) {
57
	$id = $_POST['id'];
58
}
59

    
60
if (!is_array($config['ca'])) {
61
	$config['ca'] = array();
62
}
63

    
64
$a_ca =& $config['ca'];
65

    
66
if (!is_array($config['cert'])) {
67
	$config['cert'] = array();
68
}
69

    
70
$a_cert =& $config['cert'];
71

    
72
if (!is_array($config['crl'])) {
73
	$config['crl'] = array();
74
}
75

    
76
$a_crl =& $config['crl'];
77

    
78
foreach ($a_crl as $cid => $acrl) {
79
	if (!isset($acrl['refid'])) {
80
		unset ($a_crl[$cid]);
81
	}
82
}
83

    
84
$act = $_GET['act'];
85
if ($_POST['act']) {
86
	$act = $_POST['act'];
87
}
88

    
89
if (!empty($id)) {
90
	$thiscrl =& lookup_crl($id);
91
}
92

    
93
// If we were given an invalid crlref in the id, no sense in continuing as it would only cause errors.
94
if (!$thiscrl && (($act != "") && ($act != "new"))) {
95
	pfSenseHeader("system_crlmanager.php");
96
	$act="";
97
	$savemsg = gettext("Invalid CRL reference.");
98
}
99

    
100
if ($act == "del") {
101
	$name = htmlspecialchars($thiscrl['descr']);
102
	if (crl_in_use($id)) {
103
		$savemsg = sprintf(gettext("Certificate Revocation List %s is in use and cannot be deleted"), $name) . "<br />";
104
	} else {
105
		foreach ($a_crl as $cid => $acrl) {
106
			if ($acrl['refid'] == $thiscrl['refid']) {
107
				unset($a_crl[$cid]);
108
			}
109
		}
110
		write_config("Deleted CRL {$name}.");
111
		$savemsg = sprintf(gettext("Certificate Revocation List %s successfully deleted"), $name) . "<br />";
112
	}
113
}
114

    
115
if ($act == "new") {
116
	$pconfig['method'] = $_GET['method'];
117
	$pconfig['caref'] = $_GET['caref'];
118
	$pconfig['lifetime'] = "9999";
119
	$pconfig['serial'] = "0";
120
}
121

    
122
if ($act == "exp") {
123
	crl_update($thiscrl);
124
	$exp_name = urlencode("{$thiscrl['descr']}.crl");
125
	$exp_data = base64_decode($thiscrl['text']);
126
	$exp_size = strlen($exp_data);
127

    
128
	header("Content-Type: application/octet-stream");
129
	header("Content-Disposition: attachment; filename={$exp_name}");
130
	header("Content-Length: $exp_size");
131
	echo $exp_data;
132
	exit;
133
}
134

    
135
if ($act == "addcert") {
136
	if ($_POST) {
137
		unset($input_errors);
138
		$pconfig = $_POST;
139

    
140
		if (!$pconfig['crlref'] || !$pconfig['certref']) {
141
			pfSenseHeader("system_crlmanager.php");
142
			exit;
143
		}
144

    
145
		// certref, crlref
146
		$crl =& lookup_crl($pconfig['crlref']);
147
		$cert = lookup_cert($pconfig['certref']);
148

    
149
		if (!$crl['caref'] || !$cert['caref']) {
150
			$input_errors[] = gettext("Both the Certificate and CRL must be specified.");
151
		}
152

    
153
		if ($crl['caref'] != $cert['caref']) {
154
			$input_errors[] = gettext("CA mismatch between the Certificate and CRL. Unable to Revoke.");
155
		}
156
		if (!is_crl_internal($crl)) {
157
			$input_errors[] = gettext("Cannot revoke certificates for an imported/external CRL.");
158
		}
159

    
160
		if (!$input_errors) {
161
			$reason = (empty($pconfig['crlreason'])) ? OCSP_REVOKED_STATUS_UNSPECIFIED : $pconfig['crlreason'];
162
			cert_revoke($cert, $crl, $reason);
163
			openvpn_refresh_crls();
164
			write_config("Revoked cert {$cert['descr']} in CRL {$crl['descr']}.");
165
			pfSenseHeader("system_crlmanager.php");
166
			exit;
167
		}
168
	}
169
}
170

    
171
if ($act == "delcert") {
172
	if (!is_array($thiscrl['cert'])) {
173
		pfSenseHeader("system_crlmanager.php");
174
		exit;
175
	}
176
	$found = false;
177
	foreach ($thiscrl['cert'] as $acert) {
178
		if ($acert['refid'] == $_GET['certref']) {
179
			$found = true;
180
			$thiscert = $acert;
181
		}
182
	}
183
	if (!$found) {
184
		pfSenseHeader("system_crlmanager.php");
185
		exit;
186
	}
187
	$certname = htmlspecialchars($thiscert['descr']);
188
	$crlname = htmlspecialchars($thiscrl['descr']);
189
	if (cert_unrevoke($thiscert, $thiscrl)) {
190
		$savemsg = sprintf(gettext("Deleted Certificate %s from CRL %s"), $certname, $crlname) . "<br />";
191
		openvpn_refresh_crls();
192
		write_config(sprintf(gettext("Deleted Certificate %s from CRL %s"), $certname, $crlname));
193
	} else {
194
		$savemsg = sprintf(gettext("Failed to delete Certificate %s from CRL %s"), $certname, $crlname) . "<br />";
195
	}
196
	$act="edit";
197
}
198

    
199
if ($_POST) {
200
	$input_errors = array();
201
	$pconfig = $_POST;
202

    
203
	/* input validation */
204
	if (($pconfig['method'] == "existing") || ($act == "editimported")) {
205
		$reqdfields = explode(" ", "descr crltext");
206
		$reqdfieldsn = array(
207
			gettext("Descriptive name"),
208
			gettext("Certificate Revocation List data"));
209
	}
210
	if ($pconfig['method'] == "internal") {
211
		$reqdfields = explode(" ", "descr caref");
212
		$reqdfieldsn = array(
213
			gettext("Descriptive name"),
214
			gettext("Certificate Authority"));
215
	}
216

    
217
	do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
218

    
219
	if (preg_match("/[\?\>\<\&\/\\\"\']/", $pconfig['descr'])) {
220
		array_push($input_errors, "The field 'Descriptive Name' contains invalid characters.");
221
	}
222

    
223
	/* if this is an AJAX caller then handle via JSON */
224
	if (isAjax() && is_array($input_errors)) {
225
		input_errors2Ajax($input_errors);
226
		exit;
227
	}
228

    
229
	/* save modifications */
230
	if (!$input_errors) {
231
		$result = false;
232

    
233
		if ($thiscrl) {
234
			$crl =& $thiscrl;
235
		} else {
236
			$crl = array();
237
			$crl['refid'] = uniqid();
238
		}
239

    
240
		$crl['descr'] = $pconfig['descr'];
241
		if ($act != "editimported") {
242
			$crl['caref'] = $pconfig['caref'];
243
			$crl['method'] = $pconfig['method'];
244
		}
245

    
246
		if (($pconfig['method'] == "existing") || ($act == "editimported")) {
247
			$crl['text'] = base64_encode($pconfig['crltext']);
248
		}
249

    
250
		if ($pconfig['method'] == "internal") {
251
			$crl['serial'] = empty($pconfig['serial']) ? 9999 : $pconfig['serial'];
252
			$crl['lifetime'] = empty($pconfig['lifetime']) ? 9999 : $pconfig['lifetime'];
253
			$crl['cert'] = array();
254
		}
255

    
256
		if (!$thiscrl) {
257
			$a_crl[] = $crl;
258
		}
259

    
260
		write_config("Saved CRL {$crl['descr']}");
261
		openvpn_refresh_crls();
262
		pfSenseHeader("system_crlmanager.php");
263
	}
264
}
265

    
266
include("head.inc");
267
?>
268

    
269
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>">
270
<?php include("fbegin.inc"); ?>
271
<script type="text/javascript">
272
//<![CDATA[
273

    
274
function method_change() {
275

    
276
	method = document.iform.method.value;
277

    
278
	switch (method) {
279
		case "internal":
280
			document.getElementById("existing").style.display="none";
281
			document.getElementById("internal").style.display="";
282
			break;
283
		case "existing":
284
			document.getElementById("existing").style.display="";
285
			document.getElementById("internal").style.display="none";
286
			break;
287
	}
288
}
289

    
290
//]]>
291
</script>
292
<?php
293
	if ($input_errors) {
294
		print_input_errors($input_errors);
295
	}
296
	if ($savemsg) {
297
		print_info_box($savemsg);
298
	}
299
?>
300
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="CRL manager">
301
	<tr>
302
		<td>
303
		<?php
304
			$tab_array = array();
305
			$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
306
			$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php");
307
			$tab_array[] = array(gettext("Certificate Revocation"), true, "system_crlmanager.php");
308
			display_top_tabs($tab_array);
309
		?>
310
		</td>
311
	</tr>
312
	<tr>
313
		<td id="mainarea">
314
			<div class="tabcont">
315

    
316
<?php
317
	if ($act == "new" || $act == gettext("Save") || $input_errors):
318
?>
319

    
320
				<form action="system_crlmanager.php" method="post" name="iform" id="iform">
321
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
322
						<?php if (!isset($id)): ?>
323
						<tr>
324
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
325
							<td width="78%" class="vtable">
326
								<select name='method' id='method' class="formselect" onchange='method_change()'>
327
								<?php
328
									$rowIndex = 0;
329
									foreach ($crl_methods as $method => $desc):
330
										if (($_GET['importonly'] == "yes") && ($method != "existing")) {
331
											continue;
332
										}
333
										$selected = "";
334
										if ($pconfig['method'] == $method) {
335
											$selected = "selected=\"selected\"";
336
										}
337
										$rowIndex++;
338
								?>
339
									<option value="<?=$method;?>" <?=$selected;?>><?=$desc;?></option>
340
								<?php
341
									endforeach;
342
									if ($rowIndex == 0) {
343
										echo "<option></option>";
344
									}
345
								?>
346
								</select>
347
							</td>
348
						</tr>
349
						<?php endif; ?>
350
						<tr>
351
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
352
							<td width="78%" class="vtable">
353
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
354
							</td>
355
						</tr>
356
						<tr>
357
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate Authority");?></td>
358
							<td width="78%" class="vtable">
359
								<select name='caref' id='caref' class="formselect">
360
								<?php
361
									$rowIndex = 0;
362
									foreach ($a_ca as $ca):
363
										$selected = "";
364
										if ($pconfig['caref'] == $ca['refid']) {
365
											$selected = "selected=\"selected\"";
366
										}
367
										$rowIndex++;
368
								?>
369
									<option value="<?=$ca['refid'];?>" <?=$selected;?>><?=htmlspecialchars($ca['descr']);?></option>
370
								<?php
371
									endforeach;
372
									if ($rowIndex == 0) {
373
										echo "<option></option>";
374
									}
375
								?>
376
								</select>
377
							</td>
378
						</tr>
379
					</table>
380

    
381
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing" summary="existing">
382
						<tr>
383
							<td colspan="2" class="list" height="12"></td>
384
						</tr>
385
						<tr>
386
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Existing Certificate Revocation List");?></td>
387
						</tr>
388

    
389
						<tr>
390
							<td width="22%" valign="top" class="vncellreq"><?=gettext("CRL data");?></td>
391
							<td width="78%" class="vtable">
392
								<textarea name="crltext" id="crltext" cols="65" rows="7" class="formfld_crl"><?=$pconfig['crltext'];?></textarea>
393
								<br />
394
								<?=gettext("Paste a Certificate Revocation List in X.509 CRL format here.");?>
395
							</td>
396
						</tr>
397
					</table>
398

    
399
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal" summary="internal">
400
						<tr>
401
							<td colspan="2" class="list" height="12"></td>
402
						</tr>
403
						<tr>
404
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate Revocation List");?></td>
405
						</tr>
406
						<tr>
407
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
408
							<td width="78%" class="vtable">
409
								<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
410
								<?=gettext("days");?><br />
411
								<?=gettext("Default: 9999");?>
412
							</td>
413
						</tr>
414
						<tr>
415
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Serial");?></td>
416
							<td width="78%" class="vtable">
417
								<input name="serial" type="text" class="formfld unknown" id="serial" size="5" value="<?=htmlspecialchars($pconfig['serial']);?>"/>
418
								<br />
419
								<?=gettext("Default: 0");?>
420
							</td>
421
						</tr>
422
					</table>
423

    
424
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="save">
425
						<tr>
426
							<td width="22%" valign="top">&nbsp;</td>
427
							<td width="78%">
428
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
429
								<?php if (isset($id) && $thiscrl): ?>
430
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
431
								<?php endif;?>
432
							</td>
433
						</tr>
434
					</table>
435
				</form>
436
<?php
437
	elseif ($act == "editimported"):
438
		$crl = $thiscrl;
439
?>
440
				<form action="system_crlmanager.php" method="post" name="iform" id="iform">
441
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="editimported" summary="import">
442
						<tr>
443
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Edit Imported Certificate Revocation List");?></td>
444
						</tr>
445
						<tr>
446
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
447
							<td width="78%" class="vtable">
448
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($crl['descr']);?>"/>
449
							</td>
450
						</tr>
451
						<tr>
452
							<td width="22%" valign="top" class="vncellreq"><?=gettext("CRL data");?></td>
453
							<td width="78%" class="vtable">
454
								<textarea name="crltext" id="crltext" cols="65" rows="7" class="formfld_crl"><?=base64_decode($crl['text']);?></textarea>
455
								<br />
456
								<?=gettext("Paste a Certificate Revocation List in X.509 CRL format here.");?></td>
457
							</td>
458
						</tr>
459
						<tr>
460
							<td width="22%" valign="top">&nbsp;</td>
461
							<td width="78%">
462
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
463
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
464
								<input name="act" type="hidden" value="editimported" />
465
							</td>
466
						</tr>
467
					</table>
468
				</form>
469

    
470
<?php
471
	elseif ($act == "edit"):
472
		$crl = $thiscrl;
473
?>
474
				<form action="system_crlmanager.php" method="post" name="iform" id="iform">
475
				<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="revoke">
476
					<thead>
477
					<tr>
478
						<th width="90%" class="listhdrr" colspan="3"><b><?php echo gettext("Currently Revoked Certificates for CRL") . ': ' . htmlspecialchars($crl['descr']); ?></b></th>
479
						<th width="10%" class="list"></th>
480
					</tr>
481
					<tr>
482
						<th width="30%" class="listhdrr"><b><?php echo gettext("Certificate Name")?></b></th>
483
						<th width="30%" class="listhdrr"><b><?php echo gettext("Revocation Reason")?></b></th>
484
						<th width="30%" class="listhdrr"><b><?php echo gettext("Revoked At")?></b></th>
485
						<th width="10%" class="list"></th>
486
					</tr>
487
					</thead>
488
					<tbody>
489
				<?php /* List Certs on CRL */
490
					if (!is_array($crl['cert']) || (count($crl['cert']) == 0)):
491
				?>
492
					<tr>
493
						<td class="listlr" colspan="3">
494
							&nbsp;&nbsp;&nbsp;&nbsp;<?php echo gettext("No Certificates Found for this CRL."); ?>
495
						</td>
496
						<td class="list">&nbsp;</td>
497
					</tr>
498
				<?php
499
					else:
500
						foreach ($crl['cert'] as $i => $cert):
501
							$name = htmlspecialchars($cert['descr']);
502
				 ?>
503
					<tr>
504
						<td class="listlr">
505
							<?php echo $name; ?>
506
						</td>
507
						<td class="listlr">
508
							<?php echo $openssl_crl_status[$cert["reason"]]; ?>
509
						</td>
510
						<td class="listlr">
511
							<?php echo date("D M j G:i:s T Y", $cert["revoke_time"]); ?>
512
						</td>
513
						<td class="list">
514
							<a href="system_crlmanager.php?act=delcert&amp;id=<?php echo $crl['refid']; ?>&amp;certref=<?php echo $cert['refid']; ?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate from the CRL?");?>')">
515
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("Delete this certificate from the CRL ");?>" alt="<?=gettext("Delete this certificate from the CRL ");?>" width="17" height="17" border="0" />
516
							</a>
517
						</td>
518
					</tr>
519
				<?php
520
						endforeach;
521
					endif;
522
				?>
523
				<?php /* Drop-down with other certs from this CA. */
524
					// Map Certs to CAs in one pass
525
					$ca_certs = array();
526
					foreach ($a_cert as $cert) {
527
						if ($cert['caref'] == $crl['caref']) {
528
							$ca_certs[] = $cert;
529
						}
530
					}
531
					if (count($ca_certs) == 0): ?>
532
					<tr>
533
						<td class="listlr" colspan="3">
534
							&nbsp;&nbsp;&nbsp;&nbsp;<?php echo gettext("No Certificates Found for this CA."); ?>
535
						</td>
536
						<td class="list">&nbsp;</td>
537
					</tr>
538
				<?php
539
					else:
540
				?>
541
					<tr>
542
						<td class="listlr" colspan="3" align="center">
543
							<b><?php echo gettext("Choose a Certificate to Revoke"); ?></b>:
544
							<select name='certref' id='certref' class="formselect">
545
				<?php	$rowIndex = 0;
546
						foreach ($ca_certs as $cert):
547
							$rowIndex++;
548
				?>
549
								<option value="<?=$cert['refid'];?>"><?=htmlspecialchars($cert['descr'])?></option>
550
				<?php
551
						endforeach;
552
						if ($rowIndex == 0) {
553
							echo "<option></option>";
554
						}
555
				?>
556
							</select>
557
							<b><?php echo gettext("Reason");?></b>:
558
							<select name='crlreason' id='crlreason' class="formselect">
559
				<?php	$rowIndex = 0;
560
						foreach ($openssl_crl_status as $code => $reason):
561
							$rowIndex++;
562
				?>
563
								<option value="<?= $code ?>"><?= htmlspecialchars($reason) ?></option>
564
				<?php
565
						endforeach;
566
						if ($rowIndex == 0) {
567
							echo "<option></option>";
568
						}
569
				?>
570
							</select>
571
							<input name="act" type="hidden" value="addcert" />
572
							<input name="crlref" type="hidden" value="<?=$crl['refid'];?>" />
573
							<input name="id" type="hidden" value="<?=$crl['refid'];?>" />
574
							<input id="submit" name="add" type="submit" class="formbtn" value="<?=gettext("Add"); ?>" />
575
						</td>
576
						<td class="list">&nbsp;</td>
577
					</tr>
578
				<?php
579
					endif;
580
				?>
581
					</tbody>
582
				</table>
583
				</form>
584
<?php
585
	else:
586
?>
587
				<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="ocpms">
588
					<thead>
589
					<tr>
590
						<td width="35%" class="listhdrr"><?=gettext("Name");?></td>
591
						<td width="10%" class="listhdrr"><?=gettext("Internal");?></td>
592
						<td width="35%" class="listhdrr"><?=gettext("Certificates");?></td>
593
						<td width="10%" class="listhdrr"><?=gettext("In Use");?></td>
594
						<td width="10%" class="list"></td>
595
					</tr>
596
					</thead>
597
					<tfoot>
598
					<tr>
599
						<td colspan="5">
600
							<p>
601
								<?=gettext("Additional Certificate Revocation Lists can be added here.");?>
602
							</p>
603
						</td>
604
					</tr>
605
					</tfoot>
606
					<tbody>
607
				<?php
608
					$caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
609
					// Map CRLs to CAs in one pass
610
					$ca_crl_map = array();
611
					foreach ($a_crl as $crl) {
612
						$ca_crl_map[$crl['caref']][] = $crl['refid'];
613
					}
614

    
615
					$i = 0;
616
					foreach ($a_ca as $ca):
617
						$name = htmlspecialchars($ca['descr']);
618

    
619
						if ($ca['prv']) {
620
							$cainternal = "YES";
621
						} else {
622
							$cainternal = "NO";
623
						}
624
				?>
625
					<tr>
626
						<td class="listlr" colspan="4">
627
							<table border="0" cellpadding="0" cellspacing="0" summary="icon">
628
								<tr>
629
									<td align="left" valign="middle">
630
										<img src="<?=$caimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
631
									</td>
632
									<td align="left" valign="middle">
633
										<?=$name;?>
634
									</td>
635
								</tr>
636
							</table>
637
						</td>
638
						<td class="list">
639
						<?php if ($cainternal == "YES"): ?>
640
							<a href="system_crlmanager.php?act=new&amp;caref=<?php echo $ca['refid']; ?>">
641
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?php printf(gettext("Add or Import CRL for %s"), htmlspecialchars($ca['descr']));?>" alt="<?=gettext("add crl");?>" width="17" height="17" border="0" />
642
							</a>
643
						<?php else: ?>
644
							<a href="system_crlmanager.php?act=new&amp;caref=<?php echo $ca['refid']; ?>&amp;importonly=yes">
645
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?php printf(gettext("Import CRL for %s"), htmlspecialchars($ca['descr']));?>" alt="<?=gettext("add crl");?>" width="17" height="17" border="0" />
646
							</a>
647
						<?php endif; ?>
648
						</td>
649
					</tr>
650
						<?php
651
						if (is_array($ca_crl_map[$ca['refid']])):
652
							foreach ($ca_crl_map[$ca['refid']] as $crl):
653
								$tmpcrl = lookup_crl($crl);
654
								$internal = is_crl_internal($tmpcrl);
655
								$inuse = crl_in_use($tmpcrl['refid']);
656
						?>
657
					<tr>
658
						<td class="listlr"><?php echo htmlspecialchars($tmpcrl['descr']); ?></td>
659
						<td class="listr"><?php echo ($internal) ? "YES" : "NO"; ?></td>
660
						<td class="listr"><?php echo ($internal) ? count($tmpcrl['cert']) : "Unknown (imported)"; ?></td>
661
						<td class="listr"><?php echo ($inuse) ? "YES" : "NO"; ?></td>
662
						<td valign="middle" class="list nowrap">
663
							<a href="system_crlmanager.php?act=exp&amp;id=<?=$tmpcrl['refid'];?>">
664
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("Export CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" alt="<?=gettext("Export CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" width="17" height="17" border="0" />
665
							</a>
666
							<?php if ($internal): ?>
667
							<a href="system_crlmanager.php?act=edit&amp;id=<?=$tmpcrl['refid'];?>">
668
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("Edit CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" alt="<?=gettext("Edit CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" width="17" height="17" border="0" />
669
							</a>
670
							<?php else: ?>
671
							<a href="system_crlmanager.php?act=editimported&amp;id=<?=$tmpcrl['refid'];?>">
672
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("Edit CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" alt="<?=gettext("Edit CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" width="17" height="17" border="0" />
673
							</a>
674
							<?php endif; ?>
675
							<?php if (!$inuse): ?>
676
							<a href="system_crlmanager.php?act=del&amp;id=<?=$tmpcrl['refid'];?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate Revocation List?") . ' (' . htmlspecialchars($tmpcrl['descr']) . ')';?>')">
677
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("Delete CRL") . " " . htmlspecialchars($tmpcrl['descr']);?>" alt="<?=gettext("Delete CRL") . " " . htmlspecialchars($tmpcrl['descr']); ?>" width="17" height="17" border="0" />
678
							</a>
679
							<?php endif; ?>
680
						</td>
681
					</tr>
682
						<?php
683
								$i++;
684
							endforeach;
685
						endif;
686
						?>
687
					<tr>
688
						<td colspan="5">&nbsp;</td>
689
					</tr>
690
				<?php
691
						$i++;
692
					endforeach;
693
				?>
694
					</tbody>
695
				</table>
696

    
697
<?php
698
	endif;
699
?>
700

    
701
			</div>
702
		</td>
703
	</tr>
704
</table>
705
<?php include("fend.inc");?>
706
<script type="text/javascript">
707
//<![CDATA[
708

    
709
method_change();
710

    
711
//]]>
712
</script>
713

    
714
</body>
715
</html>
(210-210/252)