feat(libSceSsl): run the TLS handshake and I/O over the title's socket with Mbed TLS #7319
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7319"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-17T23:21:16Z.
What
sceSslConnect,sceSslRead,sceSslWriteandsceSslClosethrewNotImplementedbecause libSceSsl had no transport; Gran Turismo 7 (PPSA01317) on currentmainwith #7137, #7207 and #7175 stops on exactly that line after the save-data mount (#6350, D4697), and PPSA07411 imports the same calls. This gives the library a real client transport on the Mbed TLS 3.6.7 already vendored for its certificate handling.KernelFindSocketNative_nid_no_patch), so the title's own socket, blocking or not, carries the TLS session.sceSslSetAlpnstring is split on commas and negotiated;sceSslGetAlpnSelectedreturns the result.SERVER_VERIFY,CN_CHECK,NOT_AFTER_CHECK,NOT_BEFORE_CHECK,KNOWN_CA_CHECK, values from SharpProspero) after the handshake and returns the matchingSSL_ERROR_*code; a verify callback gets the connection id, that code, handles to a copy of the peer chain (usable withsceSslGetSubjectNameand friends), the chain length and the user argument, and a negative return fails the connect withSSL_ERROR_APPLICATION_VERIFICATION_CALLBACK_CHECK. A failed verification closes the session with a close notify and is sticky: latersceSslConnectcalls return the same code and read/write throw.SSL_ERROR_WANT_POLLIN/WANT_POLLOUTfrom connect, read and write; timeouts, close notify, resets and fatal alerts map to theirSSL_ERROR_*codes (values from KytyPS5's errno.h, which the file already cited); an exhausted memory pool isSSL_ERROR_OUT_OF_MEMORYrather than a thrownbad_alloc.sceSslTermtears down its connections' transports first so nothing frees into a dead pool. Connections carry their own I/O lock (taken before the global map lock), so one blocking read does not stall every other SSL call. The verify callback runs with that lock held, so it must not call back into the same connection; the debt note says so.sceSslClosetakes the connection id (SharpProspero) instead of no argument.SERVER_VERIFYwithKNOWN_CA_CHECKonly passes for CAs the title loaded; whether the console's libSceSsl consults a system store is unknown.docs/dev/debt/libSceSsl.mdrewritten for what is real now and what is still unmeasured on a console.Tested
Windows 11 (26200), MinGW-w64 GCC 15.2.0 r7, Release, RTX 4090 (NVIDIA 616.92).
guest_ssl_transport: an in-process Mbed TLS server with a generated P-256 self-signed certificate on a loopback port; the client goes through libSceNet sockets and the publicsceSsl*calls. Covers the happy path with ALPN and echo,SSL_ERROR_EOFon the server's close notify, unknown CA (and that a second connect returns the same code while read/write throw), CN mismatch, CN check disabled, verification disabled, a verify callback that accepts an untrusted chain and reads the peer's subject through the handles, one that rejects, the non-blocking handshake/read/write loop withWANT_POLLIN/WANT_POLLOUT, and an unknown socket.guest_ssl,guest_ssl_load,guest_memory_pool_statsunchanged; 4/4 pass.maine1041f6a5+ #7137 + #7207 + #7175 with this libSceSsl.prx swapped in: 3 of 3 runs no longer stop onsceSslConnect not implemented; the title gets through its network setup and stops about 28 s after launch on the next gap,AGC graphics: blending into an 11_11_10 float color target is unsupported(the blend path for the targets #7207 adds). libSceSsl does not log, so whether the connect returned 0 or a verification code to the title is not visible in the run; the title's own handling moved it past where it used to die.fcntl/MSG_NOSIGNALbranches of the two socket callbacks.Checklist
main; no other open PR implements the same functions (correction, 10/17: #6828 does implementsceSslConnect/Read/Writeand was opened first; this PR now builds on it and is a draft until it merges, see the overlap comment below)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T23:22:03Z.
Progress report (
3de84fa→431bf44)📈 System libraries: 90.35% (+0.1%, +4 implemented functions)
✅ 4 implemented
sceSslClosesceSslConnectsceSslReadsceSslWriteImported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-17T23:33:16Z.
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.
docs/dev/debt/libSceSsl.mdcore/libs/prx/libSceSsl/CMakeLists.txtcore/libs/prx/libSceSsl/CMakeLists.txtcore/libs/prx/libSceSsl/Export.cppdocs/dev/debt/libSceSsl.mdcore/libs/prx/libSceSsl/CMakeLists.txtImported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-18T00:39:04Z.
The overlap bot is right about #6828, and I should have found it before opening this: it implements the same three calls over the same Mbed TLS submodule, was opened a day earlier, has a review and a rebase handoff, so it is the base. The checklist line "no other open PR implements the same functions" in this description was wrong; I'm correcting it to
Depends on: #6828and parking this PR as a draft until #6828 lands.What I'd then rebase this down to is the part #6828 leaves throwing or unread, which is also what its "questions for maintainers" list and the rebase handoff note flag:
verifyOptions,minimumVersionandalpnare recorded onmain(#5911) but, per the handoff note, not consumed by #6828's session. Here they configure the Mbed TLS context (verification mode and the option mask, minimum version, ALPN list split on commas) andsceSslGetAlpnSelectedreturns the negotiated protocol.SERVER_VERIFY0x1,CN_CHECK0x4,NOT_AFTER_CHECK0x8,NOT_BEFORE_CHECK0x10,KNOWN_CA_CHECK0x20) for what failed, the chain entries are certificate handles in the connection's context (usable withsceSslGetSubjectNameand friends), it runs after the handshake, and a negative return fails the connect withSSL_ERROR_APPLICATION_VERIFICATION_CALLBACK_CHECK(0x8095F0FD). Which of these the console really does is still unmeasured, so this stays in the debt note either way.SSL_ERROR_WANT_POLLIN/WANT_POLLOUT(0x8095F013/14) from connect, read and write on a non-blocking socket,READ_TIMEOUT(0x80951710) whenSO_RCVTIMEOexpires,EOF(0x8095177C) on close_notify,SOCKET_CLOSED(0x8095170D),FATAL_ALERT(0x8095F010), and the verification codesUNKNOWN_CA,CN_CHECK,NOT_AFTER,NOT_BEFORE,INVALID_CERT(0x8095F00C, 0x8095F00B, 0x8095F00D, 0x8095F00E, 0x8095F00A); an exhausted pool isOUT_OF_MEMORY(0x809517D5) rather than a thrownbad_alloc. A failed verification is sticky: the session is closed with a close_notify, latersceSslConnectcalls return the same code, and read/write throw.sceSslClose(id)sending the close_notify, which is the same signature change #5969 and #6511 carry; whichever lands first, the other rebases.On TLS 1.3 I'd follow #6828: it is compiled out there because Mbed TLS 1.3 needs process-wide PSA state that can't come from a context's pool, and nothing here depends on 1.3.
One datapoint that may matter for #6828's open questions 1 and 2: Gran Turismo 7 (PPSA01317) on
main+ #7137/#7207/#7175 stops onsceSslConnect not implemented, and with this transport it gets past the call 3 of 3 (to the next stop, an 11_11_10 blend target). libSceSsl doesn't log, so I can't see from the runs whether the title loads a CA or sets a verify callback. If it's useful before #6828 merges, I can swap #6828'slibSceSsl.prx(and its libkernel) into that layout on the 4090 and report whether the title gets through or hits one of its throws.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-18T05:58:53Z.
Thanks for this work. We're going ahead with #6828 for the libSceSsl transport, so we won't merge this PR as it is. #6828 is built with Mbed TLS threading on and TLS 1.3/PSA off, it locks the connection pool, and it also resolves libkernel
socket()descriptors.This PR has several features #6828 doesn't, and we'd like to keep them. Once #6828 lands, could you port these onto it as a follow-up PR?
sceSslGetAlpnSelectedsceSslCloseYour
guest_ssl_transporttest (in-process server, verify codes, callback, ALPN, non-blocking connect) would be a good fit there too. One more thing: please leave the title IDs out of the libSceSsl.md debt entry. New docs text doesn't name specific titles.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-18T10:21:13Z.
Heads-up: this PR is a parallel implementation of already-merged work. #6828 ("feat(ssl): run TLS 1.2 client connections over Mbed TLS") merged yesterday —
mainnow runs the TLS handshake and I/O over Mbed TLS through the title's socket, with the samesceSslConnect/sceSslDeleteConnectionsurface this PR implements (~800 lines ofExport.cppoverlap; the rebase conflicts against it are exactly that). Your branch's shape predates that landing, so the practical options are reducing this PR ontomain's implementation (keeping whatever it genuinely adds beyond #6828 — your transport test coverage is substantial at +459 lines and may be the valuable delta) or closing it as superseded — your call with the maintainers. I have a verified rebase of the #6828 lineage onblawesom:rebase/6828if a comparison base helps.Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-18T17:15:57Z.
@oneandonlydean agreed, and thanks for the list. Closing this one as superseded by #6828. The follow-up PR on
mainwill carry exactly those four pieces on top of #6828's session design: non-blocking sockets with a handshake that resumes, the verify options and the guest verify callback (run outside the connection's lock), ALPN withsceSslGetAlpnSelected, andsceSslClose, with the in-process server test ported to cover them, and no title IDs in the debt entry. It also takes in loyalburrito's review of the first cut (loyalburrito/AnyPS5#3): the initial verify options become all five checks so a connection fails closed, the reset and timeout mappings are either made real in the BIO or kept as throws, and the inferred situation-to-code choices are listed as unverified.AI-assisted: yes (Claude Code).
Pull request closed