security/acme-client: change interface again for reasons

If we call the backend without an interface parameter we will return all
of them.  To provide parity with single interface check keep the interface
key so we need to access it directly as well.
This commit is contained in:
Franco Fichtner
2024-08-02 10:34:30 +02:00
parent 25ec135f0a
commit cab23a684b
2 changed files with 8 additions and 6 deletions
@@ -73,14 +73,15 @@ class HttpOpnsense extends Base implements LeValidationInterface
// Add IP address from chosen interface
if (!empty((string)$this->config->http_opn_interface)) {
$backend = new \OPNsense\Core\Backend();
$response = json_decode($backend->configdpRun('interface address', [(string)$this->config->http_opn_interface]));
$interface = (string)$this->config->http_opn_interface;
$response = json_decode($backend->configdpRun('interface address', [$interface]));
// XXX Returns both IPv4 and IPv6 now. While "[0]" and
// "[1]" should remain in this order it would make sense
// to ensure "family" matches "inet" or "inet6" and/or
// pull both addresses for missing IPv6 support depending
// on how this should work.
if (!empty($response[0]->address)) {
$iplist[] = $response[0]->address;
if (!empty($response->$interface[0]->address)) {
$iplist[] = $response->$interface[0]->address;
}
}
@@ -74,14 +74,15 @@ class TlsalpnAcme extends Base implements LeValidationInterface
// Add IP address from chosen interface
if (!empty((string)$this->config->tlsalpn_acme_interface)) {
$backend = new \OPNsense\Core\Backend();
$response = json_decode($backend->configdpRun('interface address', [(string)$this->config->tlsalpn_acme_interface]));
$interface = (string)$this->config->tlsalpn_acme_interface;
$response = json_decode($backend->configdpRun('interface address', [$interface]));
// XXX Returns both IPv4 and IPv6 now. While "[0]" and
// "[1]" should remain in this order it would make sense
// to ensure "family" matches "inet" or "inet6" and/or
// pull both addresses for missing IPv6 support depending
// on how this should work.
if (!empty($response[0]->address)) {
$iplist[] = $response[0]->address;
if (!empty($response->$interface[0]->address)) {
$iplist[] = $response->$interface[0]->address;
}
}