|
|
@@ -5,15 +5,16 @@ namespace application\controllers;
|
|
|
class GetSSLDaysController {
|
|
|
public static function getSSLDays($data): void {
|
|
|
$domain = $data['domain'] ?? '';
|
|
|
- clearstatcache();
|
|
|
- error_log("data: " . $domain);
|
|
|
-
|
|
|
if (empty($domain)) {
|
|
|
http_response_code(400);
|
|
|
echo json_encode(['error' => 'Missing required parameter: domain']);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ exec("sudo certbot certificates --cert-name $domain | grep 'Expiry' | sed 's/..:..:..+..:..../\n/g
|
|
|
+' | sed 's/days)//g' | sed 's/[[:space:]]//g' | cut -d: -f2", $phpOutput, $phpReturnCode);
|
|
|
+
|
|
|
+ /*
|
|
|
$certFile = "/etc/letsencrypt/live/$domain/fullchain.pem";
|
|
|
if (!file_exists($certFile)) {
|
|
|
error_log("certfile: " . $certFile);
|
|
|
@@ -32,10 +33,13 @@ class GetSSLDaysController {
|
|
|
$expiryTimestamp = $certData['validTo_time_t'];
|
|
|
$expiryDate = date('Y-m-d', $expiryTimestamp);
|
|
|
$daysRemaining = ceil(($expiryTimestamp - time()) / 86400);
|
|
|
+ */
|
|
|
+ error_log("Debug certbot respond =>" . implode("\n", $phpOutput));
|
|
|
|
|
|
echo json_encode([
|
|
|
- 'ssl_expiry' => $expiryDate,
|
|
|
- 'ssl_remaining' => $daysRemaining
|
|
|
+ 'ssl_expiry' => $phpOutput,
|
|
|
+ 'ssl_remaining' => $phpOutput
|
|
|
]);
|
|
|
+
|
|
|
}
|
|
|
}
|