summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Beaver <sbeaver@netgate.com>2015-12-17 07:35:31 -0500
committerStephen Beaver <sbeaver@netgate.com>2015-12-17 07:35:31 -0500
commitf224c8a2576866f1a2d1a9574cdc586c4bfbdd35 (patch)
tree2fac3dd5de7d9ff48b6961d1c8fca94e2112316f
parent6b8cd448a4a130ea97b8d3214e7b603cd8f79950 (diff)
parent78863416b2047257c406a105546cd3bde79487ab (diff)
downloadpfsense-f224c8a2576866f1a2d1a9574cdc586c4bfbdd35.zip
pfsense-f224c8a2576866f1a2d1a9574cdc586c4bfbdd35.tar.gz
Merge pull request #2258 from phil-davis/r015
-rw-r--r--src/usr/local/www/system_camanager.php51
-rw-r--r--src/usr/local/www/system_certmanager.php82
-rw-r--r--src/usr/local/www/system_crlmanager.php66
3 files changed, 108 insertions, 91 deletions
diff --git a/src/usr/local/www/system_camanager.php b/src/usr/local/www/system_camanager.php
index 1cb7afb..b9e197d 100644
--- a/src/usr/local/www/system_camanager.php
+++ b/src/usr/local/www/system_camanager.php
@@ -317,8 +317,7 @@ if ($_POST) {
array_push($input_errors, "openssl library returns: " . $ssl_err);
}
}
- }
- else if ($pconfig['method'] == "intermediate") {
+ } else if ($pconfig['method'] == "intermediate") {
$dn = array(
'countryName' => $pconfig['dn_country'],
'stateOrProvinceName' => $pconfig['dn_state'],
@@ -353,17 +352,19 @@ if ($_POST) {
include("head.inc");
-if ($input_errors)
+if ($input_errors) {
print_input_errors($input_errors);
+}
-if ($savemsg)
+if ($savemsg) {
print_info_box($savemsg, 'success');
+}
// Load valid country codes
$dn_cc = array();
-if (file_exists("/etc/ca_countries")){
+if (file_exists("/etc/ca_countries")) {
$dn_cc_file=file("/etc/ca_countries");
- foreach($dn_cc_file as $line) {
+ foreach ($dn_cc_file as $line) {
if (preg_match('/^(\S*)\s(.*)$/', $line, $matches)) {
$dn_cc[$matches[1]] = $matches[1];
}
@@ -376,8 +377,7 @@ $tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php");
$tab_array[] = array(gettext("Certificate Revocation"), false, "system_crlmanager.php");
display_top_tabs($tab_array);
-if (!($act == "new" || $act == "edit" || $act == gettext("Save") || $input_errors))
-{
+if (!($act == "new" || $act == "edit" || $act == gettext("Save") || $input_errors)) {
?>
<div class="table-responsive">
<table class="table table-striped table-hover">
@@ -398,28 +398,34 @@ foreach ($a_ca as $i => $ca):
$subj = cert_get_subject($ca['crt']);
$issuer = cert_get_issuer($ca['crt']);
list($startdate, $enddate) = cert_get_dates($ca['crt']);
- if ($subj == $issuer)
+ if ($subj == $issuer) {
$issuer_name = gettext("self-signed");
- else
+ } else {
$issuer_name = gettext("external");
+ }
$subj = htmlspecialchars($subj);
$issuer = htmlspecialchars($issuer);
$certcount = 0;
$issuer_ca = lookup_ca($ca['caref']);
- if ($issuer_ca)
+ if ($issuer_ca) {
$issuer_name = $issuer_ca['descr'];
+ }
// TODO : Need gray certificate icon
$internal = (!!$ca['prv']);
- foreach ($a_cert as $cert)
- if ($cert['caref'] == $ca['refid'])
+ foreach ($a_cert as $cert) {
+ if ($cert['caref'] == $ca['refid']) {
$certcount++;
+ }
+ }
- foreach ($a_ca as $cert)
- if ($cert['caref'] == $ca['refid'])
+ foreach ($a_ca as $cert) {
+ if ($cert['caref'] == $ca['refid']) {
$certcount++;
+ }
+ }
?>
<tr>
<td><?=$name?></td>
@@ -459,8 +465,7 @@ foreach ($a_ca as $i => $ca):
$form = new Form;
//$form->setAction('system_camanager.php?act=edit');
-if (isset($id) && $a_ca[$id])
-{
+if (isset($id) && $a_ca[$id]) {
$form->addGlobal(new Form_Input(
'id',
null,
@@ -469,8 +474,7 @@ if (isset($id) && $a_ca[$id])
));
}
-if ($act == "edit")
-{
+if ($act == "edit") {
$form->addGlobal(new Form_Input(
'refid',
null,
@@ -488,8 +492,7 @@ $section->addInput(new Form_Input(
$pconfig['descr']
));
-if (!isset($id) || $act == "edit")
-{
+if (!isset($id) || $act == "edit") {
$section->addInput(new Form_Select(
'method',
'Method',
@@ -531,10 +534,10 @@ $section = new Form_Section('Internal Certificate Authority');
$section->addClass('toggle-internal', 'toggle-intermediate', 'collapse');
$allCas = array();
-foreach ($a_ca as $ca)
-{
- if (!$ca['prv'])
+foreach ($a_ca as $ca) {
+ if (!$ca['prv']) {
continue;
+ }
$allCas[ $ca['refid'] ] = $ca['descr'];
}
diff --git a/src/usr/local/www/system_certmanager.php b/src/usr/local/www/system_certmanager.php
index 4ecd624..9fa7e51 100644
--- a/src/usr/local/www/system_certmanager.php
+++ b/src/usr/local/www/system_certmanager.php
@@ -248,7 +248,7 @@ if ($act == "csr") {
if ($_POST) {
// This is just the blank altername name that is added for display purposes. We don't want to validate/save it
- if($_POST['altname_value0'] == "") {
+ if ($_POST['altname_value0'] == "") {
unset($_POST['altname_type0']);
unset($_POST['altname_value0']);
}
@@ -317,8 +317,7 @@ if ($_POST) {
if (!substr_compare('altname_type', $key, 0, 12)) {
$entry = substr($key, 12);
$field = 'type';
- }
- elseif (!substr_compare('altname_value', $key, 0, 13)) {
+ } elseif (!substr_compare('altname_value', $key, 0, 13)) {
$entry = substr($key, 13);
$field = 'value';
}
@@ -507,8 +506,8 @@ if ($_POST) {
/* input validation */
$reqdfields = explode(" ", "descr cert");
$reqdfieldsn = array(
- gettext("Descriptive name"),
- gettext("Final Certificate data"));
+ gettext("Descriptive name"),
+ gettext("Final Certificate data"));
do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
@@ -562,11 +561,13 @@ if ($_POST) {
include("head.inc");
-if ($input_errors)
+if ($input_errors) {
print_input_errors($input_errors);
+}
-if ($savemsg)
+if ($savemsg) {
print_info_box($savemsg, 'success');
+}
$tab_array = array();
$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
@@ -576,9 +577,9 @@ display_top_tabs($tab_array);
// Load valid country codes
$dn_cc = array();
-if (file_exists("/etc/ca_countries")){
+if (file_exists("/etc/ca_countries")) {
$dn_cc_file=file("/etc/ca_countries");
- foreach($dn_cc_file as $line) {
+ foreach ($dn_cc_file as $line) {
if (preg_match('/^(\S*)\s(.*)$/', $line, $matches)) {
$dn_cc[$matches[1]] = $matches[1];
}
@@ -588,14 +589,12 @@ if (file_exists("/etc/ca_countries")){
if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)) {
$form = new Form;
-if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors))
-{
+if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)) {
$form->setAction('system_certmanager.php?act=csr');
$section = new Form_Section('Complete Signing Request');
- if (isset($id) && $a_cert[$id])
- {
+ if (isset($id) && $a_cert[$id]) {
$form->addGlobal(new Form_Input(
'id',
null,
@@ -621,7 +620,7 @@ if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors))
$section->addInput(new Form_Textarea(
'cert',
'Final certificate data',
- $pconfig["cert"]
+ $pconfig['cert']
))->setHelp('Paste the certificate received from your certificate authority here.');
$form->add($section);
@@ -633,8 +632,7 @@ if ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors))
$form->setAction('system_certmanager.php?act=edit');
-if (isset($userid) && $a_user)
-{
+if (isset($userid) && $a_user) {
$form->addGlobal(new Form_Input(
'userid',
null,
@@ -643,8 +641,7 @@ if (isset($userid) && $a_user)
));
}
-if (isset($id) && $a_cert[$id])
-{
+if (isset($id) && $a_cert[$id]) {
$form->addGlobal(new Form_Input(
'id',
null,
@@ -655,8 +652,7 @@ if (isset($id) && $a_cert[$id])
$section = new Form_Section('Add a new certificate');
-if (!isset($id))
-{
+if (!isset($id)) {
$section->addInput(new Form_Select(
'method',
'Method',
@@ -692,22 +688,19 @@ $form->add($section);
$section = new Form_Section('Internal Certificate');
$section->addClass('toggle-internal collapse');
-if (!$internal_ca_count)
-{
+if (!$internal_ca_count) {
$section->addInput(new Form_StaticText(
'Certificate authority',
gettext('No internal Certificate Authorities have been defined. You must ').
'<a href="system_camanager.php?act=new&amp;method=internal"> '. gettext(" create") .'</a>'.
gettext(' an internal CA before creating an internal certificate.')
));
-}
-else
-{
+} else {
$allCas = array();
- foreach ($a_ca as $ca)
- {
- if (!$ca['prv'])
- continue;
+ foreach ($a_ca as $ca) {
+ if (!$ca['prv']) {
+ continue;
+ }
$allCas[ $ca['refid'] ] = $ca['descr'];
}
@@ -797,8 +790,7 @@ $section->addInput(new Form_Input(
['placeholder' => 'e.g. www.example.com']
));
-if (empty($pconfig['altnames']['item']))
-{
+if (empty($pconfig['altnames']['item'])) {
$pconfig['altnames']['item'] = array(
array('type' => null, 'value' => null)
);
@@ -920,19 +912,23 @@ $section->addClass('toggle-existing collapse');
$existCerts = array();
foreach ($config['cert'] as $cert) {
- if(is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA!
- if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert']))
+ if (is_array($config['system']['user'][$userid]['cert'])) { // Could be MIA!
+ if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert'])) {
continue;
+ }
}
$ca = lookup_ca($cert['caref']);
- if ($ca)
+ if ($ca) {
$cert['descr'] .= " (CA: {$ca['descr']})";
+ }
- if (cert_in_use($cert['refid']))
+ if (cert_in_use($cert['refid'])) {
$cert['descr'] .= " <i>In Use</i>";
- if (is_cert_revoked($cert))
+ }
+ if (is_cert_revoked($cert)) {
$cert['descr'] .= " <b>Revoked</b>";
+ }
$existCerts[ $cert['refid'] ] = $cert['descr'];
}
@@ -1011,7 +1007,7 @@ print $form;
</thead>
<tbody>
<?php
-foreach($a_cert as $i => $cert):
+foreach ($a_cert as $i => $cert):
$name = htmlspecialchars($cert['descr']);
if ($cert['crt']) {
@@ -1020,10 +1016,11 @@ foreach($a_cert as $i => $cert):
$purpose = cert_get_purpose($cert['crt']);
list($startdate, $enddate) = cert_get_dates($cert['crt']);
- if ($subj==$issuer)
+ if ($subj == $issuer) {
$caname = '<i>'. gettext("self-signed") .'</i>';
- else
+ } else {
$caname = '<i>'. gettext("external").'</i>';
+ }
$subj = htmlspecialchars($subj);
}
@@ -1034,8 +1031,9 @@ foreach($a_cert as $i => $cert):
}
$ca = lookup_ca($cert['caref']);
- if ($ca)
+ if ($ca) {
$caname = $ca['descr'];
+ }
?>
<tr>
<td>
@@ -1050,7 +1048,7 @@ foreach($a_cert as $i => $cert):
<td><?=$caname?></td>
<td>
<?=$subj?>
- <?php if (! $cert['csr']): ?>
+ <?php if (!$cert['csr']): ?>
<br />
<small>
<?=gettext("Valid From")?>: <b><?=$startdate ?></b><br /><?=gettext("Valid Until")?>: <b><?=$enddate ?></b>
@@ -1115,7 +1113,7 @@ foreach($a_cert as $i => $cert):
?>
<script type="text/javascript">
//<![CDATA[
-events.push(function(){
+events.push(function() {
<?php if ($internal_ca_count): ?>
function internalca_change() {
diff --git a/src/usr/local/www/system_crlmanager.php b/src/usr/local/www/system_crlmanager.php
index 46ffc95..437a3a9 100644
--- a/src/usr/local/www/system_crlmanager.php
+++ b/src/usr/local/www/system_crlmanager.php
@@ -324,9 +324,10 @@ function build_method_list() {
$list = array();
- foreach($crl_methods as $method => $desc) {
- if (($_GET['importonly'] == "yes") && ($method != "existing"))
+ foreach ($crl_methods as $method => $desc) {
+ if (($_GET['importonly'] == "yes") && ($method != "existing")) {
continue;
+ }
$list[$method] = $desc;
}
@@ -339,8 +340,9 @@ function build_ca_list() {
$list = array();
- foreach($a_ca as $ca)
+ foreach ($a_ca as $ca) {
$list[$ca['refid']] = $ca['descr'];
+ }
return($list);
}
@@ -350,17 +352,20 @@ function build_cacert_list() {
$list = array();
- foreach($ca_certs as $cert)
+ foreach($ca_certs as $cert) {
$list[$cert['refid']] = $cert['descr'];
+ }
return($list);
}
-if ($input_errors)
+if ($input_errors) {
print_input_errors($input_errors);
+}
-if ($savemsg)
+if ($savemsg) {
print_info_box($savemsg, 'sucess');
+}
$tab_array = array();
$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
@@ -489,9 +494,9 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
<div class="panel-heading"><h2 class="panel-title"><?=gettext("Currently Revoked Certificates for CRL") . ': ' . $crl['descr']?></h2></div>
<div class="panel-body table-responsive">
<?php
- if (!is_array($crl['cert']) || (count($crl['cert']) == 0))
+ if (!is_array($crl['cert']) || (count($crl['cert']) == 0)) {
print_info_box(gettext("No Certificates Found for this CRL."), 'danger');
- else {
+ } else {
?>
<table class="table table-striped table-hover table-condensed">
<thead>
@@ -504,7 +509,7 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
</thead>
<tbody>
<?php
- foreach($crl['cert'] as $i => $cert):
+ foreach ($crl['cert'] as $i => $cert):
$name = htmlspecialchars($cert['descr']);
?>
<tr>
@@ -534,9 +539,11 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
<?php
$ca_certs = array();
- foreach($a_cert as $cert)
- if ($cert['caref'] == $crl['caref'])
+ foreach ($a_cert as $cert) {
+ if ($cert['caref'] == $crl['caref']) {
$ca_certs[] = $cert;
+ }
+ }
if (count($ca_certs) == 0)
print_info_box(gettext("No Certificates Found for this CA."), 'danger');
@@ -609,17 +616,19 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
<?php
// Map CRLs to CAs in one pass
$ca_crl_map = array();
- foreach($a_crl as $crl)
+ foreach ($a_crl as $crl) {
$ca_crl_map[$crl['caref']][] = $crl['refid'];
+ }
$i = 0;
- foreach($a_ca as $ca):
+ foreach ($a_ca as $ca):
$name = htmlspecialchars($ca['descr']);
- if($ca['prv']) {
+ if ($ca['prv']) {
$cainternal = "YES";
- } else
+ } else {
$cainternal = "NO";
+ }
?>
<tr>
<td colspan="4">
@@ -627,22 +636,25 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
</td>
<td>
<?php
- if ($cainternal == "YES"): ?>
+ if ($cainternal == "YES"):
+?>
<a href="system_crlmanager.php?act=new&amp;caref=<?=$ca['refid']; ?>" class="btn btn-xs btn-success">
<?=gettext("Add or Import CRL")?>
</a>
<?php
- else: ?>
+ else:
+?>
<a href="system_crlmanager.php?act=new&amp;caref=<?=$ca['refid']; ?>&amp;importonly=yes" class="btn btn-xs btn-success">
<?=gettext("Add or Import CRL")?>
</a>
<?php
- endif; ?>
+ endif;
+?>
</td>
</tr>
<?php
if (is_array($ca_crl_map[$ca['refid']])):
- foreach($ca_crl_map[$ca['refid']] as $crl):
+ foreach ($ca_crl_map[$ca['refid']] as $crl):
$tmpcrl = lookup_crl($crl);
$internal = is_crl_internal($tmpcrl);
$inuse = crl_in_use($tmpcrl['refid']);
@@ -662,17 +674,20 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
<?=gettext("Edit CRL")?>
</a>
<?php
- else: ?>
+ else:
+?>
<a href="system_crlmanager.php?act=editimported&amp;id=<?=$tmpcrl['refid']?>" class="btn btn-xs btn-info">
<?=gettext("Edit CRL")?>
</a>
<?php endif;
- if (!$inuse): ?>
+ if (!$inuse):
+?>
<a href="system_crlmanager.php?act=del&amp;id=<?=$tmpcrl['refid']?>" class="btn btn-xs btn-danger">
<?=gettext("Delete CRL")?>
</a>
<?php
- endif; ?>
+ endif;
+?>
</td>
</tr>
<?php
@@ -694,14 +709,15 @@ if ($act == "new" || $act == gettext("Save") || $input_errors) {
<script>
//<![CDATA[
-events.push(function(){
+events.push(function() {
// Hides all elements of the specified class. This will usually be a section or group
function hideClass(s_class, hide) {
- if(hide)
+ if (hide) {
$('.' + s_class).hide();
- else
+ } else {
$('.' + s_class).show();
+ }
}
// When the 'method" selector is changed, we show/hide certain sections
OpenPOWER on IntegriCloud