Trust the per-printer CA file for Bambu LAN connections (#17062)

The HTTPS CA file in the IP and access code dialog had no effect for Bambu Lab printers. For Bambu printers, the CA path is now saved with the printer's local machine entry instead of being read from the selected preset. On connect, Orca builds `<data_dir>/cert` with the bundled `printer.cer` plus the CA of each printer connected in this session, and points the network plug-in there. The file must contain only CA certificates. If it doesn't, Orca logs a warning and keeps the bundled certs. Other printer agents still use `printhost_cafile` from the preset.

A CA chosen before this change is not migrated. Choose it again in the dialog.

Fixes #17061
This commit is contained in:
Niklas authored and GitHub committed 2026-11-10 18:48:28 -06:00
1 parent fabad6114a
commit 96d7742974
13 files changed
+447 -25

No files matched your search

+18 -2
View File
@@ -579,6 +579,15 @@ void MachineObject::set_access_code(std::string code, bool only_refresh)
}
}
void MachineObject::set_ca_file(std::string path, bool only_refresh)
{
ca_file = std::move(path);
if (only_refresh && is_lan_mode_printer() && has_access_right()) {
if (AppConfig* config = m_manager ? m_manager->get_app_config() : GUI::wxGetApp().app_config)
DeviceManager::update_local_machine(*this, config);
}
}
std::string MachineObject::get_show_printer_type() const
{
std::string printer_type = this->printer_type;
@@ -2706,13 +2715,20 @@ int MachineObject::connect()
// bare IP as dev_ip, so take the port from the dev_id rather than falling back to port 80.
if (port.empty() && connects_through_moonraker_agent(printer_agent_id))
Http::get_host_from_url(get_dev_id(), &port);
std::string ca_file;
// A Bambu printer's CA is chosen per device in the connect dialog. Never take it from the
// selected preset: it may belong to another printer, or come from an imported profile.
// A local machine saved before agent ids existed belongs to the agent that connects it now.
const std::string agent_id = !printer_agent_id.empty() ? printer_agent_id :
m_manager ? m_manager->get_current_printer_agent_id() : std::string();
const bool is_bbl = agent_id == BBL_PRINTER_AGENT_ID;
std::string ca_file = is_bbl ? get_ca_file() : std::string();
if (wxTheApp && GUI::wxGetApp().preset_bundle) {
const auto& config = GUI::wxGetApp().preset_bundle->printers.get_edited_preset().config;
if (port.empty())
port = config.opt_string("printhost_port");
ca_file = config.opt_string("printhost_cafile");
if (!is_bbl)
ca_file = config.opt_string("printhost_cafile");
// Refresh credentials from the matching preset for connections that bypass GUI_App::select_machine().
const std::string print_host = config.opt_string("print_host");