Skip to content

Commit

Permalink
fixed certificate details output
Browse files Browse the repository at this point in the history
  • Loading branch information
majagw committed May 15, 2024
1 parent 76c21d4 commit ea18cf5
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
10 changes: 6 additions & 4 deletions core/diag/RADIUSTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ private function checkLineparse($inputarray, $desiredCheck) {
switch ($desiredCheck) {
case self::LINEPARSE_TLSVERSION:
$version = [];
if (preg_match("/Using TLS version (.*)$/", $inputarray[$counter], $version)) {
if (isset($inputarray[$counter]) && preg_match("/Using TLS version (.*)$/", $inputarray[$counter], $version)) {
switch (trim($version[1])) {
case self::TLS_VERSION_1_3:
return self::TLS_VERSION_1_3;
Expand Down Expand Up @@ -739,7 +739,6 @@ private function createCArepository($tmpDir, &$intermOdditiesCAT, $servercert, $
private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir, $servercert, $eapIntermediates, $eapIntermediateCRLs) {

$crlCheckString = $this->createCArepository($tmpDir, $intermOdditiesCAT, $servercert, $eapIntermediates, $eapIntermediateCRLs);

// ... and run the verification test
$verifyResultEaponly = [];
$verifyResultAllcerts = [];
Expand Down Expand Up @@ -772,6 +771,7 @@ private function thoroughChainChecks(&$testresults, &$intermOdditiesCAT, $tmpDir
if (count($verifyResultAllcerts) == 0 || count($verifyResultEaponly) == 0) {
throw new Exception("No output at all from openssl?");
}
$testresults['cert_oddities'] = array();
if (!preg_match("/OK$/", $verifyResultAllcerts[0])) { // case 1
if (preg_match("/certificate revoked$/", $verifyResultAllcerts[1])) {
$testresults['cert_oddities'][] = RADIUSTests::CERTPROB_SERVER_CERT_REVOKED;
Expand Down Expand Up @@ -1356,8 +1356,10 @@ public function consolidateUdpResult($host) {
$o = [];
$o['code'] = $oddity;
$o['message'] = isset($this->returnCodes[$oddity]["message"]) && $this->returnCodes[$oddity]["message"] ? $this->returnCodes[$oddity]["message"] : $oddity;
$o['level'] = $this->returnCodes[$oddity]["severity"];
$ret['level'] = max($ret['level'], $this->returnCodes[$oddity]["severity"]);
if (isset($this->returnCodes[$oddity]['severity'])) {
$o['level'] = $this->returnCodes[$oddity]["severity"];
$ret['level'] = max($ret['level'], $this->returnCodes[$oddity]["severity"]);
}
$ret['cert_oddities'][] = $o;
}
\core\common\Entity::outOfThePotatoes();
Expand Down
46 changes: 23 additions & 23 deletions core/diag/RADIUSTestsUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,42 +317,42 @@ public function printStatic()
$hostindex = $udp->hostindex;
$result = $udp->result[0];
$out[] = '<hr>';
$out[] = '<strong>'.sprintf(_("Testing from: %s"), \config\Diagnostics::RADIUSTESTS['UDP-hosts'][$hostindex]['display_name']).'</strong>';
$out[] = sprintf(_("Testing from: <strong>%s"), \config\Diagnostics::RADIUSTESTS['UDP-hosts'][$hostindex]['display_name']).'</strong>';
$out[] = '<ul style="list-style-type: none;"><li>';
$out[] = "<table id='results$hostindex' style='width:100%' class='udp_results'>
<tr>
<td class='icon_td'><img src='".$this->stateIcons[$result->level]."' id='src".$hostindex."_img'></td>
<td id='src$hostindex' colspan=2>
";
$out[] = '<strong>'.($result->server ? $result->server : _("Connected to undetermined server")).'</strong><br/>'.sprintf (_("elapsed time: %sms."), $result->time_millisec).'<p>'.$result->message.'</p>';
$out[] = '<strong>'.($result->server ? $result->server : _("Connected to undetermined server")).'</strong><br/>'.sprintf (_("elapsed time: %sms."), $result->time_millisec).'<div>'.$result->message.'</div>';

if ($result->level > \core\common\Entity::L_OK && property_exists($result, 'cert_oddities')) {
foreach ($result->cert_oddities as $oddities) {
$out[] = '<tr class="results_tr"><td>&nbsp;</td><td class="icon_td"><img src="'.$this->stateIcons[$oddities->level].'"></td><td>'.$oddities->message.'</td></tr>';
}
}
$cert_data = '';
foreach ($result->server_cert as $sckey => $sc) {
if (array_key_exists($sckey, $this->certFields)) {
$cert_data .= '<dt>'.$this->certFields[$sckey].'</dt><dd>'.$sc.'</dd>';
$more = '';
if ($result->server_cert) {
$more .= '<div class="more">';
$certdesc = '<br>'.$this->certFields['title'].'<ul>';
foreach ($result->server_cert as $sckey => $sc) {
if (array_key_exists($sckey, $this->certFields)) {
$certdesc .= '<li>'.$this->certFields[$sckey].' '.$sc;
}
}
}
$out[] = "<tr class='server_cert' style='display: ";
$out[] = ($result->server_cert ? 'table-row_id' : 'none').";'><td>&nbsp;</td><td colspan=2><div><dl class='server_cert_list' style='display: none;'>";
$out[] = $cert_data;

$ext = '';
foreach ($result->server_cert->extensions as $extkey => $extval) {
if ($ext) {
$ext .= '<br>';
if ($result->server_cert->extensions) {
$certdesc .= '<li>' . _('Extensions') . '<ul>';
foreach ($result->server_cert->extensions as $ekey => $eval) {
$certdesc .= '<li>' . $ekey . ': ' . $eval;
}
$certdesc .= '</ul>';
}
$ext .= '<strong>'.$extkey.': </strong>'.'<i>'.$extval.'</i>';
}
if ($ext != '') {
$out[] = '<dt>'._('Extensions').'</dt></dd><dd>'.$ext.'</dd>';
}
$out[] = "</dl><a href='' class='morelink'>"._("show server certificate details")."&raquo;</a></div></tr>";

$out[] = "</td></tr></table>";
$certdesc .= '</ul>';
$more .= '<span class="morecontent"><span>'.$certdesc.
'</span>&nbsp;&nbsp;<a href="" class="morelink">'._("show server certificate details").'&raquo;</a></span></td></tr>';
$out[] = $more . '</ul>';
}
$out[] = "</td></tr></table></ul>";
}
$out[] = '</fieldset>';
return join('', $out);
Expand Down
16 changes: 10 additions & 6 deletions web/diag/action_realmcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,16 @@ function clients(data, status) {
state = notaccepted + ': ' + data.ca[key].certificate[c].resultcomment;
}
}
cliinfo = cliinfo + '<li><table><tbody><tr><td class="icon_td"><img class="icon" src="' + icons[level] + '" style="width: 24px;"></td><td>' + state;
cliinfo = cliinfo + ' <?php echo "(" . sprintf(_("elapsed time: %sms."), "'+data.ca[key].certificate[c].time_millisec+'&nbsp;") . ")"; ?>' + add + '</td></tr>';
cliinfo = cliinfo + '</tbody></table></ul></li>';

cliinfo = cliinfo + '<li>';
if (data.ca[key].certificate[c].finalerror && data.ca[key].certificate[c].finalerror==2) {
cliinfo = cliinfo + ' <?php echo _("this test was skipped - no appropriate client certificate");?>' + '</ul></li>';
} else {
cliinfo = cliinfo + '<table><tbody><tr><td class="icon_td"><img class="icon" src="' + icons[level] + '" style="width: 24px;"></td><td>' + state;
cliinfo = cliinfo + ' <?php echo "(" . sprintf(_("elapsed time: %sms."), "'+data.ca[key].certificate[c].time_millisec+'&nbsp;") . ")"; ?>' + add + '</td></tr>';
cliinfo = cliinfo + '</tbody></table></ul></li>';
}

if (data.ca[key].certificate[c].finalerror === 1) {
cliinfo = cliinfo + '<li>' + restskipped + '</li>';
}
Expand Down Expand Up @@ -378,7 +385,6 @@ function capath(data, status) {
}

function udp(data, status) {
console.log("udp - ajax - start");
show_debug(JSON.stringify(data));
var v = data.result[0];
$("#src" + data.hostindex + "_img").attr('src', icons[v.level]);
Expand Down Expand Up @@ -413,12 +419,10 @@ function udp(data, status) {
global_level_udp = Math.max(global_level_udp, v.level);
$(".server_cert").show();
running_ajax_stat--;
console.log(running_ajax_stat);
ajax_end();
}

function ajax_end() {
console.log("ajax_end");
if (running_ajax_stat === 0) {
$("#main_static_ico").attr('src', icons[global_level_udp]);
$("#main_static_result").html(global_info[global_level_udp] + ' ' + "<?php echo _("See the appropriate tab for details.") ?>");
Expand Down
4 changes: 3 additions & 1 deletion web/diag/show_realmcheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,10 @@
$('.moreall').removeClass('less');
$('.moreall').html(morealltext);
} else {
console.log('MMMM');
$(this).attr('moretext', $(this).html());
$(this).addClass('less');
console.log($(this).html());
$(this).html(lesstext);
}
$(this).parent().prev().toggle();
Expand Down Expand Up @@ -160,7 +162,7 @@
?>
<div id="tabs-3">
<!--<button id="run_d_tests" onclick="run_dynamic()"><?php echo _("Repeat dynamic connectivity tests") ?></button>-->
<?php print $realmTests->printDynamic(); ?>
<?php print $realmTests->printDynamic();?>

</div>
<?php
Expand Down

0 comments on commit ea18cf5

Please sign in to comment.