feat(libSceLibreSsl): implement the SSL_CTX verify mode, certificate store, quiet shutdown and password callback accessors #10483

Merged
alvaroelpob merged 6 commits from upstream-pr/10483 into main 2026-11-05 17:07:06 +00:00
alvaroelpob commented 2026-10-24 03:01:16 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-10-24T03:01:16Z.


What

Implements SSL_CTX_get_verify_mode, SSL_CTX_get_cert_store, SSL_CTX_set_quiet_shutdown, SSL_CTX_set_default_passwd_cb and SSL_CTX_set_default_passwd_cb_userdata in libSceLibreSsl, which threw and were declared without parameters.

The module is LibreSSL 2.5.4 (firmware 13.40 measurements in #8981). Signatures, layouts and results follow that release's ssl.h, ssl_locl.h and ssl_lib.c:

Export Behaviour
int SSL_CTX_get_verify_mode(const SSL_CTX*) verify_mode
X509_STORE* SSL_CTX_get_cert_store(const SSL_CTX*) cert_store
void SSL_CTX_set_quiet_shutdown(SSL_CTX*, int mode) internal->quiet_shutdown = mode
void SSL_CTX_set_default_passwd_cb(SSL_CTX*, pem_password_cb*) default_passwd_callback = cb
void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void*) default_passwd_callback_userdata = u

The layouts are 120 bytes for SSL_CTX (cert_store at 16, verify_mode at 48, default_passwd_callback at 96, its userdata at 104, internal at 112) and 464 for ssl_ctx_internal_st (quiet_shutdown at 292). They were checked with static_asserts and against offsetof from the 2.5.4 headers compiled on x86-64. The password callback is only stored; no export calls it yet. LibreSSL dereferences the context, and the internal state in SSL_CTX_set_quiet_shutdown, without checking them, so a null for either throws. No export of this module creates a context yet, so for now only contexts built by the caller reach these functions.

The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 352.

