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