Skip to content

Commit 7806d46

Browse files
committed
Fix lcurl dependency
Do not depend on homebrew. Use static OpenSSL with bundled CA
1 parent d16ae04 commit 7806d46

5 files changed

Lines changed: 34 additions & 1 deletion

File tree

.github/workflows/build-macos.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ jobs:
4545
key: vcpkg-${{ hashFiles('SimpleGraphic/vcpkg.json', 'SimpleGraphic/vcpkg-configuration.json', 'vcpkg-triplets/arm64-osx-pob.cmake') }}
4646
restore-keys: vcpkg-
4747

48+
# Stop pkg-config from leaking Homebrew's openssl into the curl build.
49+
- name: Isolate from Homebrew
50+
run: echo "PKG_CONFIG_PATH=" >> $GITHUB_ENV
51+
4852
- name: Configure
4953
run: >
5054
cmake -B build -DCMAKE_BUILD_TYPE=Release

.github/workflows/release-macos.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ jobs:
6363
rm "$CERT_FILE"
6464
echo "CODESIGN_KEYCHAIN=$KEYCHAIN" >> "$GITHUB_ENV"
6565
66+
# Stop pkg-config from leaking Homebrew's openssl into the curl build.
67+
- name: Isolate from Homebrew
68+
run: echo "PKG_CONFIG_PATH=" >> $GITHUB_ENV
69+
6670
- name: Configure
6771
run: >
6872
cmake -B build -DCMAKE_BUILD_TYPE=Release

CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ install(CODE "
140140
endforeach()
141141
")
142142

143+
# ----- CA bundle for libcurl TLS validation -----
144+
# Ship Mozilla's CA bundle (the standard cacert.pem from curl.se) so libcurl
145+
# can validate HTTPS certs without depending on Homebrew or the user's system
146+
# state. Cached in the build dir; refresh by deleting the file before
147+
# configuring.
148+
set(POB_CACERT "${CMAKE_BINARY_DIR}/cacert.pem")
149+
if (NOT EXISTS "${POB_CACERT}")
150+
file(DOWNLOAD https://curl.se/ca/cacert.pem "${POB_CACERT}"
151+
TLS_VERIFY ON
152+
STATUS _cacert_dl_status
153+
SHOW_PROGRESS)
154+
list(GET _cacert_dl_status 0 _cacert_dl_code)
155+
if (NOT _cacert_dl_code EQUAL 0)
156+
message(FATAL_ERROR "Failed to download cacert.pem: ${_cacert_dl_status}")
157+
endif()
158+
endif()
159+
install(FILES "${POB_CACERT}" DESTINATION "${POB_RES_DEST}")
160+
143161
# ----- Bundle the PoB Lua tree -----
144162
if (EXISTS "${POB_LUA_TREE}/src/Launch.lua")
145163
install(DIRECTORY "${POB_LUA_TREE}/src"

macos/launcher.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ int main(int argc, char** argv)
286286
// its own cfg files and imgui.ini away from basePath.
287287
setenv("POB_MAC_USER_DIR", appSupport->c_str(), 1);
288288

289+
// Point OpenSSL (libcurl's TLS backend) at the bundled Mozilla CA
290+
// list. libcurl's OpenSSL backend calls SSL_CTX_set_default_verify_paths
291+
// when no CAINFO is set on the easy handle, which honors SSL_CERT_FILE.
292+
char caPath[PATH_MAX];
293+
std::snprintf(caPath, sizeof(caPath), "%s/cacert.pem", bundleResourcesAbs);
294+
setenv("SSL_CERT_FILE", caPath, 1);
295+
289296
const fs::path appSrcPath = *appSupport / "src";
290297

291298
// Prefer mac_entry.lua (the bootstrap that patches the in-app

0 commit comments

Comments
 (0)