Skip to content

Commit f7a4a4e

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

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ function disableHost($hostId, $urlAndPort, $sendMessageAndReload = true, $change
3232
$pathToCert = $details->getCertificate($host["Host_ID"]);
3333
$pathToCert = $_ENV["LXD_CERTS_DIR"] . "$pathToCert";
3434
$socketPath = $details->getSocketPath($host["Host_ID"]);
35+
36+
if ($socketPath == null) {
37+
$certinfo = openssl_x509_parse(file_get_contents($pathToCert));
38+
39+
if ($certinfo['validFrom_time_t'] > time() || $certinfo['validTo_time_t'] < time()) {
40+
disableHost($host["Host_ID"], $host["Host_Url_And_Port"], $host["Host_Online"] == true, $changeStatus, $reloadNode);
41+
continue;
42+
}
43+
}
44+
3545
$config = $clients->createConfigArray($pathToCert, $socketPath);
3646
$config["timeout"] = 2;
3747
$lxd = $clients->createNewClient($host["Host_Url_And_Port"], $config);

0 commit comments

Comments
 (0)