Revision 033c3ae8
Added by Steve Beaver over 3 years ago
src/usr/local/www/system_certmanager.php | ||
---|---|---|
33 | 33 |
require_once("certs.inc"); |
34 | 34 |
require_once("pfsense-utils.inc"); |
35 | 35 |
|
36 |
// Non-display functions moved to this include file for MVC |
|
37 |
require_once("system_certmanager.inc"); |
|
38 |
|
|
39 |
init_config_arr(array('ca')); |
|
40 |
$a_ca = &$config['ca']; |
|
41 |
|
|
36 | 42 |
$cert_methods = array( |
37 | 43 |
"internal" => gettext("Create an internal Certificate"), |
38 | 44 |
"import" => gettext("Import an existing Certificate"), |
... | ... | |
64 | 70 |
$a_user =& $config['system']['user']; |
65 | 71 |
} |
66 | 72 |
|
67 |
init_config_arr(array('ca')); |
|
68 |
$a_ca = &$config['ca']; |
|
69 |
|
|
70 |
init_config_arr(array('cert')); |
|
71 |
$a_cert = &$config['cert']; |
|
72 |
|
|
73 | 73 |
$internal_ca_count = 0; |
74 | 74 |
foreach ($a_ca as $ca) { |
75 | 75 |
if ($ca['prv']) { |
... | ... | |
745 | 745 |
|
746 | 746 |
$form->add($section); |
747 | 747 |
|
748 |
// Return an array containing the IDs od all CAs |
|
749 |
function list_cas() { |
|
750 |
global $a_ca; |
|
751 |
$allCas = array(); |
|
752 |
|
|
753 |
foreach ($a_ca as $ca) { |
|
754 |
if ($ca['prv']) { |
|
755 |
$allCas[$ca['refid']] = $ca['descr']; |
|
756 |
} |
|
757 |
} |
|
758 |
|
|
759 |
return $allCas; |
|
760 |
} |
|
761 |
|
|
762 |
// Return an array containing the IDs od all CSRs |
|
763 |
function list_csrs() { |
|
764 |
global $config; |
|
765 |
$allCsrs = array(); |
|
766 |
|
|
767 |
foreach ($config['cert'] as $cert) { |
|
768 |
if ($cert['csr']) { |
|
769 |
$allCsrs[$cert['refid']] = $cert['descr']; |
|
770 |
} |
|
771 |
} |
|
772 |
|
|
773 |
return ['new' => gettext('New CSR (Paste below)')] + $allCsrs; |
|
774 |
} |
|
775 |
|
|
776 | 748 |
$section = new Form_Section('Sign CSR'); |
777 | 749 |
$section->addClass('toggle-sign collapse'); |
778 | 750 |
|
... | ... | |
1369 | 1341 |
$pluginparams['type'] = 'certificates'; |
1370 | 1342 |
$pluginparams['event'] = 'used_certificates'; |
1371 | 1343 |
$certificates_used_by_packages = pkg_call_plugins('plugin_certificates', $pluginparams); |
1372 |
foreach ($a_cert as $cert): |
|
1373 |
if (!is_array($cert) || empty($cert)) { |
|
1374 |
continue; |
|
1375 |
} |
|
1376 |
$name = htmlspecialchars($cert['descr']); |
|
1377 |
if ($cert['crt']) { |
|
1378 |
$subj = cert_get_subject($cert['crt']); |
|
1379 |
$issuer = cert_get_issuer($cert['crt']); |
|
1380 |
$purpose = cert_get_purpose($cert['crt']); |
|
1381 |
|
|
1382 |
if ($subj == $issuer) { |
|
1383 |
$caname = '<i>'. gettext("self-signed") .'</i>'; |
|
1384 |
} else { |
|
1385 |
$caname = '<i>'. gettext("external").'</i>'; |
|
1386 |
} |
|
1387 | 1344 |
|
1388 |
$subj = htmlspecialchars(cert_escape_x509_chars($subj, true)); |
|
1389 |
} else { |
|
1390 |
$subj = ""; |
|
1391 |
$issuer = ""; |
|
1392 |
$purpose = ""; |
|
1393 |
$startdate = ""; |
|
1394 |
$enddate = ""; |
|
1395 |
$caname = "<em>" . gettext("private key only") . "</em>"; |
|
1396 |
} |
|
1397 |
|
|
1398 |
if ($cert['csr']) { |
|
1399 |
$subj = htmlspecialchars(cert_escape_x509_chars(csr_get_subject($cert['csr']), true)); |
|
1400 |
$caname = "<em>" . gettext("external - signature pending") . "</em>"; |
|
1401 |
} |
|
1402 |
|
|
1403 |
$ca = lookup_ca($cert['caref']); |
|
1404 |
if ($ca) { |
|
1405 |
$caname = $ca['descr']; |
|
1406 |
} |
|
1345 |
// Gather the data required to display a certificate table. The array returned includes: |
|
1346 |
// ['name'] |
|
1347 |
// ['subj'] |
|
1348 |
// ['issuer'] |
|
1349 |
// ['info'] (infoblock contents) |
|
1350 |
// ['dates'] |
|
1351 |
// ['refid'] |
|
1352 |
// ['csr'] |
|
1353 |
// ['prv'] |
|
1354 |
// ['inuse'] |
|
1355 |
$certs = getCertData(); |
|
1356 |
|
|
1357 |
foreach ($certs as $cert): |
|
1407 | 1358 |
?> |
1408 | 1359 |
<tr> |
1409 |
<td> |
|
1410 |
<?=$name?><br /> |
|
1411 |
<?php if ($cert['type']): ?> |
|
1412 |
<i><?=$cert_types[$cert['type']]?></i><br /> |
|
1413 |
<?php endif?> |
|
1414 |
<?php if (is_array($purpose)): ?> |
|
1415 |
CA: <b><?=$purpose['ca']?></b><br/> |
|
1416 |
<?=gettext("Server")?>: <b><?=$purpose['server']?></b><br/> |
|
1417 |
<?php endif?> |
|
1418 |
</td> |
|
1419 |
<td><?=$caname?></td> |
|
1420 |
<td> |
|
1421 |
<?=$subj?> |
|
1422 |
<?= cert_print_infoblock($cert); ?> |
|
1423 |
<?php cert_print_dates($cert);?> |
|
1424 |
</td> |
|
1425 |
<td> |
|
1426 |
<?php if (is_cert_revoked($cert)): ?> |
|
1427 |
<i><?=gettext("Revoked")?></i> |
|
1428 |
<?php endif?> |
|
1429 |
<?php if (is_webgui_cert($cert['refid'])): ?> |
|
1430 |
<?=gettext("webConfigurator")?> |
|
1431 |
<?php endif?> |
|
1432 |
<?php if (is_user_cert($cert['refid'])): ?> |
|
1433 |
<?=gettext("User Cert")?> |
|
1434 |
<?php endif?> |
|
1435 |
<?php if (is_openvpn_server_cert($cert['refid'])): ?> |
|
1436 |
<?=gettext("OpenVPN Server")?> |
|
1437 |
<?php endif?> |
|
1438 |
<?php if (is_openvpn_client_cert($cert['refid'])): ?> |
|
1439 |
<?=gettext("OpenVPN Client")?> |
|
1440 |
<?php endif?> |
|
1441 |
<?php if (is_ipsec_cert($cert['refid'])): ?> |
|
1442 |
<?=gettext("IPsec Tunnel")?> |
|
1443 |
<?php endif?> |
|
1444 |
<?php if (is_captiveportal_cert($cert['refid'])): ?> |
|
1445 |
<?=gettext("Captive Portal")?> |
|
1446 |
<?php endif?> |
|
1447 |
<?php if (is_unbound_cert($cert['refid'])): ?> |
|
1448 |
<?=gettext("DNS Resolver")?> |
|
1449 |
<?php endif?> |
|
1450 |
<?php echo cert_usedby_description($cert['refid'], $certificates_used_by_packages); ?> |
|
1360 |
<td> <?=$cert['name']; ?> </td> |
|
1361 |
<td> <?=$cert['issuer']; ?> </td> |
|
1362 |
<td> <?=$cert['subj']; ?> |
|
1363 |
<?php |
|
1364 |
if (!empty($cert['info'])) { |
|
1365 |
print('<div class="infoblock">'); |
|
1366 |
print_info_box($cert['info'], 'info', false); |
|
1367 |
print("</div>" . $cert['dates']); |
|
1368 |
} |
|
1369 |
?> |
|
1370 |
|
|
1451 | 1371 |
</td> |
1372 |
|
|
1373 |
<td> <?=$cert['inuse']; ?> </td> |
|
1374 |
|
|
1452 | 1375 |
<td> |
1453 | 1376 |
<?php if (!$cert['csr']): ?> |
1454 | 1377 |
<a href="system_certmanager.php?act=edit&id=<?=$cert['refid']?>" class="fa fa-pencil" title="<?=gettext("Edit Certificate")?>"></a> |
... | ... | |
1471 | 1394 |
</td> |
1472 | 1395 |
</tr> |
1473 | 1396 |
<?php |
1397 |
$idx++; |
|
1474 | 1398 |
endforeach; ?> |
1475 | 1399 |
</tbody> |
1476 | 1400 |
</table> |
... | ... | |
1537 | 1461 |
}); |
1538 | 1462 |
//]]> |
1539 | 1463 |
</script> |
1464 |
|
|
1540 | 1465 |
<?php |
1541 | 1466 |
include("foot.inc"); |
1542 | 1467 |
exit; |
Also available in: Unified diff
Certmanager mvc