Skip to content

Commit

Permalink
Set host to offline if our client certificate has expired (close #479)
Browse files Browse the repository at this point in the history
  • Loading branch information
turtle0x1 committed Mar 12, 2022
1 parent 56fbc3e commit f7a4a4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -49,6 +49,7 @@ Changed
Disable some spice channels to improve VM Terminal experience (#463)
Open terminal when opening an instance view
Restrict deployments by user project access (Admin can access all) (#466)
Set host to offline if our client certificate has expired (#479)

Fixed
First run doesn't toggle passwords properly (#390)
Expand Down
10 changes: 10 additions & 0 deletions src/cronJobs/scripts/hostsOnline.php
Expand Up @@ -32,6 +32,16 @@ function disableHost($hostId, $urlAndPort, $sendMessageAndReload = true, $change
$pathToCert = $details->getCertificate($host["Host_ID"]);
$pathToCert = $_ENV["LXD_CERTS_DIR"] . "$pathToCert";
$socketPath = $details->getSocketPath($host["Host_ID"]);

if ($socketPath == null) {
$certinfo = openssl_x509_parse(file_get_contents($pathToCert));

if ($certinfo['validFrom_time_t'] > time() || $certinfo['validTo_time_t'] < time()) {
disableHost($host["Host_ID"], $host["Host_Url_And_Port"], $host["Host_Online"] == true, $changeStatus, $reloadNode);
continue;
}
}

$config = $clients->createConfigArray($pathToCert, $socketPath);
$config["timeout"] = 2;
$lxd = $clients->createNewClient($host["Host_Url_And_Port"], $config);
Expand Down

0 comments on commit f7a4a4e

Please sign in to comment.