diff --git a/application/clicommands/CheckCommand.php b/application/clicommands/CheckCommand.php index 66336c68..96078728 100644 --- a/application/clicommands/CheckCommand.php +++ b/application/clicommands/CheckCommand.php @@ -113,15 +113,15 @@ public function hostAction() $state = 3; foreach ($this->getDb()->select($targets) as $target) { - if ($target['valid'] === 'no' && ($target['self_signed'] === 'no' || ! $allowSelfSigned)) { - $invalidMessage = $target['subject'] . ': ' . $target['invalid_reason']; + if ($target->valid === 'no' && ($target->self_signed === 'no' || ! $allowSelfSigned)) { + $invalidMessage = $target->subject . ': ' . $target->invalid_reason; $output[$invalidMessage] = $invalidMessage; $state = 2; } $now = new \DateTime(); - $validFrom = (new \DateTime())->setTimestamp($target['valid_from']); - $validTo = (new \DateTime())->setTimestamp($target['valid_to']); + $validFrom = (new \DateTime())->setTimestamp($target->valid_from); + $validTo = (new \DateTime())->setTimestamp($target->valid_to); $criticalAfter = $this->thresholdToDateTime($validFrom, $validTo, $criticalThreshold, $criticalUnit); $warningAfter = $this->thresholdToDateTime($validFrom, $validTo, $warningThreshold, $warningUnit); @@ -136,28 +136,28 @@ public function hostAction() $remainingTime = $now->diff($validTo); if (! $remainingTime->invert) { // The certificate has not expired yet - $output[$target['subject']] = sprintf( + $output[$target->subject] = sprintf( '%s expires in %d days', - $target['subject'], + $target->subject, $remainingTime->days ); } else { - $output[$target['subject']] = sprintf( + $output[$target->subject] = sprintf( '%s has expired since %d days', - $target['subject'], + $target->subject, $remainingTime->days ); } - $perfData[$target['subject']] = sprintf( + $perfData[$target->subject] = sprintf( "'%s'=%ds;%d:;%d:;0;%d", - $target['subject'], + $target->subject, $remainingTime->invert ? 0 - : $target['valid_to'] - time(), - $target['valid_to'] - $warningAfter->getTimestamp(), - $target['valid_to'] - $criticalAfter->getTimestamp(), - $target['valid_to'] - $target['valid_from'] + : $target->valid_to - time(), + $target->valid_to - $warningAfter->getTimestamp(), + $target->valid_to - $criticalAfter->getTimestamp(), + $target->valid_to - $target->valid_from ); }