Skip to content

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

Merged
oneandonlydean merged 3 commits into
boykopovar:mainfrom
zaryabzip:fix/ssl-connect-reset-and-plain-reply
Nov 7, 2026
Merged

oneandonlydean merged 3 commits into
boykopovar:mainfrom
zaryabzip:fix/ssl-connect-reset-and-plain-reply

Conversation

@zaryabzip

@zaryabzip zaryabzip commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

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 fix(libSceHttp2): return the console codes for failed TLS handshakes #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)

…reply in sceSslConnect

A PS5 payload measured 0x80410136 when the peer resets during the
handshake and 0x80951D78 when it answers in plain text (boykopovar#11922). The host
returned SSL_ERROR_SOCKET_CLOSED for the first and threw for the second.
…hut it down

mbedtls_net_free shuts the socket down before closing it, which sends a
FIN ahead of the RST, so the client saw a clean end instead of a reset.
Close it with SO_LINGER 0 here, as Reset() already does (found by the
Windows run).
@zaryabzip

Copy link
Copy Markdown
Contributor Author

Windows and WSL2 run at 41ddd4d6d7, with the negative control.

  • WSL2, Ubuntu 24.04.5 (kernel 6.18.54.1), GCC 13.3.0, Release:
    • Merged onto main b611e634f7, a clean merge.
    • ctest -R "guest_ssl|http2" runs 20 tests, and all pass.
    • With --repeat until-fail:3, 20 of 20 pass in each of the 3 rounds.
  • Windows 11 Home 25H2 (26200.9711), WinLibs GCC 15.2.0 r7 UCRT, Release:
    • The head itself, on its base 9ab6a281ea.
    • 21 tests, all pass, and 21 of 21 in each of the 3 rounds. guest_http2_dns_first is registered only on Windows.
  • Neither build has warnings in Export.cpp or GuestSslTransport.cpp.
  • Control (Export.cpp from main, this PR's test kept): on both, guest_ssl_transport_kernel and guest_ssl_transport_net exit with 1 and a reset during the handshake did not report the libSceNet reset code.
  • At the previous head b642815135, both transport tests failed with that same message, on both systems. The reset socket was shut down by mbedtls_net_free first, so the client read a clean EOF; on Windows sceSslConnect returned 0x8095170d. 41ddd4d6d7 closes the socket directly, as the existing Reset case already did.

AI-assisted: yes (Claude Code)

@github-actions

github-actions Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 12688 core/libs/prx/libSceSsl/Export.cpp
core/libs/tests/GuestSslTransport.cpp
docs/dev/debt/libSceSsl.md
PR 12700 core/libs/prx/libSceSsl/Export.cpp
core/libs/tests/GuestSslTransport.cpp
docs/dev/debt/libSceSsl.md
PR 12965 core/libs/prx/libSceSsl/Export.cpp
core/libs/tests/GuestSslTransport.cpp
docs/dev/debt/libSceSsl.md
PR 13468 core/libs/prx/libSceSsl/Export.cpp
docs/dev/debt/libSceSsl.md
PR 14212 docs/dev/debt/libSceHttp2.md
docs/dev/debt/libSceSsl.md
PR 16231 docs/dev/debt/libSceHttp2.md
PR 16292 docs/dev/debt/libSceHttp2.md

@oneandonlydean oneandonlydean self-assigned this Nov 7, 2026
@oneandonlydean
oneandonlydean merged commit 4138def into boykopovar:main Nov 7, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants