Skip to content

Commit 360c4d3

Browse files
committed
Set host to offline if our client certificate has expired (close #479)
1 parent 56fbc3e commit 360c4d3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Changed
4949
Disable some spice channels to improve VM Terminal experience (#463)
5050
Open terminal when opening an instance view
5151
Restrict deployments by user project access (Admin can access all) (#466)
52+
Set host to offline if our client certificate has expired (#479)
5253

5354
Fixed
5455
First run doesn't toggle passwords properly (#390)

src/cronJobs/scripts/hostsOnline.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ function disableHost($hostId, $urlAndPort, $sendMessageAndReload = true, $change
3131
try {
3232
$pathToCert = $details->getCertificate($host["Host_ID"]);
3333
$pathToCert = $_ENV["LXD_CERTS_DIR"] . "$pathToCert";
34+
35+
$certinfo = openssl_x509_parse(file_get_contents($pathToCert));
36+
37+
if ($certinfo['validFrom_time_t'] > time() || $certinfo['validTo_time_t'] < time()) {
38+
disableHost($host["Host_ID"], $host["Host_Url_And_Port"], $host["Host_Online"] == true, $changeStatus, $reloadNode);
39+
continue;
40+
}
41+
3442
$socketPath = $details->getSocketPath($host["Host_ID"]);
3543
$config = $clients->createConfigArray($pathToCert, $socketPath);
3644
$config["timeout"] = 2;

0 commit comments

Comments
 (0)