fix(http2): trust the system CA list for HTTPS requests #11145

Merged
p3n1cillin merged 5 commits from upstream-pr/11145 into main 2026-10-28 09:13:33 +00:00
p3n1cillin commented 2026-10-25 19:33:39 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by p3n1cillin on 2026-10-25T19:33:39Z.


What

#10167 (libSceHttp2's HTTP/2 transport) has merged, and it already accepts is_auto_proxy_conf 0 and 1. This PR is based directly on main f759e165d9 and has five commits. They fix what still stops the catalog titles that use libSceHttp2 from reaching an HTTPS server.

Default trust. Each libSceSsl context starts with no trust anchors, so a request without a verify callback throws sceHttp2: TLS failed. None of the four titles that use libSceHttp2 loads a certificate or installs a callback:

The change:

  • libSceSsl gets SslTrustSystemRoots_nid_no_patch. For one connection, it trusts the system CA list after the context's own authorities. The list is /<sandbox word>/common/cert/CA_LIST.cer, which #5280 serves from the host trust store.
  • The list is parsed once per process into its own pool, not the title's.
  • The transport calls the helper after sceSslCreateConnection.
  • If the sandbox word is null, or the list can't be opened, is empty or holds no certificate, the call throws and names the path. Nothing is cached after a failure.

Dropped from this PR:

  • The is_auto_proxy_conf change: #10167 covers it.
  • The Winsock change: on the rebased tree, a request made with no earlier socket and no WSAStartup of the title's own now resolves without it (probe below), so that commit is gone.

One copy of the libSceSsl helper. This PR now owns SslTrustSystemRoots_nid_no_patch. That includes the libkernel link that guest_ssl_context_lifetime_tests needs for it. #11134 (libSceHttp) is restacked on this PR and only adds its call, so the merged stack has one implementation. This PR doesn't depend on #11134.

The debt entries record what is inferred and what isn't measured: that the console's roots are exactly this file.

Tests in this PR

Each test serves its own CA_LIST.cer through the working-directory override of the sandbox path that guest_sandbox_certificates covers, so they don't depend on the host's trust store. I have run them on Windows only.

  • guest_ssl_system_roots (libSceSsl), against the fixture loopback server:
    • system (list = fixture root): a context without certificates fails the handshake with 0x8095f00c without the helper and connects with it; a context with an unrelated authority does the same, so the list is trusted after the context's own chain. Adding the list to a started connection throws, and an unknown id returns 0x8095f006.
    • context (list without the fixture root): a context that loaded the fixture root still connects with and without the helper; a context without certificates still fails with the helper.
    • empty and blank (empty list, list with no certificate): the helper throws with the path, twice.
  • guest_http2_system_roots (libSceHttp2): a request from an sceSslInit context with no loaded certificate reaches the localhost loopback server over h2, with the host name and known-CA checks on.

Mutation checks on this head:

  • With the PR's previous Export.cpp, guest_ssl_system_roots_empty and _blank fail.
  • Without the SslTrustSystemRoots_nid_no_patch call in Transport.cpp, guest_http2_system_roots fails and guest_http2_transport still passes.

Tested

Windows 11 Pro (26300), Ryzen 5 7600X, WinLibs GCC 15.2.0, Release. Full build of this branch (head c38629b159) on main f759e165d9:

  • Tests: all 95 tests registered by libSceHttp, libSceHttp2, libSceSsl and libSceNet pass, the five new ones included.
  • Probe (on the earlier head on main 74acfad65b, same trust code): a native probe makes RetroArch's updater request: sceHttp2Init, then sceHttp2CreateTemplate(http, "PS5-RetroArch-Updater/1", 3, 1), then GET, with no WSAStartup of its own.
    • With this PR, https://github.com/ and https://www.google.com/ both return 200 over h2.
    • With the SslTrustSystemRoots_nid_no_patch call removed from the transport, the same request throws sceHttp2: TLS failed.

tools/check_conventions.py --base f759e165d9 passes. The fifth commit, from @oneandonlydean's review, takes the kernel file calls from libkernel's File.hpp and Api.hpp instead of a local extern "C" block. No title was run on this head: the four titles' libSceHttp2 requests are user-triggered (updater, model download) or plain http:// (OliSe).

