fix(libSceSsl): return the console's codes for a reset and a non-TLS reply in sceSslConnect #15848

Merged
zaryabzip merged 3 commits from upstream-pr/15848 into main 2026-11-07 21:44:01 +00:00
zaryabzip commented 2026-11-04 19:24:15 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by zaryabzip on 2026-11-04T19:24:15Z.


What

sceSslConnect now returns the console's codes for two handshake failures that @hugodearaujo's PS5 payload measured in #11922. The payload ran on system software 13.59, against loopback TLS servers it ran itself; the raw lines are SSL|L3-reset-after-hello|sslconnect=80410136 and SSL|L4-garbage-after-hello|sslconnect=80951d78.

During the handshake Console main
The peer resets after the ClientHello SCE_NET_ERROR_ECONNRESET (0x80410136) SSL_ERROR_SOCKET_CLOSED (0x8095170D)
The peer answers in plain text 0x80951D78 throws (the console's error code is unknown)

The change, in Session::Code for Operation::Connect:

  • MBEDTLS_ERR_NET_CONN_RESET returns ErrorNetReset, as it already does for reads and closes.
  • MBEDTLS_ERR_SSL_INVALID_RECORD returns the new ErrorNotTls (0x80951D78). mbedTLS returns that error from ssl_parse_record_header when the first byte isn't a TLS record type, as an ASCII reply's H (0x48) isn't. See ssl_check_record_type at the pinned 068ff080b3, library/ssl_msg.c.
  • A peer that closes after the ClientHello still returns 0x8095170D (MBEDTLS_ERR_SSL_CONN_EOF), which matches the console's third case in #11922.

libSceHttp2's transport already passes both codes through unchanged (Transport.cpp:44-45), so sceHttp2SendRequest now returns them too. #11922's debt entry recorded that these two needed a libSceSsl change first.

Debt.

  • libSceSsl's connection entry said a reset during the handshake returns SSL_ERROR_SOCKET_CLOSED and wasn't measured. It now gives the three measured handshake codes. It also notes that the plain-text reply was the only refused record header measured; any header mbedTLS refuses is taken to answer the same.
  • libSceHttp2's error-paths entry now lists all seven handshake codes as passed through.

Test. GuestSslTransport gains two server modes that read the whole ClientHello record first:

  • one then closes with SO_LINGER 0, so the client gets an RST;
  • one answers HTTP/1.1 400 Bad Request.

The client checks only sceSslConnect's result, since that is all the payload recorded. On main the test fails at the reset row, which returns 0x8095170D there. I left GuestHttp2Transport alone: its Mode enum is the one line that five open PRs also extend (#11630, #11950, #12305, #15221, #15231).

Overlap: git merge-tree merges this cleanly with main and with every open pull request that touches these four files and merges with main. Those are #11630, #11950, #12305, #13468, #15221, #15231 and #15709. #11470, #12456, #12688, #14085, #14212 and #14308 conflict with it, but each already conflicts with main.

Tested

  • WSL2 and Windows, by me at 41ddd4d6d7 (comment):
    • WSL2: Ubuntu 24.04.5, GCC 13.3.0, Release, merged onto main b611e634f7. ctest -R "guest_ssl|http2" passes all 20 tests, and --repeat until-fail:3 passes every round.
    • Windows: Windows 11 Home 25H2, WinLibs GCC 15.2.0 r7, Release, the head on its base 9ab6a281ea. All 21 tests pass, and every repeat round passes.
    • With Export.cpp from main, guest_ssl_transport_kernel and _net fail with "a reset during the handshake did not report the libSceNet reset code".

Checked so far, on macOS (arm64, where no full build is possible):

  • GuestSslTransport.cpp passes an x86-64 clang++ -fsyntax-only against mbedTLS 068ff080b3's headers, and so do the changed lines of libSceSsl/Export.cpp.
  • tools/check_conventions.py --base 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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes (Claude Code)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5160255961 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15848). Originally posted by [zaryabzip](https://github.com/zaryabzip) on 2026-11-04T19:24:15Z. --- ### What `sceSslConnect` now returns the console's codes for two handshake failures that @hugodearaujo's PS5 payload measured in #11922. The payload ran on system software 13.59, against loopback TLS servers it ran itself; the raw lines are `SSL|L3-reset-after-hello|sslconnect=80410136` and `SSL|L4-garbage-after-hello|sslconnect=80951d78`. | During the handshake | Console | `main` | |---|---|---| | The peer resets after the ClientHello | `SCE_NET_ERROR_ECONNRESET` (0x80410136) | `SSL_ERROR_SOCKET_CLOSED` (0x8095170D) | | The peer answers in plain text | 0x80951D78 | throws (`the console's error code is unknown`) | **The change**, in `Session::Code` for `Operation::Connect`: - `MBEDTLS_ERR_NET_CONN_RESET` returns `ErrorNetReset`, as it already does for reads and closes. - `MBEDTLS_ERR_SSL_INVALID_RECORD` returns the new `ErrorNotTls` (0x80951D78). mbedTLS returns that error from `ssl_parse_record_header` when the first byte isn't a TLS record type, as an ASCII reply's `H` (0x48) isn't. See `ssl_check_record_type` at the pinned `068ff080b3`, `library/ssl_msg.c`. - A peer that closes after the ClientHello still returns 0x8095170D (`MBEDTLS_ERR_SSL_CONN_EOF`), which matches the console's third case in #11922. libSceHttp2's transport already passes both codes through unchanged (`Transport.cpp:44-45`), so `sceHttp2SendRequest` now returns them too. #11922's debt entry recorded that these two needed a libSceSsl change first. **Debt.** - libSceSsl's connection entry said a reset during the handshake returns `SSL_ERROR_SOCKET_CLOSED` and wasn't measured. It now gives the three measured handshake codes. It also notes that the plain-text reply was the only refused record header measured; any header mbedTLS refuses is taken to answer the same. - libSceHttp2's error-paths entry now lists all seven handshake codes as passed through. **Test.** `GuestSslTransport` gains two server modes that read the whole ClientHello record first: - one then closes with `SO_LINGER` 0, so the client gets an RST; - one answers `HTTP/1.1 400 Bad Request`. The client checks only `sceSslConnect`'s result, since that is all the payload recorded. On `main` the test fails at the reset row, which returns 0x8095170D there. I left `GuestHttp2Transport` alone: its `Mode` enum is the one line that five open PRs also extend (#11630, #11950, #12305, #15221, #15231). Overlap: `git merge-tree` merges this cleanly with `main` and with every open pull request that touches these four files and merges with `main`. Those are #11630, #11950, #12305, #13468, #15221, #15231 and #15709. #11470, #12456, #12688, #14085, #14212 and #14308 conflict with it, but each already conflicts with `main`. ### 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. --> - **WSL2 and Windows, by me** at `41ddd4d6d7` ([comment](https://github.com/boykopovar/AnyPS5/pull/15848#issuecomment-6642149255)): - WSL2: Ubuntu 24.04.5, GCC 13.3.0, Release, merged onto `main` `b611e634f7`. `ctest -R "guest_ssl|http2"` passes all 20 tests, and `--repeat until-fail:3` passes every round. - Windows: Windows 11 Home 25H2, WinLibs GCC 15.2.0 r7, Release, the head on its base `9ab6a281ea`. All 21 tests pass, and every repeat round passes. - With `Export.cpp` from `main`, `guest_ssl_transport_kernel` and `_net` fail with "a reset during the handshake did not report the libSceNet reset code". Checked so far, on macOS (arm64, where no full build is possible): - `GuestSslTransport.cpp` passes an x86-64 `clang++ -fsyntax-only` against mbedTLS `068ff080b3`'s headers, and so do the changed lines of `libSceSsl/Export.cpp`. - `tools/check_conventions.py --base 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: <!-- #PR, or none --> none - [x] Fixes: <!-- issue it closes as Fixes #N, or none --> none - [x] Unblocks: <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> none - [x] GPUs tested: <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> n/a - [x] AI-assisted: <!-- yes / no --> yes (Claude Code)
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!15848
No description provided.