From 550a9043bda3fe4276f24cff0145a24e04d7b5a0 Mon Sep 17 00:00:00 2001 From: "dexter.schenk" Date: Tue, 27 Oct 2026 21:18:39 +0200 Subject: [PATCH 1/3] fix(ssl): try the system CA bundle first, never pass a null cert path On Linux the CA lookup shells out to `openssl version -d`. Houdini 22's hython puts its dsolib on LD_LIBRARY_PATH, so the system openssl binary loads Houdini's libcrypto and fails (undefined symbol: BIO_new_dgram_sctp). The compiled-in OPENSSLDIR has no cert.pem either, so setSSL throws, and the constructor's catch called set_ca_cert_path(nullptr). That builds a std::string from null (basic_string::_M_construct null not valid) and aborts the whole AyonApi init, so the resolver never starts. - check the standard system bundles (RHEL, Debian, macOS) before running the CLI - drop the null set_ca_cert_path; httplib then uses OpenSSL's default verify paths Co-Authored-By: Claude Opus 5.5 --- src/AyonCppApi/AyonCppApi.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/AyonCppApi/AyonCppApi.cpp b/src/AyonCppApi/AyonCppApi.cpp index 7d6b158..529af88 100644 --- a/src/AyonCppApi/AyonCppApi.cpp +++ b/src/AyonCppApi/AyonCppApi.cpp @@ -174,8 +174,9 @@ AyonApi::AyonApi(const std::optional &logFilePos, try { setSSL(); } catch (const std::exception &e) { + // No set_ca_cert_path(nullptr): it takes a std::string, so null throws and aborts init. + // httplib falls back to OpenSSL's default verify paths. m_log->error("Failed to get OpenSSL directory: {}", e.what()); - m_ayonServer->set_ca_cert_path(nullptr); } } m_ayonServer->enable_server_certificate_verification(true); @@ -878,6 +879,21 @@ AyonApi::setSSL() { } } +#ifndef _WIN32 + // The system CA bundle first: the `openssl` CLI below breaks when the host app puts its own libcrypto on + // LD_LIBRARY_PATH (Houdini 22 dsolib: "undefined symbol: BIO_new_dgram_sctp"). + for (const char* bundle: {"/etc/pki/tls/certs/ca-bundle.crt", // RHEL / Rocky + "/etc/ssl/certs/ca-certificates.crt", // Debian / Ubuntu + "/etc/ssl/cert.pem"}) { // macOS + if (std::filesystem::is_regular_file(bundle)) { + m_log->info("Using system CA bundle: {}", bundle); + m_ayonServer->set_ca_cert_path(bundle); + m_caCertPath = bundle; + return; + } + } +#endif + std::filesystem::path opensslDirCLI(getOpenSSLDirByCLI()); opensslDirCLI /= "cert.pem"; std::string certFileCLI = opensslDirCLI.string(); From 952323438de7e2da6c468aec11adfba638b6c738 Mon Sep 17 00:00:00 2001 From: "dexter.schenk" Date: Mon, 2 Nov 2026 19:42:50 +0200 Subject: [PATCH 2/3] fix(ssl): fall through when the openssl CLI or OPENSSLDIR lookup fails setSSL() let the exception from getOpenSSLDirByCLI() escape when the `openssl` CLI was missing or broken (empty output -> parseOutput throws), so the compiled-in OPENSSLDIR and the bundled certs/cacert.pem were never tried. Both lookups now log a warning and fall through. The system bundle list runs on Linux only (plus the openSUSE path): on macOS the CLI's OPENSSLDIR, e.g. Homebrew's bundle that can carry keychain CAs, stays ahead of the stock /etc/ssl/cert.pem as before. The constructor's comment and error log now say what httplib falls back to per platform. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01YRNAzpFt5VwUwBTHRbRQRm --- src/AyonCppApi/AyonCppApi.cpp | 41 ++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/src/AyonCppApi/AyonCppApi.cpp b/src/AyonCppApi/AyonCppApi.cpp index 529af88..f4d5b5f 100644 --- a/src/AyonCppApi/AyonCppApi.cpp +++ b/src/AyonCppApi/AyonCppApi.cpp @@ -175,8 +175,9 @@ AyonApi::AyonApi(const std::optional &logFilePos, setSSL(); } catch (const std::exception &e) { // No set_ca_cert_path(nullptr): it takes a std::string, so null throws and aborts init. - // httplib falls back to OpenSSL's default verify paths. - m_log->error("Failed to get OpenSSL directory: {}", e.what()); + // httplib then uses its default CA lookup (OpenSSL's default verify paths on Linux, the system + // store on Windows, the keychain on macOS with CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN). + m_log->error("Failed to find a CA bundle ({}); continuing with httplib's default CA lookup", e.what()); } } m_ayonServer->enable_server_certificate_verification(true); @@ -879,12 +880,14 @@ AyonApi::setSSL() { } } -#ifndef _WIN32 +#ifdef __linux__ // The system CA bundle first: the `openssl` CLI below breaks when the host app puts its own libcrypto on - // LD_LIBRARY_PATH (Houdini 22 dsolib: "undefined symbol: BIO_new_dgram_sctp"). + // LD_LIBRARY_PATH (Houdini 22 dsolib: "undefined symbol: BIO_new_dgram_sctp"). Linux only: on macOS the CLI's + // OPENSSLDIR (e.g. Homebrew's, which can carry keychain CAs) stays ahead of the stock /etc/ssl/cert.pem. for (const char* bundle: {"/etc/pki/tls/certs/ca-bundle.crt", // RHEL / Rocky "/etc/ssl/certs/ca-certificates.crt", // Debian / Ubuntu - "/etc/ssl/cert.pem"}) { // macOS + "/etc/ssl/ca-bundle.pem", // openSUSE + "/etc/ssl/cert.pem"}) { // Alpine / Arch if (std::filesystem::is_regular_file(bundle)) { m_log->info("Using system CA bundle: {}", bundle); m_ayonServer->set_ca_cert_path(bundle); @@ -894,22 +897,34 @@ AyonApi::setSSL() { } #endif - std::filesystem::path opensslDirCLI(getOpenSSLDirByCLI()); - opensslDirCLI /= "cert.pem"; - std::string certFileCLI = opensslDirCLI.string(); + // Each lookup below may throw (no or broken `openssl` CLI, unparsable OPENSSLDIR): fall through to the next one + // and finally to the bundled certificate instead of giving up. + std::string certFileCLI; + try { + std::filesystem::path opensslDirCLI(getOpenSSLDirByCLI()); + opensslDirCLI /= "cert.pem"; + certFileCLI = opensslDirCLI.string(); + } catch (const std::exception &e) { + m_log->warn("openssl CLI lookup failed: {}", e.what()); + } - if (std::filesystem::exists(certFileCLI)) { + if (!certFileCLI.empty() && std::filesystem::exists(certFileCLI)) { m_log->info("Using cert based on CLI var: {}", certFileCLI); m_ayonServer->set_ca_cert_path(certFileCLI.c_str()); m_caCertPath = certFileCLI; return; } - std::filesystem::path opensslDirSSLEAY(getOpenSSLDir()); - opensslDirSSLEAY /= "cert.pem"; - std::string certFileSSLEAY = opensslDirSSLEAY.string(); + std::string certFileSSLEAY; + try { + std::filesystem::path opensslDirSSLEAY(getOpenSSLDir()); + opensslDirSSLEAY /= "cert.pem"; + certFileSSLEAY = opensslDirSSLEAY.string(); + } catch (const std::exception &e) { + m_log->warn("OPENSSLDIR lookup failed: {}", e.what()); + } - if (std::filesystem::exists(certFileSSLEAY)) { + if (!certFileSSLEAY.empty() && std::filesystem::exists(certFileSSLEAY)) { m_log->info("Using cert based on SSLEAY_DIR: {}", certFileSSLEAY); m_ayonServer->set_ca_cert_path(certFileSSLEAY.c_str()); m_caCertPath = certFileSSLEAY; From b37f887dcdd64b16f1205784f6f3676e2a2ceab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= <33513211+antirotor@users.noreply.github.com> Date: Wed, 4 Nov 2026 17:07:32 +0100 Subject: [PATCH 3/3] Add error handling to file existence check Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/AyonCppApi/AyonCppApi.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/AyonCppApi/AyonCppApi.cpp b/src/AyonCppApi/AyonCppApi.cpp index f4d5b5f..1b510bf 100644 --- a/src/AyonCppApi/AyonCppApi.cpp +++ b/src/AyonCppApi/AyonCppApi.cpp @@ -888,7 +888,8 @@ AyonApi::setSSL() { "/etc/ssl/certs/ca-certificates.crt", // Debian / Ubuntu "/etc/ssl/ca-bundle.pem", // openSUSE "/etc/ssl/cert.pem"}) { // Alpine / Arch - if (std::filesystem::is_regular_file(bundle)) { + std::error_code ec; + if (std::filesystem::is_regular_file(bundle, ec)) { m_log->info("Using system CA bundle: {}", bundle); m_ayonServer->set_ca_cert_path(bundle); m_caCertPath = bundle;