cloud_discovery: run EST enrollment within DHCP discovery flow

Move EST client enrollment to occur immediately after successful DHCP
discovery and before starting the ucentral client. This ensures
controller-specific certificates are enrolled before attempting to
connect. If EST enrollment fails during DHCP discovery, the client
will not be started.

Adjust interval_handler to call EST enrollment after DHCP discovery
attempt rather than before, ensuring proper certificate handling for
DHCP-discovered controllers.

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin 2025-11-25 07:31:08 +01:00
parent 371edb568f
commit 0f979f2b1f

View File

@ -213,8 +213,11 @@ function discover_dhcp() {
cert: `/etc/ucentral/${fqdn}.pem`,
ca: `/etc/ucentral/${fqdn}.ca`
})) {
ulog(LOG_INFO, `Discovered cloud via DHCP ${dhcp.dhcp_server}:${dhcp.dhcp_port}\n`);
ulog(LOG_INFO, `Discovered cloud via DHCP ${dhcp.dhcp_server}:${dhcp.dhcp_port} - trying EST\n`);
fs.writefile('/tmp/discovery.method', DISCOVER_DHCP);
if (system('/usr/bin/est_client enroll'))
return false;
ulog(LOG_INFO, `Discovered cloud via DHCP ${dhcp.dhcp_server}:${dhcp.dhcp_port} - starting client\n`);
client_start();
set_state(VALIDATING);
}
@ -340,13 +343,13 @@ function interval_handler() {
if (!time_is_valid())
return;
if (system('/usr/bin/est_client enroll'))
return;
discovery_method = DISCOVER_DHCP;
if (!is_discover_method_blacked() && discover_dhcp())
return;
if (system('/usr/bin/est_client enroll'))
return;
discovery_method = DISCOVER_FLASH;
if (!is_discover_method_blacked() && !discover_flash())
return;