Tested

Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with BUILD_TESTING=ON on main 379b1dca3. There is one commit per function, and each adds that function with its test block and debt update. Each was built and its guest_libressl_ssl_ctx test and check_conventions.py run on its own.

  • New guest_libressl_ssl_ctx test. SSL_CTX_get_verify_mode returns 0, 3 and -1. SSL_CTX_get_cert_store returns null and then the store, not the cipher list. SSL_CTX_set_quiet_shutdown stores 1, INT_MIN and 0, and leaves every other byte of the internal state zero. The two password setters store and clear their own field and leave the other one and internal alone. A null context throws in all five, and a null internal state throws in SSL_CTX_set_quiet_shutdown.
  • Full ctest -j16 at the last commit: 2005/2006 pass. agc_driver_multisample_retirement fails the same way on main on this machine.
  • Not tested: Windows, a title.
  • Rebased on main 1e740a23a3 (after #9033), head 6d5b731336: the conflicts were only the add_library source list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build and ctest -j16: 2043/2044 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Rebased on main e7e3e9c198, head b1f7189dd2, to resolve the conflict from #9529 on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. b1f7189dd2 (refactor(libSceLibreSsl): declare the SSL_CTX accessor exports in the public header) puts the real signatures and their structs in libSceLibreSsl/include/Api.hpp and drops the test's redeclarations, which public_headers requires since #10706. Full build and ctest -j16: 2202/2203 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Rebased on main ae7d59258e (after #9949), head b0d8acf2d3, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and ctest -j16: 2275/2276 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Rebased on main 2dbe9b99f5 (after #9745, #9870 and #11111), head e96986f7f6, to resolve the conflicts with main on the shared CMakeLists.txt and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and ctest -j16: 2370/2371 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Rebased on main c7b4878fa8 (after #10373, #10376 and #10449), head 368b38f4c9, to resolve the conflicts with main on the shared CMakeLists.txt, Api.hpp and debt-file lines; both sides are kept and the count is 319 minus this PR's exports. Full build and ctest -j16: 2394/2395 pass; agc_driver_multisample_retirement fails the same way on that main. check_conventions.py --base upstream/main passes.
  • Rebased on main 474030e584 (after #13562), head e6468ff498, to resolve the conflict on the pending-export count in the debt file; the count is 292 minus this PR's exports. Full build and ctest -j16: 3062/3062 pass. check_conventions.py --base upstream/main passes.
  • Rebased on main cf79276fee (after #13820), head a4817006c9, to resolve the conflict on the pending-export count in the debt file. main still says 292 although #13820 removed two stubs, leaving 290, so the count is now set to the 285 stubs left in Export.cpp. It also restores the PS5 3.20 export table link, b2a77c09cd71c01f34c790cfbe98c751a13262ad, which the previous rebase had written without its zeros. Full build and ctest -j16: 3107/3107 pass (log_file failed once on #10486 and passed on five reruns and a second full run). check_conventions.py --base upstream/main passes.
  • Rebased on main 4939814d79 (after #9970, #10078 and #10488), head 68c65cf612, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp, Api.hpp and debt-file lines; both sides are kept. This replaces the merge of main pushed to the branch as 5de5069019 and its count commit 8690f073a5, which became empty. The count is set to the 256 stubs left in Export.cpp. Full build and ctest -j16: 3538/3538 pass. check_conventions.py --base upstream/main passes.
  • Rebased on main 4f41f4c375, head 3962035028, to resolve the conflicts on the shared CMakeLists.txt, Export.cpp and debt-file lines; both sides are kept and the debt count is recomputed from Export.cpp. Full build and ctest -j16: 3796/3800 pass; guest_sce_net, guest_poll, guest_select_wait and guest_memory failed under that load, pass when run alone, and main 4f41f4c375 passes all 3799 with -j16 on the same machine. check_conventions.py --base upstream/main passes.

Checklist

  • Based on current main; no other open PR implements the same functions
  • 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: #9446, #9571, #10395, #10418, #10448, #10450, #10477, #10478, #10481, #10482
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4991960532 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10483). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-10-24T03:01:16Z. --- ### What Implements `SSL_CTX_get_verify_mode`, `SSL_CTX_get_cert_store`, `SSL_CTX_set_quiet_shutdown`, `SSL_CTX_set_default_passwd_cb` and `SSL_CTX_set_default_passwd_cb_userdata` in libSceLibreSsl, which threw and were declared without parameters. The module is LibreSSL 2.5.4 ([firmware 13.40 measurements in #8981](https://github.com/boykopovar/AnyPS5/discussions/8981#discussioncomment-19111214)). Signatures, layouts and results follow that release's [`ssl.h`, `ssl_locl.h` and `ssl_lib.c`](https://github.com/libressl/openbsd/tree/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl): | Export | Behaviour | |---|---| | `int SSL_CTX_get_verify_mode(const SSL_CTX*)` | `verify_mode` | | `X509_STORE* SSL_CTX_get_cert_store(const SSL_CTX*)` | `cert_store` | | `void SSL_CTX_set_quiet_shutdown(SSL_CTX*, int mode)` | `internal->quiet_shutdown = mode` | | `void SSL_CTX_set_default_passwd_cb(SSL_CTX*, pem_password_cb*)` | `default_passwd_callback = cb` | | `void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX*, void*)` | `default_passwd_callback_userdata = u` | The layouts are 120 bytes for `SSL_CTX` (`cert_store` at 16, `verify_mode` at 48, `default_passwd_callback` at 96, its userdata at 104, `internal` at 112) and 464 for `ssl_ctx_internal_st` (`quiet_shutdown` at 292). They were checked with `static_assert`s and against `offsetof` from the 2.5.4 headers compiled on x86-64. The password callback is only stored; no export calls it yet. LibreSSL dereferences the context, and the internal state in `SSL_CTX_set_quiet_shutdown`, without checking them, so a null for either throws. No export of this module creates a context yet, so for now only contexts built by the caller reach these functions. The debt entry records the source and what is unverified, and the pending-export count drops from 357 to 352. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 26.04 (WSL2, kernel 6.18), GCC 15.2.0, Release, full build with `BUILD_TESTING=ON` on `main` 379b1dca3. There is one commit per function, and each adds that function with its test block and debt update. Each was built and its `guest_libressl_ssl_ctx` test and `check_conventions.py` run on its own. - New `guest_libressl_ssl_ctx` test. `SSL_CTX_get_verify_mode` returns 0, 3 and -1. `SSL_CTX_get_cert_store` returns null and then the store, not the cipher list. `SSL_CTX_set_quiet_shutdown` stores 1, `INT_MIN` and 0, and leaves every other byte of the internal state zero. The two password setters store and clear their own field and leave the other one and `internal` alone. A null context throws in all five, and a null internal state throws in `SSL_CTX_set_quiet_shutdown`. - Full `ctest -j16` at the last commit: 2005/2006 pass. `agc_driver_multisample_retirement` fails the same way on `main` on this machine. - Not tested: Windows, a title. - Rebased on `main` 1e740a23a3 (after #9033), head 6d5b731336: the conflicts were only the `add_library` source list, the end of the test block, the pending-export count and the last debt entry; both sides are kept and the count is 357 minus this PR's exports. Full build and `ctest -j16`: 2043/2044 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` e7e3e9c198, head b1f7189dd2, to resolve the conflict from #9529 on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 353 minus this PR's exports. b1f7189dd2 (`refactor(libSceLibreSsl): declare the SSL_CTX accessor exports in the public header`) puts the real signatures and their structs in `libSceLibreSsl/include/Api.hpp` and drops the test's redeclarations, which `public_headers` requires since #10706. Full build and `ctest -j16`: 2202/2203 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` ae7d59258e (after #9949), head b0d8acf2d3, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 342 minus this PR's exports. Full build and `ctest -j16`: 2275/2276 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 2dbe9b99f5 (after #9745, #9870 and #11111), head e96986f7f6, to resolve the conflicts with `main` on the shared `CMakeLists.txt` and debt-file lines; both sides are kept and the count is 340 minus this PR's exports. Full build and `ctest -j16`: 2370/2371 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` c7b4878fa8 (after #10373, #10376 and #10449), head 368b38f4c9, to resolve the conflicts with `main` on the shared `CMakeLists.txt`, `Api.hpp` and debt-file lines; both sides are kept and the count is 319 minus this PR's exports. Full build and `ctest -j16`: 2394/2395 pass; `agc_driver_multisample_retirement` fails the same way on that `main`. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 474030e584 (after #13562), head e6468ff498, to resolve the conflict on the pending-export count in the debt file; the count is 292 minus this PR's exports. Full build and `ctest -j16`: 3062/3062 pass. `check_conventions.py --base upstream/main` passes. - Rebased on `main` cf79276fee (after #13820), head a4817006c9, to resolve the conflict on the pending-export count in the debt file. `main` still says 292 although #13820 removed two stubs, leaving 290, so the count is now set to the 285 stubs left in `Export.cpp`. It also restores the PS5 3.20 export table link, `b2a77c09cd71c01f34c790cfbe98c751a13262ad`, which the previous rebase had written without its zeros. Full build and `ctest -j16`: 3107/3107 pass (`log_file` failed once on #10486 and passed on five reruns and a second full run). `check_conventions.py --base upstream/main` passes. - Rebased on `main` 4939814d79 (after #9970, #10078 and #10488), head 68c65cf612, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp`, `Api.hpp` and debt-file lines; both sides are kept. This replaces the merge of `main` pushed to the branch as 5de5069019 and its count commit 8690f073a5, which became empty. The count is set to the 256 stubs left in `Export.cpp`. Full build and `ctest -j16`: 3538/3538 pass. `check_conventions.py --base upstream/main` passes. - Rebased on `main` 4f41f4c375, head 3962035028, to resolve the conflicts on the shared `CMakeLists.txt`, `Export.cpp` and debt-file lines; both sides are kept and the debt count is recomputed from `Export.cpp`. Full build and `ctest -j16`: 3796/3800 pass; `guest_sce_net`, `guest_poll`, `guest_select_wait` and `guest_memory` failed under that load, pass when run alone, and `main` 4f41f4c375 passes all 3799 with `-j16` on the same machine. `check_conventions.py --base upstream/main` passes. ### 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 - [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: #9446, #9571, #10395, #10418, #10448, #10450, #10477, #10478, #10481, #10482 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-24 03:03:09 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-24T03:03:09Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5636518477 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10483#pullrequestreview-5636518477). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-24T03:03:09Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
MarcZX10 commented 2026-10-24 15:58:26 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-24T15:58:26Z.

Review: APPROVED


Reviewed the five context accessors against the cited LibreSSL 2.5.4 layout. The offsets (cert store 16, verify mode 48, callback/userdata 96/104, internal state 112, quiet-shutdown 292) align with the test fixture and static assertions; getters return the intended fields and setters preserve neighboring state. The current head merges cleanly with upstream main (3fcb5e4d76), and convention/diff checks pass. I compiled and ran GuestLibreSslSslCtx.cpp with SslCtx.cpp directly using GCC 12.2.0; it passed. The broader Linux suite in the description is author-reported; hosted product jobs are skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5638869528 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10483#pullrequestreview-5638869528). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-24T15:58:26Z. **Review:** APPROVED --- Reviewed the five context accessors against the cited LibreSSL 2.5.4 layout. The offsets (cert store 16, verify mode 48, callback/userdata 96/104, internal state 112, quiet-shutdown 292) align with the test fixture and static assertions; getters return the intended fields and setters preserve neighboring state. The current head merges cleanly with upstream main (3fcb5e4d76), and convention/diff checks pass. I compiled and ran `GuestLibreSslSslCtx.cpp` with `SslCtx.cpp` directly using GCC 12.2.0; it passed. The broader Linux suite in the description is author-reported; hosted product jobs are skipped.
ahmadmuj commented 2026-10-25 18:05:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T18:05:19Z.

Review: APPROVED


Reviewed head 160698d003 merged onto main 7a25f87620. The only conflict is the debt-file count line, so I took this PR's side for the build. Linux x86_64, GCC 13.3, Release.

What I ran:

  • guest_libressl_ssl_ctx on the merged tree: pass.
  • tools/check_conventions.py --base 0119103fa9: pass.
  • Layout probe compiled against real LibreSSL 2.5.4 (release tarball, SHA256 matches ftp.openbsd.org) with ssl/ssl_locl.h and libssl's own defines: SSL_CTX is 120 bytes, cert_store 16, verify_mode 48, passwd cb/userdata 96/104, internal 112; ssl_ctx_internal_st is 464 bytes, quiet_shutdown 292. Same as the static_asserts.
  • Differential: a real 2.5.4 SSL_CTX_new(TLS_method()) passed to this PR's built libSceLibreSsl.prx. 17/17 checks match:
    • get_cert_store returns LibreSSL's store on a fresh ctx and after SSL_CTX_set_cert_store.
    • get_verify_mode matches SSL_CTX_get_verify_mode on a fresh ctx (0) and after SSL_CTX_set_verify with 1, 3, 5, 7 and -1.
    • set_quiet_shutdown reads back through SSL_CTX_get_quiet_shutdown (1, 0, 7, INT_MIN).
    • Each of the three setters changes exactly the same bytes of the 120 + 464 as the LibreSSL setter does.

Source walk against 2.5.4 ssl_lib.c (2e2c612066): the five bodies are single field reads or writes, and the signatures match ssl.h. The only difference is the null throws, and the debt entry covers those.

Not checked: whether the console module really is 2.5.4. I have no console, and the debt entry already says so.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644547099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10483#pullrequestreview-5644547099). Originally posted by [ahmadmuj](https://github.com/ahmadmuj) on 2026-10-25T18:05:19Z. **Review:** APPROVED --- Reviewed head `160698d003` merged onto main `7a25f87620`. The only conflict is the debt-file count line, so I took this PR's side for the build. Linux x86_64, GCC 13.3, Release. What I ran: - `guest_libressl_ssl_ctx` on the merged tree: pass. - `tools/check_conventions.py --base 0119103fa9`: pass. - Layout probe compiled against real LibreSSL 2.5.4 (release tarball, SHA256 matches ftp.openbsd.org) with `ssl/ssl_locl.h` and libssl's own defines: `SSL_CTX` is 120 bytes, cert_store 16, verify_mode 48, passwd cb/userdata 96/104, internal 112; `ssl_ctx_internal_st` is 464 bytes, quiet_shutdown 292. Same as the static_asserts. - Differential: a real 2.5.4 `SSL_CTX_new(TLS_method())` passed to this PR's built `libSceLibreSsl.prx`. 17/17 checks match: - `get_cert_store` returns LibreSSL's store on a fresh ctx and after `SSL_CTX_set_cert_store`. - `get_verify_mode` matches `SSL_CTX_get_verify_mode` on a fresh ctx (0) and after `SSL_CTX_set_verify` with 1, 3, 5, 7 and -1. - `set_quiet_shutdown` reads back through `SSL_CTX_get_quiet_shutdown` (1, 0, 7, INT_MIN). - Each of the three setters changes exactly the same bytes of the 120 + 464 as the LibreSSL setter does. Source walk against 2.5.4 `ssl_lib.c` ([2e2c612066](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libssl/ssl_lib.c)): the five bodies are single field reads or writes, and the signatures match `ssl.h`. The only difference is the null throws, and the debt entry covers those. Not checked: whether the console module really is 2.5.4. I have no console, and the debt entry already says so.
MarcZX10 commented 2026-10-29 08:59:31 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:59:31Z.

Review: CHANGES_REQUESTED


Re-check — changes requested\n\nThe new report is useful: it says the implementation functions were preserved through the merge and the full test suite has the same single known failure as its tested main, with conventions passing. However, the tested integration point is 4c7d275bef; current upstream main is aaccd0ba39, and this PR head is 44 commits behind it.\n\nPlease update onto current main, preserve the implementation and debt-count changes, recount the pending exports against the resulting Export.cpp, and rerun the relevant LibreSSL tests plus conventions on the exact updated head. The earlier approval was for the prior head and does not cover this stale integration point. I did not rerun these checks locally.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5695134479 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/10483#pullrequestreview-5695134479). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-29T08:59:31Z. **Review:** CHANGES_REQUESTED --- ## Re-check — changes requested\n\nThe new report is useful: it says the implementation functions were preserved through the merge and the full test suite has the same single known failure as its tested main, with conventions passing. However, the tested integration point is 4c7d275bef; current upstream main is aaccd0ba39, and this PR head is 44 commits behind it.\n\nPlease update onto current main, preserve the implementation and debt-count changes, recount the pending exports against the resulting Export.cpp, and rerun the relevant LibreSSL tests plus conventions on the exact updated head. The earlier approval was for the prior head and does not cover this stale integration point. I did not rerun these checks locally.
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!10483
No description provided.