1
|
<?php
|
2
|
/*
|
3
|
system_crlmanager.php
|
4
|
*/
|
5
|
/* ====================================================================
|
6
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7
|
*
|
8
|
* Redistribution and use in source and binary forms, with or without modification,
|
9
|
* 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
|
16
|
* the documentation and/or other materials provided with the
|
17
|
* distribution.
|
18
|
*
|
19
|
* 3. All advertising materials mentioning features or use of this software
|
20
|
* must display the following acknowledgment:
|
21
|
* "This product includes software developed by the pfSense Project
|
22
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
23
|
*
|
24
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
25
|
* endorse or promote products derived from this software without
|
26
|
* prior written permission. For written permission, please contact
|
27
|
* coreteam@pfsense.org.
|
28
|
*
|
29
|
* 5. Products derived from this software may not be called "pfSense"
|
30
|
* nor may "pfSense" appear in their names without prior written
|
31
|
* permission of the Electric Sheep Fencing, LLC.
|
32
|
*
|
33
|
* 6. Redistributions of any form whatsoever must retain the following
|
34
|
* acknowledgment:
|
35
|
*
|
36
|
* "This product includes software developed by the pfSense Project
|
37
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
38
|
*
|
39
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
40
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
41
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
43
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
44
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
45
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
46
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
48
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
49
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
50
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
51
|
*
|
52
|
* ====================================================================
|
53
|
*
|
54
|
*/
|
55
|
/*
|
56
|
pfSense_MODULE: certificate_manager
|
57
|
*/
|
58
|
|
59
|
##|+PRIV
|
60
|
##|*IDENT=page-system-crlmanager
|
61
|
##|*NAME=System: CRL Manager
|
62
|
##|*DESCR=Allow access to the 'System: CRL Manager' page.
|
63
|
##|*MATCH=system_crlmanager.php*
|
64
|
##|-PRIV
|
65
|
|
66
|
require("guiconfig.inc");
|
67
|
require_once("certs.inc");
|
68
|
require_once("openvpn.inc");
|
69
|
require_once("vpn.inc");
|
70
|
|
71
|
global $openssl_crl_status;
|
72
|
|
73
|
$pgtitle = array(gettext("System"), gettext("Certificate Revocation List Manager"));
|
74
|
|
75
|
$crl_methods = array(
|
76
|
"internal" => gettext("Create an internal Certificate Revocation List"),
|
77
|
"existing" => gettext("Import an existing Certificate Revocation List"));
|
78
|
|
79
|
if (ctype_alnum($_GET['id'])) {
|
80
|
$id = $_GET['id'];
|
81
|
}
|
82
|
if (isset($_POST['id']) && ctype_alnum($_POST['id'])) {
|
83
|
$id = $_POST['id'];
|
84
|
}
|
85
|
|
86
|
if (!is_array($config['ca'])) {
|
87
|
$config['ca'] = array();
|
88
|
}
|
89
|
|
90
|
$a_ca =& $config['ca'];
|
91
|
|
92
|
if (!is_array($config['cert'])) {
|
93
|
$config['cert'] = array();
|
94
|
}
|
95
|
|
96
|
$a_cert =& $config['cert'];
|
97
|
|
98
|
if (!is_array($config['crl'])) {
|
99
|
$config['crl'] = array();
|
100
|
}
|
101
|
|
102
|
$a_crl =& $config['crl'];
|
103
|
|
104
|
foreach ($a_crl as $cid => $acrl) {
|
105
|
if (!isset($acrl['refid'])) {
|
106
|
unset ($a_crl[$cid]);
|
107
|
}
|
108
|
}
|
109
|
|
110
|
$act = $_GET['act'];
|
111
|
if ($_POST['act']) {
|
112
|
$act = $_POST['act'];
|
113
|
}
|
114
|
|
115
|
if (!empty($id)) {
|
116
|
$thiscrl =& lookup_crl($id);
|
117
|
}
|
118
|
|
119
|
// If we were given an invalid crlref in the id, no sense in continuing as it would only cause errors.
|
120
|
if (!$thiscrl && (($act != "") && ($act != "new"))) {
|
121
|
pfSenseHeader("system_crlmanager.php");
|
122
|
$act="";
|
123
|
$savemsg = gettext("Invalid CRL reference.");
|
124
|
}
|
125
|
|
126
|
if ($act == "del") {
|
127
|
$name = htmlspecialchars($thiscrl['descr']);
|
128
|
if (crl_in_use($id)) {
|
129
|
$savemsg = sprintf(gettext("Certificate Revocation List %s is in use and cannot be deleted"), $name) . "<br />";
|
130
|
} else {
|
131
|
foreach ($a_crl as $cid => $acrl) {
|
132
|
if ($acrl['refid'] == $thiscrl['refid']) {
|
133
|
unset($a_crl[$cid]);
|
134
|
}
|
135
|
}
|
136
|
write_config("Deleted CRL {$name}.");
|
137
|
$savemsg = sprintf(gettext("Certificate Revocation List %s successfully deleted"), $name) . "<br />";
|
138
|
}
|
139
|
}
|
140
|
|
141
|
if ($act == "new") {
|
142
|
$pconfig['method'] = $_GET['method'];
|
143
|
$pconfig['caref'] = $_GET['caref'];
|
144
|
$pconfig['lifetime'] = "9999";
|
145
|
$pconfig['serial'] = "0";
|
146
|
}
|
147
|
|
148
|
if ($act == "exp") {
|
149
|
crl_update($thiscrl);
|
150
|
$exp_name = urlencode("{$thiscrl['descr']}.crl");
|
151
|
$exp_data = base64_decode($thiscrl['text']);
|
152
|
$exp_size = strlen($exp_data);
|
153
|
|
154
|
header("Content-Type: application/octet-stream");
|
155
|
header("Content-Disposition: attachment; filename={$exp_name}");
|
156
|
header("Content-Length: $exp_size");
|
157
|
echo $exp_data;
|
158
|
exit;
|
159
|
}
|
160
|
|
161
|
if ($act == "addcert") {
|
162
|
if ($_POST) {
|
163
|
unset($input_errors);
|
164
|
$pconfig = $_POST;
|
165
|
|
166
|
if (!$pconfig['crlref'] || !$pconfig['certref']) {
|
167
|
pfSenseHeader("system_crlmanager.php");
|
168
|
exit;
|
169
|
}
|
170
|
|
171
|
// certref, crlref
|
172
|
$crl =& lookup_crl($pconfig['crlref']);
|
173
|
$cert = lookup_cert($pconfig['certref']);
|
174
|
|
175
|
if (!$crl['caref'] || !$cert['caref']) {
|
176
|
$input_errors[] = gettext("Both the Certificate and CRL must be specified.");
|
177
|
}
|
178
|
|
179
|
if ($crl['caref'] != $cert['caref']) {
|
180
|
$input_errors[] = gettext("CA mismatch between the Certificate and CRL. Unable to Revoke.");
|
181
|
}
|
182
|
if (!is_crl_internal($crl)) {
|
183
|
$input_errors[] = gettext("Cannot revoke certificates for an imported/external CRL.");
|
184
|
}
|
185
|
|
186
|
if (!$input_errors) {
|
187
|
$reason = (empty($pconfig['crlreason'])) ? OCSP_REVOKED_STATUS_UNSPECIFIED : $pconfig['crlreason'];
|
188
|
cert_revoke($cert, $crl, $reason);
|
189
|
// refresh IPsec and OpenVPN CRLs
|
190
|
openvpn_refresh_crls();
|
191
|
vpn_ipsec_configure();
|
192
|
write_config("Revoked cert {$cert['descr']} in CRL {$crl['descr']}.");
|
193
|
pfSenseHeader("system_crlmanager.php");
|
194
|
exit;
|
195
|
}
|
196
|
}
|
197
|
}
|
198
|
|
199
|
if ($act == "delcert") {
|
200
|
if (!is_array($thiscrl['cert'])) {
|
201
|
pfSenseHeader("system_crlmanager.php");
|
202
|
exit;
|
203
|
}
|
204
|
$found = false;
|
205
|
foreach ($thiscrl['cert'] as $acert) {
|
206
|
if ($acert['refid'] == $_GET['certref']) {
|
207
|
$found = true;
|
208
|
$thiscert = $acert;
|
209
|
}
|
210
|
}
|
211
|
if (!$found) {
|
212
|
pfSenseHeader("system_crlmanager.php");
|
213
|
exit;
|
214
|
}
|
215
|
$certname = htmlspecialchars($thiscert['descr']);
|
216
|
$crlname = htmlspecialchars($thiscrl['descr']);
|
217
|
if (cert_unrevoke($thiscert, $thiscrl)) {
|
218
|
$savemsg = sprintf(gettext("Deleted Certificate %s from CRL %s"), $certname, $crlname) . "<br />";
|
219
|
// refresh IPsec and OpenVPN CRLs
|
220
|
openvpn_refresh_crls();
|
221
|
vpn_ipsec_configure();
|
222
|
write_config(sprintf(gettext("Deleted Certificate %s from CRL %s"), $certname, $crlname));
|
223
|
} else {
|
224
|
$savemsg = sprintf(gettext("Failed to delete Certificate %s from CRL %s"), $certname, $crlname) . "<br />";
|
225
|
}
|
226
|
$act="edit";
|
227
|
}
|
228
|
|
229
|
if ($_POST) {
|
230
|
$input_errors = array();
|
231
|
$pconfig = $_POST;
|
232
|
|
233
|
/* input validation */
|
234
|
if (($pconfig['method'] == "existing") || ($act == "editimported")) {
|
235
|
$reqdfields = explode(" ", "descr crltext");
|
236
|
$reqdfieldsn = array(
|
237
|
gettext("Descriptive name"),
|
238
|
gettext("Certificate Revocation List data"));
|
239
|
}
|
240
|
if ($pconfig['method'] == "internal") {
|
241
|
$reqdfields = explode(" ", "descr caref");
|
242
|
$reqdfieldsn = array(
|
243
|
gettext("Descriptive name"),
|
244
|
gettext("Certificate Authority"));
|
245
|
}
|
246
|
|
247
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
|
248
|
|
249
|
if (preg_match("/[\?\>\<\&\/\\\"\']/", $pconfig['descr'])) {
|
250
|
array_push($input_errors, "The field 'Descriptive Name' contains invalid characters.");
|
251
|
}
|
252
|
|
253
|
/* if this is an AJAX caller then handle via JSON */
|
254
|
if (isAjax() && is_array($input_errors)) {
|
255
|
input_errors2Ajax($input_errors);
|
256
|
exit;
|
257
|
}
|
258
|
|
259
|
/* save modifications */
|
260
|
if (!$input_errors) {
|
261
|
$result = false;
|
262
|
|
263
|
if ($thiscrl) {
|
264
|
$crl =& $thiscrl;
|
265
|
} else {
|
266
|
$crl = array();
|
267
|
$crl['refid'] = uniqid();
|
268
|
}
|
269
|
|
270
|
$crl['descr'] = $pconfig['descr'];
|
271
|
if ($act != "editimported") {
|
272
|
$crl['caref'] = $pconfig['caref'];
|
273
|
$crl['method'] = $pconfig['method'];
|
274
|
}
|
275
|
|
276
|
if (($pconfig['method'] == "existing") || ($act == "editimported")) {
|
277
|
$crl['text'] = base64_encode($pconfig['crltext']);
|
278
|
}
|
279
|
|
280
|
if ($pconfig['method'] == "internal") {
|
281
|
$crl['serial'] = empty($pconfig['serial']) ? 9999 : $pconfig['serial'];
|
282
|
$crl['lifetime'] = empty($pconfig['lifetime']) ? 9999 : $pconfig['lifetime'];
|
283
|
$crl['cert'] = array();
|
284
|
}
|
285
|
|
286
|
if (!$thiscrl) {
|
287
|
$a_crl[] = $crl;
|
288
|
}
|
289
|
|
290
|
write_config("Saved CRL {$crl['descr']}");
|
291
|
// refresh IPsec and OpenVPN CRLs
|
292
|
openvpn_refresh_crls();
|
293
|
vpn_ipsec_configure();
|
294
|
pfSenseHeader("system_crlmanager.php");
|
295
|
}
|
296
|
}
|
297
|
|
298
|
include("head.inc");
|
299
|
?>
|
300
|
|
301
|
<script type="text/javascript">
|
302
|
//<![CDATA[
|
303
|
|
304
|
function method_change() {
|
305
|
|
306
|
method = document.iform.method.value;
|
307
|
|
308
|
switch (method) {
|
309
|
case "internal":
|
310
|
document.getElementById("existing").style.display="none";
|
311
|
document.getElementById("internal").style.display="";
|
312
|
break;
|
313
|
case "existing":
|
314
|
document.getElementById("existing").style.display="";
|
315
|
document.getElementById("internal").style.display="none";
|
316
|
break;
|
317
|
}
|
318
|
}
|
319
|
|
320
|
//]]>
|
321
|
</script>
|
322
|
|
323
|
<?php
|
324
|
|
325
|
function build_method_list() {
|
326
|
global $_GET, $crl_methods;
|
327
|
|
328
|
$list = array();
|
329
|
|
330
|
foreach($crl_methods as $method => $desc) {
|
331
|
if (($_GET['importonly'] == "yes") && ($method != "existing"))
|
332
|
continue;
|
333
|
|
334
|
$list[$method] = $desc;
|
335
|
}
|
336
|
|
337
|
return($list);
|
338
|
}
|
339
|
|
340
|
function build_ca_list() {
|
341
|
global $a_ca;
|
342
|
|
343
|
$list = array();
|
344
|
|
345
|
foreach($a_ca as $ca)
|
346
|
$list[$ca['refid']] = $ca['descr'];
|
347
|
|
348
|
return($list);
|
349
|
}
|
350
|
|
351
|
function build_cacert_list() {
|
352
|
global $ca_certs;
|
353
|
|
354
|
$list = array();
|
355
|
|
356
|
foreach($ca_certs as $cert)
|
357
|
$list[$cert['refid']] = $cert['descr'];
|
358
|
|
359
|
return($list);
|
360
|
}
|
361
|
|
362
|
if ($input_errors)
|
363
|
print_input_errors($input_errors);
|
364
|
|
365
|
if ($savemsg)
|
366
|
print_info_box($savemsg, 'sucess');
|
367
|
|
368
|
$tab_array = array();
|
369
|
$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
|
370
|
$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php");
|
371
|
$tab_array[] = array(gettext("Certificate Revocation"), true, "system_crlmanager.php");
|
372
|
display_top_tabs($tab_array);
|
373
|
|
374
|
require_once('classes/Form.class.php');
|
375
|
|
376
|
if ($act == "new" || $act == gettext("Save") || $input_errors) {
|
377
|
if (!isset($id)) {
|
378
|
$form = new Form();
|
379
|
|
380
|
$section = new Form_Section('Create new revocation list');
|
381
|
|
382
|
$section->addInput(new Form_Select(
|
383
|
'method',
|
384
|
'Method',
|
385
|
$pconfig['method'],
|
386
|
build_method_list()
|
387
|
));
|
388
|
|
389
|
}
|
390
|
|
391
|
$section->addInput(new Form_Input(
|
392
|
'descr',
|
393
|
'Descriptive name',
|
394
|
'text',
|
395
|
$pconfig['descr']
|
396
|
));
|
397
|
|
398
|
$section->addInput(new Form_Select(
|
399
|
'caref',
|
400
|
'Certificate Authority',
|
401
|
$pconfig['caref'],
|
402
|
build_ca_list()
|
403
|
));
|
404
|
|
405
|
$form->add($section);
|
406
|
|
407
|
$section = new Form_Section('Existing Certificate Revocation List');
|
408
|
$section->addClass('existing');
|
409
|
|
410
|
$section->addInput(new Form_Textarea(
|
411
|
'crltext',
|
412
|
'CRL data',
|
413
|
$pconfig['crltext']
|
414
|
))->setHelp('Paste a Certificate Revocation List in X.509 CRL format here.');
|
415
|
|
416
|
$form->add($section);
|
417
|
|
418
|
$section = new Form_Section('Internal Certificate Revocation List');
|
419
|
$section->addClass('internal');
|
420
|
|
421
|
$section->addInput(new Form_Input(
|
422
|
'lifetime',
|
423
|
'Lifetime (Days)',
|
424
|
'number',
|
425
|
$pconfig['lifetime'],
|
426
|
[max => '9999']
|
427
|
));
|
428
|
|
429
|
$section->addInput(new Form_Input(
|
430
|
'serial',
|
431
|
'Serial',
|
432
|
'number',
|
433
|
$pconfig['serial'],
|
434
|
[min => '0', max => '9999']
|
435
|
));
|
436
|
|
437
|
$form->add($section);
|
438
|
|
439
|
if (isset($id) && $thiscrl) {
|
440
|
$section->addInput(new Form_Input(
|
441
|
'id',
|
442
|
null,
|
443
|
'hidden',
|
444
|
$id
|
445
|
));
|
446
|
}
|
447
|
|
448
|
print($form);
|
449
|
|
450
|
} elseif ($act == "editimported") {
|
451
|
|
452
|
$form = new Form();
|
453
|
|
454
|
$section = new Form_Section('Edit Imported Certificate Revocation List');
|
455
|
|
456
|
$section->addInput(new Form_Input(
|
457
|
'descr',
|
458
|
'Descriptive name',
|
459
|
'text',
|
460
|
$pconfig['descr']
|
461
|
));
|
462
|
|
463
|
$section->addInput(new Form_Textarea(
|
464
|
'crltext',
|
465
|
'CRL data',
|
466
|
$pconfig['crltext']
|
467
|
))->setHelp('Paste a Certificate Revocation List in X.509 CRL format here.');
|
468
|
|
469
|
$section->addInput(new Form_Input(
|
470
|
'id',
|
471
|
null,
|
472
|
'hidden',
|
473
|
$id
|
474
|
));
|
475
|
|
476
|
$section->addInput(new Form_Input(
|
477
|
'act',
|
478
|
null,
|
479
|
'hidden',
|
480
|
'editimported'
|
481
|
));
|
482
|
|
483
|
$form->add($section);
|
484
|
|
485
|
print($form);
|
486
|
|
487
|
} elseif ($act == "edit") {
|
488
|
$crl = $thiscrl;
|
489
|
|
490
|
$form = new Form(false);
|
491
|
?>
|
492
|
|
493
|
<div class="panel panel-default">
|
494
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Currently Revoked Certificates for CRL") . ': ' . $crl['descr']?></h2></div>
|
495
|
<div class="panel-body table-responsive">
|
496
|
<?php
|
497
|
if (!is_array($crl['cert']) || (count($crl['cert']) == 0))
|
498
|
print_info_box(gettext("No Certificates Found for this CRL."), 'danger');
|
499
|
else {
|
500
|
?>
|
501
|
<table class="table table-striped table-hover table-condensed">
|
502
|
<thead>
|
503
|
<tr>
|
504
|
<th><?=gettext("Certificate Name")?></th>
|
505
|
<th><?=gettext("Revocation Reason")?></th>
|
506
|
<th><?=gettext("Revoked At")?></th>
|
507
|
<th></th>
|
508
|
</tr>
|
509
|
</thead>
|
510
|
<tbody>
|
511
|
<?php
|
512
|
foreach($crl['cert'] as $i => $cert):
|
513
|
$name = htmlspecialchars($cert['descr']);
|
514
|
?>
|
515
|
<tr>
|
516
|
<td class="listlr">
|
517
|
<?=$name; ?>
|
518
|
</td>
|
519
|
<td class="listlr">
|
520
|
<?=$openssl_crl_status[$cert["reason"]]; ?>
|
521
|
</td>
|
522
|
<td class="listlr">
|
523
|
<?=date("D M j G:i:s T Y", $cert["revoke_time"]); ?>
|
524
|
</td>
|
525
|
<td class="list">
|
526
|
<a href="system_crlmanager.php?act=delcert&id=<?=$crl['refid']; ?>&certref=<?=$cert['refid']; ?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate from the CRL?")?>')">
|
527
|
<i class="icon-large icon-remove-sign" title="<?=gettext("Delete this certificate from the CRL ")?>" alt="<?=gettext("Delete this certificate from the CRL ")?>"></i>
|
528
|
</a>
|
529
|
</td>
|
530
|
</tr>
|
531
|
<?php
|
532
|
endforeach;
|
533
|
?>
|
534
|
</tbody>
|
535
|
</table>
|
536
|
<?php } ?>
|
537
|
</div>
|
538
|
</div>
|
539
|
<?php
|
540
|
|
541
|
$ca_certs = array();
|
542
|
foreach($a_cert as $cert)
|
543
|
if ($cert['caref'] == $crl['caref'])
|
544
|
$ca_certs[] = $cert;
|
545
|
|
546
|
if (count($ca_certs) == 0)
|
547
|
print_info_box(gettext("No Certificates Found for this CA."), 'danger');
|
548
|
else
|
549
|
|
550
|
$section = new Form_Section('Choose a certificate to revoke');
|
551
|
$group = new Form_Group(null);
|
552
|
|
553
|
$group->add(new Form_Select(
|
554
|
'certref',
|
555
|
null,
|
556
|
$pconfig['certref'],
|
557
|
build_cacert_list()
|
558
|
))->setWidth(4)->setHelp('Certificate');
|
559
|
|
560
|
$group->add(new Form_Select(
|
561
|
'crlreason',
|
562
|
null,
|
563
|
-1,
|
564
|
$openssl_crl_status
|
565
|
))->setHelp('Reason');
|
566
|
|
567
|
$group->add(new Form_Button(
|
568
|
'submit',
|
569
|
'Add'
|
570
|
))->removeClass('btn-primary')->addClass('btn-success btn-sm');
|
571
|
|
572
|
$section->add($group);
|
573
|
|
574
|
$section->addInput(new Form_Input(
|
575
|
'id',
|
576
|
null,
|
577
|
'hidden',
|
578
|
$crl['refid']
|
579
|
));
|
580
|
|
581
|
$section->addInput(new Form_Input(
|
582
|
'act',
|
583
|
null,
|
584
|
'hidden',
|
585
|
'addcert'
|
586
|
));
|
587
|
|
588
|
$section->addInput(new Form_Input(
|
589
|
'crlref',
|
590
|
null,
|
591
|
'hidden',
|
592
|
$crl['refid']
|
593
|
));
|
594
|
|
595
|
$form->add($section);
|
596
|
print($form);
|
597
|
} else {
|
598
|
?>
|
599
|
|
600
|
<div class="panel panel-default">
|
601
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Additional Certificate Revocation Lists")?></h2></div>
|
602
|
<div class="panel-body table-responsive">
|
603
|
<table class="table table-striped table-hover table-condensed">
|
604
|
<thead>
|
605
|
<tr>
|
606
|
<th><?=gettext("Name")?></th>
|
607
|
<th><?=gettext("Internal")?></th>
|
608
|
<th><?=gettext("Certificates")?></th>
|
609
|
<th><?=gettext("In Use")?></th>
|
610
|
<th></th>
|
611
|
</tr>
|
612
|
</thead>
|
613
|
<tbody>
|
614
|
<?php
|
615
|
// Map CRLs to CAs in one pass
|
616
|
$ca_crl_map = array();
|
617
|
foreach($a_crl as $crl)
|
618
|
$ca_crl_map[$crl['caref']][] = $crl['refid'];
|
619
|
|
620
|
$i = 0;
|
621
|
foreach($a_ca as $ca):
|
622
|
$name = htmlspecialchars($ca['descr']);
|
623
|
|
624
|
if($ca['prv']) {
|
625
|
$cainternal = "YES";
|
626
|
} else
|
627
|
$cainternal = "NO";
|
628
|
?>
|
629
|
<tr>
|
630
|
<td colspan="4">
|
631
|
<?=$name?>
|
632
|
</td>
|
633
|
<td>
|
634
|
<?php
|
635
|
if ($cainternal == "YES"): ?>
|
636
|
<a href="system_crlmanager.php?act=new&caref=<?=$ca['refid']; ?>" class="btn btn-xs btn-success">
|
637
|
<?=gettext("Add or Import CRL")?>
|
638
|
</a>
|
639
|
<?php
|
640
|
else: ?>
|
641
|
<a href="system_crlmanager.php?act=new&caref=<?=$ca['refid']; ?>&importonly=yes" class="btn btn-xs btn-success">
|
642
|
<?=gettext("Add or Import CRL")?>
|
643
|
</a>
|
644
|
<?php
|
645
|
endif; ?>
|
646
|
</td>
|
647
|
</tr>
|
648
|
<?php
|
649
|
if (is_array($ca_crl_map[$ca['refid']])):
|
650
|
foreach($ca_crl_map[$ca['refid']] as $crl):
|
651
|
$tmpcrl = lookup_crl($crl);
|
652
|
$internal = is_crl_internal($tmpcrl);
|
653
|
$inuse = crl_in_use($tmpcrl['refid']);
|
654
|
?>
|
655
|
<tr>
|
656
|
<td><?=$tmpcrl['descr']; ?></td>
|
657
|
<td><?=($internal) ? "YES" : "NO"; ?></td>
|
658
|
<td><?=($internal) ? count($tmpcrl['cert']) : "Unknown (imported)"; ?></td>
|
659
|
<td><?=($inuse) ? "YES" : "NO"; ?></td>
|
660
|
<td>
|
661
|
<a href="system_crlmanager.php?act=exp&id=<?=$tmpcrl['refid']?>" class="btn btn-xs btn-success">
|
662
|
<?=gettext("Export CRL")?>
|
663
|
</a>
|
664
|
<?php
|
665
|
if ($internal): ?>
|
666
|
<a href="system_crlmanager.php?act=edit&id=<?=$tmpcrl['refid']?>" class="btn btn-xs btn-info">
|
667
|
<?=gettext("Edit CRL")?>
|
668
|
</a>
|
669
|
<?php
|
670
|
else: ?>
|
671
|
<a href="system_crlmanager.php?act=editimported&id=<?=$tmpcrl['refid']?>" class="btn btn-xs btn-info">
|
672
|
<?=gettext("Edit CRL")?>
|
673
|
</a>
|
674
|
<?php endif;
|
675
|
if (!$inuse): ?>
|
676
|
<a href="system_crlmanager.php?act=del&id=<?=$tmpcrl['refid']?>" class="btn btn-xs btn-danger">
|
677
|
<?=gettext("Delete CRL")?>
|
678
|
</a>
|
679
|
<?php
|
680
|
endif; ?>
|
681
|
</td>
|
682
|
</tr>
|
683
|
<?php
|
684
|
$i++;
|
685
|
endforeach;
|
686
|
endif;
|
687
|
$i++;
|
688
|
endforeach;
|
689
|
?>
|
690
|
</tbody>
|
691
|
</table>
|
692
|
</div>
|
693
|
</div>
|
694
|
|
695
|
|
696
|
<?php
|
697
|
}
|
698
|
?>
|
699
|
|
700
|
<script>
|
701
|
//<![CDATA[
|
702
|
events.push(function(){
|
703
|
|
704
|
// Hides all elements of the specified class. This will usually be a section or group
|
705
|
function hideClass(s_class, hide) {
|
706
|
if(hide)
|
707
|
$('.' + s_class).hide();
|
708
|
else
|
709
|
$('.' + s_class).show();
|
710
|
}
|
711
|
|
712
|
// When the 'method" selector is changed, we show/hide certain sections
|
713
|
$('#method').on('change', function() {
|
714
|
hideClass('internal', ($('#method').val() == 'existing'));
|
715
|
hideClass('existing', ($('#method').val() == 'internal'));
|
716
|
});
|
717
|
|
718
|
hideClass('internal', ($('#method').val() == 'existing'));
|
719
|
hideClass('existing', ($('#method').val() == 'internal'));
|
720
|
});
|
721
|
//]]>
|
722
|
</script>
|
723
|
|
724
|
<?php include("foot.inc");
|
725
|
|