mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Provide a useful error message to the user when there is no private CA with which to create a new user certificate. Fixes #7585
This commit is contained in:
parent
ec0736af25
commit
fc1913fef2
@ -106,6 +106,18 @@ if ($_POST['act'] == "deluser") {
|
||||
*/
|
||||
$pconfig['utype'] = "user";
|
||||
$pconfig['lifetime'] = 3650;
|
||||
|
||||
$nonPrvCas = array();
|
||||
if (is_array($config['ca']) && count($config['ca']) > 0) {
|
||||
foreach ($config['ca'] as $ca) {
|
||||
if (!$ca['prv']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nonPrvCas[ $ca['refid'] ] = $ca['descr'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['dellall'])) {
|
||||
@ -848,12 +860,20 @@ if ($act == "new" || $act == "edit" || $input_errors):
|
||||
|
||||
// ==== Button for adding user certificate ================================
|
||||
if ($act == 'new') {
|
||||
$section->addInput(new Form_Checkbox(
|
||||
'showcert',
|
||||
'Certificate',
|
||||
'Click to create a user certificate',
|
||||
false
|
||||
));
|
||||
if (count($nonPrvCas) > 0) {
|
||||
$section->addInput(new Form_Checkbox(
|
||||
'showcert',
|
||||
'Certificate',
|
||||
'Click to create a user certificate',
|
||||
false
|
||||
));
|
||||
} else {
|
||||
$section->addInput(new Form_StaticText(
|
||||
'Certificate',
|
||||
gettext('No private CAs found. A private CA is required to create a new user certificate. ' .
|
||||
'Save the user first to import an external certificate.')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
$form->add($section);
|
||||
@ -888,15 +908,6 @@ if ($act == "new" || $act == "edit" || $input_errors):
|
||||
$section = new Form_Section('Create Certificate for User');
|
||||
$section->addClass('cert-options');
|
||||
|
||||
$nonPrvCas = array();
|
||||
foreach ($config['ca'] as $ca) {
|
||||
if (!$ca['prv']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nonPrvCas[ $ca['refid'] ] = $ca['descr'];
|
||||
}
|
||||
|
||||
if (!empty($nonPrvCas)) {
|
||||
$section->addInput(new Form_Input(
|
||||
'name',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user