notify expire certificate

This commit is contained in:
mercury
2023-11-17 00:11:16 +04:00
parent 475d3504f0
commit 6fc7571e76
3 changed files with 29 additions and 2 deletions
+25 -1
View File
@@ -605,6 +605,7 @@ class Bot
$this->shutdownClient();
$this->checkVersion();
$this->checkBackup();
$this->checkCert();
sleep(10);
}
}
@@ -675,6 +676,23 @@ class Bot
}
}
public function checkCert()
{
try {
require __DIR__ . '/config.php';
if (!empty($c['admin']) && (empty($this->time2) || ((time() - $this->time2) > 3600))) {
$this->time2 = time();
$cert = $this->expireCert();
if (!empty($cert) && $cert - 60 * 60 * 24 * 14 < time()) {
foreach ($c['admin'] as $k => $v) {
$this->send($v, "certificate expire: " . date('Y-m-d H:i:s', $cert));
}
}
}
} catch (Exception $e) {
}
}
public function getTime(int $seconds)
{
$seconds = ($seconds - time()) > 0 ? $seconds - time() : 0;
@@ -2867,6 +2885,12 @@ DNS-over-HTTPS with IP:
];
}
public function expireCert()
{
$c = openssl_x509_read(file_get_contents("/certs/cert_public"));
return openssl_x509_parse($c)["validTo_time_t"] ?: false;
}
public function configMenu()
{
$conf = $this->getPacConf();
@@ -2885,7 +2909,7 @@ DNS-over-HTTPS with IP:
case 'letsencrypt':
$data[] = [
[
'text' => $this->i18n('renew SSL'),
'text' => $this->i18n('renew SSL') . ': ' . date('Y-m-d H:i:s', $this->expireCert()),
'callback_data' => "/setSSL letsencrypt",
],
[
+1 -1
View File
@@ -1,4 +1,4 @@
FROM alpine:3.17
FROM alpine:3.18.2
RUN apk add --no-cache --update php81 \
php81-mbstring \
php81-session \
+3
View File
@@ -1,3 +1,6 @@
17.11.2023 уведомление о скорой просрочке сертификата
<code>git pull</code>
<code>make r</code>
12.11.2023 AdGuardHome latest docker image
<code>git pull</code>
<code>make r</code>