Skip to content

Commit

Permalink
Certificate cron bugfix
Browse files Browse the repository at this point in the history
Don't try to update certificates if expiry is empty (connection error)
  • Loading branch information
wrongecho committed Oct 2, 2024
1 parent c352f6e commit 63579d5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions cron_certificate_refresher.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
* ###############################################################################################################
*/

$sql_certificates = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_archived_at IS NULL");
$sql_certificates = mysqli_query(
$mysqli,
"SELECT * FROM certificates
LEFT JOIN clients ON certificates.certificate_client_id = clients.client_id
WHERE certificate_archived_at IS NULL
AND client_archived_at IS NULL"
);

while ($row = mysqli_fetch_array($sql_certificates)) {
$certificate_id = intval($row['certificate_id']);
Expand All @@ -46,17 +52,18 @@
$issued_by = sanitizeInput($certificate['issued_by']);
$public_key = sanitizeInput($certificate['public_key']);

if (empty($expire)) {
$expire = "NULL";
} else {
$expire = "'" . $expire . "'";
}
if (!empty($expire)) {

echo "\n$domain\n";
echo "$issued_by\n";
echo "$expire\n";
echo "$public_key\n\n";
echo "\n$domain\n";
echo "$issued_by\n";
echo "$expire\n";
echo "$public_key\n\n";

mysqli_query($mysqli,"UPDATE certificates SET certificate_issued_by = '$issued_by', certificate_expire = $expire, certificate_public_key = '$public_key' WHERE certificate_id = $certificate_id");
$expire = "'" . $expire . "'";
mysqli_query($mysqli,"UPDATE certificates SET certificate_issued_by = '$issued_by', certificate_expire = $expire, certificate_public_key = '$public_key' WHERE certificate_id = $certificate_id");

} else {
error_log("Certificate Cron Error - Error updating $domain");
}

}

0 comments on commit 63579d5

Please sign in to comment.