feat(libSceLibreSsl3): implement OPENSSL_init_ssl #15631

Merged
alvaroelpob merged 10 commits from upstream-pr/15631 into main 2026-11-07 20:34:12 +00:00
alvaroelpob commented 2026-11-03 22:29:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by alvaroelpob on 2026-11-03T22:29:12Z.


What

Implements OPENSSL_init_ssl in libSceLibreSsl3. In LibreSSL 4.0.0 ssl_init.c, where SSL_library_init calls it, it returns 1 and its work is OPENSSL_init_crypto, the error string loaders, which are empty in the firmware module, and the configuration step: OPENSSL_INIT_NO_LOAD_CONFIG settles the configuration without loading it, and OPENSSL_INIT_LOAD_CONFIG before that throws, because loading the console's configuration file is not modelled.

Tested

Linux x86-64 (WSL2), Release: the full build passes and ctest --test-dir build -j16 passes 3883 of 3883 tests, including the new guest_libressl3_init_ssl, at head f607f72a09, rebased on main b11c7bf84f. The test fails if the OPENSSL_INIT_LOAD_CONFIG throw is removed. python3 tools/check_conventions.py --base upstream/main passes. Not run on a console or in a title.

Checklist

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5145497560 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15631). Originally posted by [alvaroelpob](https://github.com/alvaroelpob) on 2026-11-03T22:29:12Z. --- ### What Implements `OPENSSL_init_ssl` in libSceLibreSsl3. In LibreSSL 4.0.0 [`ssl_init.c`](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libssl/ssl_init.c#L29-L58), where `SSL_library_init` calls it, it returns 1 and its work is `OPENSSL_init_crypto`, the error string loaders, which are empty in the firmware module, and the configuration step: `OPENSSL_INIT_NO_LOAD_CONFIG` settles the configuration without loading it, and `OPENSSL_INIT_LOAD_CONFIG` before that throws, because loading the console's configuration file is not modelled. ### 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. --> Linux x86-64 (WSL2), Release: the full build passes and `ctest --test-dir build -j16` passes 3883 of 3883 tests, including the new `guest_libressl3_init_ssl`, at head f607f72a09, rebased on `main` b11c7bf84f. The test fails if the `OPENSSL_INIT_LOAD_CONFIG` throw is removed. `python3 tools/check_conventions.py --base upstream/main` passes. Not run on a console or in a title. ### 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: #12945, #14366, #14889, #14890, #14992, #15031, #15045, #15119, #15289, #15303, #15472, #15514, #15544, #15591, #15599, #15616, #15618, #15620, #15622, #15623, #15624, #15625, #15627, #15628, #15629 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
XairRrR commented 2026-11-03 23:11:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T23:11:57Z.

Review: COMMENTED


Reviewed — comments

The change merges cleanly, builds, and passes its test, and the negative control fails as it should. One question about behaviour is still open: in LibreSSL, OPENSSL_init_ssl also runs SSL_library_init. This implementation skips that step, and the repository's own SSL_library_init still throws.

What I ran

Head 996523a7520f60fc362ae80d5940e9b08616077d merged into main 1c8c0efc8c41314402e6966da5bef6ea3d639d10 (merged tree ca6ffc2e63ee22ee03a33c7c8dc8a3f1aa7a4d6e). Debian 13 VM, GCC 14.2.0, Release, Ninja.

git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...996523a7520f60fc362ae80d5940e9b08616077d
python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10
ctest --test-dir build --output-on-failure -R "guest_libressl3_init_ssl|guest_libressl3_version"
ctest --test-dir build --output-on-failure -R public_headers
# negative control: src/InitSsl.cpp replaced by a throwing stub (main's behaviour, new signature kept)
ninja -C build -j32 -l32 guest_libressl3_init_ssl_tests
ctest --test-dir build --output-on-failure -R "^guest_libressl3_init_ssl$"
# restored from the merged tree, rebuilt, reran, git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed
Build (script) ok
Selected tests (script) 831/835 passed. 3 skips were expected. The one failure (unwrap_self_..._inherits_the_destination_directory_group) also fails on main, so it is not caused by this PR
guest_libressl3_init_ssl Passed (0.01 s)
public_headers* (65 tests) all passed
Vulkan validation skipped, because no AGC, shader or VideoOut file changed

Negative control

I replaced src/InitSsl.cpp with a stub that has the same signature and calls NotImplemented_nid_no_patch, which is what main does. After a rebuild, guest_libressl3_init_ssl failed:

output
terminate called after throwing an instance of 'std::runtime_error'
  what():  OPENSSL_init_ssl_nid_postfix not implemented
1/1 Test #2874: guest_libressl3_init_ssl .........Subprocess aborted

I then restored the merged file and rebuilt. The test passes again, and git status --porcelain is empty.

Findings

Blocking

None.

Non-blocking

  1. SSL_library_init step is not accounted for. In LibreSSL, the once-only initialisation of OPENSSL_init_ssl runs both SSL_load_error_strings() and SSL_library_init().

    • The debt entry only says that "the string loaders it runs are empty in the firmware 13.42 module".
    • InitSsl.cpp#L16-L20 skips SSL_library_init without saying why.
    • The repository's SSL_library_init in libSceLibreSsl still throws (Export.cpp#L966-L969). The code base therefore treats that step as unimplemented, but OPENSSL_init_ssl silently treats it as done.

    If the firmware's SSL_library_init (and the EVP_add_* calls it makes) really does nothing observable, please say so in the debt entry with the same evidence, and ideally make SSL_library_init return 1 in a follow-up. Otherwise, OPENSSL_init_ssl should throw like SSL_library_init does.

  2. The throw path is not tested. The test only calls OPENSSL_INIT_LOAD_CONFIG after the configuration is settled. No test checks that OPENSSL_INIT_LOAD_CONFIG throws in a fresh process. A second small executable, registered with WILL_FAIL or as a death-style check, would cover the one branch that differs from "return 1".

  3. Duplicate if(WIN32) block. CMakeLists.txt#L114-L121 adds a separate if(WIN32) block that sets the same PATH modification. Adding guest_libressl3_init_ssl to the existing set_tests_properties list below it would avoid repeating the block.

Not verified

  • I could not read the cited LibreSSL ssl_init.c lines or the firmware 13.42 disassembly comment, because there was no network. The claims that the return value is always 1 and that the loaders are empty are taken from the description, not checked.
  • The Windows/MinGW build and the PATH setup were not tested.
  • Nothing was checked on a console.

To get this to a good state

Explain in the debt entry why skipping SSL_library_init matches the console, or make the function throw until it is settled. Optionally, add a test for the OPENSSL_INIT_LOAD_CONFIG throw path.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5760810801 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15631#pullrequestreview-5760810801). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T23:11:57Z. **Review:** COMMENTED --- # Reviewed — comments The change merges cleanly, builds, and passes its test, and the negative control fails as it should. One question about behaviour is still open: in LibreSSL, `OPENSSL_init_ssl` also runs `SSL_library_init`. This implementation skips that step, and the repository's own `SSL_library_init` still throws. ## What I ran Head `996523a7520f60fc362ae80d5940e9b08616077d` merged into `main` `1c8c0efc8c41314402e6966da5bef6ea3d639d10` (merged tree `ca6ffc2e63ee22ee03a33c7c8dc8a3f1aa7a4d6e`). Debian 13 VM, GCC 14.2.0, Release, Ninja. ``` git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...996523a7520f60fc362ae80d5940e9b08616077d python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10 ctest --test-dir build --output-on-failure -R "guest_libressl3_init_ssl|guest_libressl3_version" ctest --test-dir build --output-on-failure -R public_headers # negative control: src/InitSsl.cpp replaced by a throwing stub (main's behaviour, new signature kept) ninja -C build -j32 -l32 guest_libressl3_init_ssl_tests ctest --test-dir build --output-on-failure -R "^guest_libressl3_init_ssl$" # restored from the merged tree, rebuilt, reran, git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | All conventions checks passed | | Build (script) | ok | | Selected tests (script) | 831/835 passed. 3 skips were expected. The one failure (`unwrap_self_..._inherits_the_destination_directory_group`) also fails on `main`, so it is not caused by this PR | | `guest_libressl3_init_ssl` | Passed (0.01 s) | | `public_headers*` (65 tests) | all passed | | Vulkan validation | skipped, because no AGC, shader or VideoOut file changed | ## Negative control I replaced `src/InitSsl.cpp` with a stub that has the same signature and calls `NotImplemented_nid_no_patch`, which is what `main` does. After a rebuild, `guest_libressl3_init_ssl` failed: <details><summary>output</summary> ``` terminate called after throwing an instance of 'std::runtime_error' what(): OPENSSL_init_ssl_nid_postfix not implemented 1/1 Test #2874: guest_libressl3_init_ssl .........Subprocess aborted ``` </details> I then restored the merged file and rebuilt. The test passes again, and `git status --porcelain` is empty. ## Findings ### Blocking None. ### Non-blocking 1. **`SSL_library_init` step is not accounted for.** In LibreSSL, the once-only initialisation of `OPENSSL_init_ssl` runs both `SSL_load_error_strings()` and `SSL_library_init()`. - The debt entry only says that "the string loaders it runs are empty in the firmware 13.42 module". - [`InitSsl.cpp#L16-L20`](https://github.com/boykopovar/AnyPS5/blob/996523a7520f60fc362ae80d5940e9b08616077d/core/libs/prx/libSceLibreSsl3/src/InitSsl.cpp#L16-L20) skips `SSL_library_init` without saying why. - The repository's `SSL_library_init` in libSceLibreSsl still throws ([`Export.cpp#L966-L969`](https://github.com/boykopovar/AnyPS5/blob/1c8c0efc8c41314402e6966da5bef6ea3d639d10/core/libs/prx/libSceLibreSsl/Export.cpp#L966-L969)). The code base therefore treats that step as unimplemented, but `OPENSSL_init_ssl` silently treats it as done. If the firmware's `SSL_library_init` (and the `EVP_add_*` calls it makes) really does nothing observable, please say so in the debt entry with the same evidence, and ideally make `SSL_library_init` return 1 in a follow-up. Otherwise, `OPENSSL_init_ssl` should throw like `SSL_library_init` does. 2. **The throw path is not tested.** The test only calls `OPENSSL_INIT_LOAD_CONFIG` after the configuration is settled. No test checks that `OPENSSL_INIT_LOAD_CONFIG` throws in a fresh process. A second small executable, registered with `WILL_FAIL` or as a death-style check, would cover the one branch that differs from "return 1". 3. **Duplicate `if(WIN32)` block.** [`CMakeLists.txt#L114-L121`](https://github.com/boykopovar/AnyPS5/blob/996523a7520f60fc362ae80d5940e9b08616077d/core/libs/prx/libSceLibreSsl3/CMakeLists.txt#L114-L121) adds a separate `if(WIN32)` block that sets the same `PATH` modification. Adding `guest_libressl3_init_ssl` to the existing `set_tests_properties` list below it would avoid repeating the block. ## Not verified - I could not read the cited LibreSSL `ssl_init.c` lines or the firmware 13.42 disassembly comment, because there was no network. The claims that the return value is always 1 and that the loaders are empty are taken from the description, not checked. - The Windows/MinGW build and the `PATH` setup were not tested. - Nothing was checked on a console. ## To get this to a good state Explain in the debt entry why skipping `SSL_library_init` matches the console, or make the function throw until it is settled. Optionally, add a test for the `OPENSSL_INIT_LOAD_CONFIG` throw path. <!-- anyps5-bots job=3694 head=996523a7520f60fc362ae80d5940e9b08616077d -->
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!15631
No description provided.