Title evidence, from @wachi35676 (comment): PSFlyCast (PPSA99247) and PSSwanStation (PPSA99248) check the GitHub API for updates through libSceHttp2. That comment covered the earlier head, stacked on #10167, which had the same trust code.

  • On main before #10167 merged, both fail with 0x80436063.
  • With this PR merged locally, both get their newest release, 3 of 3 runs each.

More title evidence, from @JJenkx (comment): on Linux, PPSA06652's HTTP/1 request reaches TLS with these CA commits and #11611's stack, with verification callbacks reporting errors=0. Without them, sceSslConnect fails with 0x8095f0fd.

Checklist

  • Based on current main; no other open PR implements the same functions (#11134 is stacked on this PR and reuses its libSceSsl helper)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none (#10167 has merged)
  • Fixes: none
  • Unblocks: PPSA99247 and PPSA99248 update checks (tested by @wachi35676); #11134
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007969834 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11145). Originally posted by [p3n1cillin](https://github.com/p3n1cillin) on 2026-10-25T19:33:39Z. --- ### What #10167 (libSceHttp2's HTTP/2 transport) has merged, and it already accepts `is_auto_proxy_conf` 0 and 1. This PR is based directly on `main` `f759e165d9` and has five commits. They fix what still stops the catalog titles that use libSceHttp2 from reaching an HTTPS server. **Default trust.** Each libSceSsl context starts with no trust anchors, so a request without a verify callback throws `sceHttp2: TLS failed`. None of the four titles that use libSceHttp2 loads a certificate or installs a callback: - OliSe Player, [`netxm.c`](https://github.com/Marice/OliSePlayer/blob/fb06d7ac7467a50ba1f2ee299dac20e43213d674/src/netxm.c#L73); - RetroArch, [`webui_update.cpp`](https://github.com/mihawk-99/PS5_RetroArch/blob/7268510b12fe7461342e0cc4497c87a0910c1055/src/webui_update.cpp#L305); - PS5LM, [`fetch.cpp`](https://github.com/cobanov/PS5LM/blob/ecbcb8cc54faf33b7987011b4708d5e0b9ee5f52/ps5/app/fetch.cpp#L59); - Porpoise, [`porpoise_http.cpp`](https://github.com/elripalda/Porpoise-Dolphin-Emulator-for-PS5/blob/db6c13e20a9e4c3e16e088ecb8b3d0098efa73b2/src/porpoise_http.cpp#L77). The change: - libSceSsl gets `SslTrustSystemRoots_nid_no_patch`. For one connection, it trusts the system CA list after the context's own authorities. The list is `/<sandbox word>/common/cert/CA_LIST.cer`, which #5280 serves from the host trust store. - The list is parsed once per process into its own pool, not the title's. - The transport calls the helper after `sceSslCreateConnection`. - If the sandbox word is null, or the list can't be opened, is empty or holds no certificate, the call throws and names the path. Nothing is cached after a failure. **Dropped from this PR:** - The `is_auto_proxy_conf` change: #10167 covers it. - The Winsock change: on the rebased tree, a request made with no earlier socket and no `WSAStartup` of the title's own now resolves without it (probe below), so that commit is gone. **One copy of the libSceSsl helper.** This PR now owns `SslTrustSystemRoots_nid_no_patch`. That includes the `libkernel` link that `guest_ssl_context_lifetime_tests` needs for it. #11134 (libSceHttp) is restacked on this PR and only adds its call, so the merged stack has one implementation. This PR doesn't depend on #11134. The debt entries record what is inferred and what isn't measured: that the console's roots are exactly this file. ### Tests in this PR Each test serves its own `CA_LIST.cer` through the working-directory override of the sandbox path that `guest_sandbox_certificates` covers, so they don't depend on the host's trust store. I have run them on Windows only. - **`guest_ssl_system_roots`** (libSceSsl), against the fixture loopback server: - `system` (list = fixture root): a context without certificates fails the handshake with `0x8095f00c` without the helper and connects with it; a context with an unrelated authority does the same, so the list is trusted after the context's own chain. Adding the list to a started connection throws, and an unknown id returns `0x8095f006`. - `context` (list without the fixture root): a context that loaded the fixture root still connects with and without the helper; a context without certificates still fails with the helper. - `empty` and `blank` (empty list, list with no certificate): the helper throws with the path, twice. - **`guest_http2_system_roots`** (libSceHttp2): a request from an `sceSslInit` context with no loaded certificate reaches the `localhost` loopback server over h2, with the host name and known-CA checks on. Mutation checks on this head: - With the PR's previous `Export.cpp`, `guest_ssl_system_roots_empty` and `_blank` fail. - Without the `SslTrustSystemRoots_nid_no_patch` call in `Transport.cpp`, `guest_http2_system_roots` fails and `guest_http2_transport` still passes. ### Tested Windows 11 Pro (26300), Ryzen 5 7600X, WinLibs GCC 15.2.0, Release. Full build of this branch (head `c38629b159`) on `main` `f759e165d9`: - **Tests:** all 95 tests registered by libSceHttp, libSceHttp2, libSceSsl and libSceNet pass, the five new ones included. - **Probe** (on the earlier head on `main` `74acfad65b`, same trust code): a native probe makes RetroArch's updater request: `sceHttp2Init`, then `sceHttp2CreateTemplate(http, "PS5-RetroArch-Updater/1", 3, 1)`, then GET, with no `WSAStartup` of its own. - With this PR, `https://github.com/` and `https://www.google.com/` both return 200 over h2. - With the `SslTrustSystemRoots_nid_no_patch` call removed from the transport, the same request throws `sceHttp2: TLS failed`. `tools/check_conventions.py --base f759e165d9` passes. The fifth commit, from @oneandonlydean's review, takes the kernel file calls from libkernel's `File.hpp` and `Api.hpp` instead of a local `extern "C"` block. No title was run on this head: the four titles' libSceHttp2 requests are user-triggered (updater, model download) or plain `http://` (OliSe). **Title evidence, from @wachi35676 ([comment](https://github.com/boykopovar/AnyPS5/pull/11145#issuecomment-6403840604)):** PSFlyCast (PPSA99247) and PSSwanStation (PPSA99248) check the GitHub API for updates through libSceHttp2. That comment covered the earlier head, stacked on #10167, which had the same trust code. - On `main` before #10167 merged, both fail with `0x80436063`. - With this PR merged locally, both get their newest release, 3 of 3 runs each. **More title evidence, from @JJenkx ([comment](https://github.com/boykopovar/AnyPS5/pull/11145#issuecomment-6429270809)):** on Linux, PPSA06652's HTTP/1 request reaches TLS with these CA commits and #11611's stack, with verification callbacks reporting `errors=0`. Without them, `sceSslConnect` fails with `0x8095f0fd`. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions (#11134 is stacked on this PR and reuses its libSceSsl helper) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none (#10167 has merged) - [x] Fixes: none - [x] Unblocks: PPSA99247 and PPSA99248 update checks (tested by @wachi35676); #11134 - [x] GPUs tested: n/a - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-25 19:40:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T19:40:33Z.

Review: DISMISSED


Reviewed the current PR metadata and overlap against exact head d5cfffa51914a7521731addf5a5eea7c0b2a972e.

Two integration blockers remain before this stack can be reviewed as merge-ready:

  1. GitHub reports the PR as CONFLICTING / DIRTY with the current main and labels it needs rebase. The branch is stacked on #10167's older head, so the current PR checks do not include a build or focused test run for a clean merge with today's base. Please resolve the current-main conflicts on your branch, then rerun the relevant tests on that rebased tree.
  2. This PR includes SslTrustSystemRoots_nid_no_patch and its libSceSsl implementation, while open #11134 adds the same helper and CA-list behavior. The body acknowledges that overlap but the checklist only says Depends on: #10167. Please declare and coordinate the #11134 ordering, then remove/reuse the duplicate helper when rebasing so the merged stack has one implementation. #11134 currently has an outstanding review request, so this may need to wait for that resolution.

I did not rebase or modify the author's branch. Current conventions, intake and labels checks pass, but they do not clear the merge conflict or validate the product code on the current base. No approval until these stack issues are resolved.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644914352 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11145#pullrequestreview-5644914352). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T19:40:33Z. **Review:** DISMISSED --- Reviewed the current PR metadata and overlap against exact head `d5cfffa51914a7521731addf5a5eea7c0b2a972e`. Two integration blockers remain before this stack can be reviewed as merge-ready: 1. GitHub reports the PR as `CONFLICTING` / `DIRTY` with the current `main` and labels it `needs rebase`. The branch is stacked on #10167's older head, so the current PR checks do not include a build or focused test run for a clean merge with today's base. Please resolve the current-main conflicts on your branch, then rerun the relevant tests on that rebased tree. 2. This PR includes `SslTrustSystemRoots_nid_no_patch` and its libSceSsl implementation, while open #11134 adds the same helper and CA-list behavior. The body acknowledges that overlap but the checklist only says `Depends on: #10167`. Please declare and coordinate the #11134 ordering, then remove/reuse the duplicate helper when rebasing so the merged stack has one implementation. #11134 currently has an outstanding review request, so this may need to wait for that resolution. I did not rebase or modify the author's branch. Current conventions, intake and labels checks pass, but they do not clear the merge conflict or validate the product code on the current base. No approval until these stack issues are resolved.
klosixgaming-arch commented 2026-10-25 21:45:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-25T21:45:51Z.

Review: COMMENTED


Reviewed head d5cfffa519 by reading the diff and the existing review thread. I did not build or run this, so everything below is from the code, not from a test of mine.

Scope note first. The diff here is 12 files and about 1,500 added lines because the PR is stacked on #10167 (the HTTP/2 transport), which is not merged. The description says only the last two commits are new, but GitHub shows the whole stack, and the PR is DIRTY against main. I did not review the transport itself line by line. This review covers what the description says is new: automatic-proxy acceptance, the Winsock start and the system-roots trust in libSceSsl. I'd suggest retargeting this onto #10167's branch, or waiting until #10167 lands, so the diff shows only the two commits.

libSceSsl (SslTrustSystemRoots_nid_no_patch).

  • The shared root chain is parsed once into its own pool, and a session links it behind its own authorities list. The destructor sets linkedSystemRoots->next = nullptr before mbedtls_x509_crt_free(&authorities), so the shared chain is not freed with the session. That is the part I would have worried about, and it looks right.
  • If the title loaded no certificates, trusted points directly at the shared chain; mbedTLS only reads it, so concurrent sessions are fine.
  • ReadSystemCaList returns an empty string if the file cannot be opened, and SystemRoots() then caches an empty chain for the rest of the process. A transient failure to open the sandboxed path therefore disables trust permanently, with no message. A one-line diagnostic on the empty result, or not caching a failure, would help.
  • std::string("/") + sceKernelGetFsSandboxRandomWord() is undefined if that function returns null. Presumably it never does; a guard costs nothing.
  • The trust source is the host store served by #5280 and the debt note says the console's roots being exactly this file is not measured. Fine, and honestly stated.

Resolver. It calls WSAStartup in the constructor of a function-local static and has no matching WSACleanup in the visible destructor path. For a process-lifetime singleton that is harmless in practice, but it will unbalance the Winsock count if the resolver is ever torn down earlier.

Proxy. Accepting is_auto_proxy_conf and connecting directly is a reasonable stance given there is no system proxy setting, and the debt entry says the console behaviour is inferred.

I'm leaving a comment. MarcZX10's CHANGES_REQUESTED (the rebase and the stack integration) is the blocker, not anything in the parts I read.

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5645480178 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11145#pullrequestreview-5645480178). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-25T21:45:51Z. **Review:** COMMENTED --- Reviewed head `d5cfffa519` by reading the diff and the existing review thread. I did not build or run this, so everything below is from the code, not from a test of mine. **Scope note first.** The diff here is 12 files and about 1,500 added lines because the PR is stacked on #10167 (the HTTP/2 transport), which is not merged. The description says only the last two commits are new, but GitHub shows the whole stack, and the PR is DIRTY against `main`. I did not review the transport itself line by line. This review covers what the description says is new: automatic-proxy acceptance, the Winsock start and the system-roots trust in libSceSsl. I'd suggest retargeting this onto #10167's branch, or waiting until #10167 lands, so the diff shows only the two commits. **libSceSsl (`SslTrustSystemRoots_nid_no_patch`).** - The shared root chain is parsed once into its own pool, and a session links it behind its own `authorities` list. The destructor sets `linkedSystemRoots->next = nullptr` before `mbedtls_x509_crt_free(&authorities)`, so the shared chain is not freed with the session. That is the part I would have worried about, and it looks right. - If the title loaded no certificates, `trusted` points directly at the shared chain; mbedTLS only reads it, so concurrent sessions are fine. - `ReadSystemCaList` returns an empty string if the file cannot be opened, and `SystemRoots()` then caches an empty chain for the rest of the process. A transient failure to open the sandboxed path therefore disables trust permanently, with no message. A one-line diagnostic on the empty result, or not caching a failure, would help. - `std::string("/") + sceKernelGetFsSandboxRandomWord()` is undefined if that function returns null. Presumably it never does; a guard costs nothing. - The trust source is the host store served by #5280 and the debt note says the console's roots being exactly this file is not measured. Fine, and honestly stated. **Resolver.** It calls `WSAStartup` in the constructor of a function-local static and has no matching `WSACleanup` in the visible destructor path. For a process-lifetime singleton that is harmless in practice, but it will unbalance the Winsock count if the resolver is ever torn down earlier. **Proxy.** Accepting `is_auto_proxy_conf` and connecting directly is a reasonable stance given there is no system proxy setting, and the debt entry says the console behaviour is inferred. I'm leaving a comment. MarcZX10's `CHANGES_REQUESTED` (the rebase and the stack integration) is the blocker, not anything in the parts I read. AI-assisted: yes. Written with AI assistance and reviewed by me.
adriadam10 commented 2026-10-27 03:23:36 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T03:23:36Z.

Review: CHANGES_REQUESTED


Checked the rebased head: the chain linking in Session::Configure and the unlink in ~Session are correct, the system list is shared read-only, and the debt entries are in place. Two things before merge:

  • core/libs/prx/libSceSsl/Export.cpp:892 (SslTrustSystemRoots_nid_no_patch) and the call in Transport.cpp:354 have no test in the repo; the only test change is the libkernel link. The Windows probe in the description can't be re-run from the tree. A Linux test is possible with what's already there: GuestSandboxCertificates.cpp sets SSL_CERT_FILE to serve a chosen bundle at CA_LIST.cer, and GuestHttp2Transport.cpp / SslCertificateFixture.hpp have a loopback server with its own CA. Serve the fixture root as the system list, then check that a connection without sceSslLoadCert fails the handshake without the helper and succeeds with it (and that a context-loaded CA still works alongside it).
  • Export.cpp:223: an empty CA list returns an empty chain and SystemRoots() then returns nullptr, so the connection silently trusts nothing, which is the failure this PR fixes. Throw (naming the path) when the file is empty or yields no certificate, like the missing-file case.

Title evidence from @wachi35676 and @JJenkx is noted; once the test is in, this is ready.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5661860312 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11145#pullrequestreview-5661860312). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-27T03:23:36Z. **Review:** CHANGES_REQUESTED --- Checked the rebased head: the chain linking in `Session::Configure` and the unlink in `~Session` are correct, the system list is shared read-only, and the debt entries are in place. Two things before merge: - `core/libs/prx/libSceSsl/Export.cpp:892` (`SslTrustSystemRoots_nid_no_patch`) and the call in `Transport.cpp:354` have no test in the repo; the only test change is the `libkernel` link. The Windows probe in the description can't be re-run from the tree. A Linux test is possible with what's already there: `GuestSandboxCertificates.cpp` sets `SSL_CERT_FILE` to serve a chosen bundle at `CA_LIST.cer`, and `GuestHttp2Transport.cpp` / `SslCertificateFixture.hpp` have a loopback server with its own CA. Serve the fixture root as the system list, then check that a connection without `sceSslLoadCert` fails the handshake without the helper and succeeds with it (and that a context-loaded CA still works alongside it). - `Export.cpp:223`: an empty CA list returns an empty chain and `SystemRoots()` then returns `nullptr`, so the connection silently trusts nothing, which is the failure this PR fixes. Throw (naming the path) when the file is empty or yields no certificate, like the missing-file case. Title evidence from @wachi35676 and @JJenkx is noted; once the test is in, this is ready.
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!11145
No description provided.