feat(ssl): run TLS 1.2 client connections over Mbed TLS #6828
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6828"
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 loyalburrito on 2026-10-16T13:33:07Z.
What
sceSslConnect,sceSslReadandsceSslWriteno longer throwNotImplemented: they run a TLS 1.2 client over the Mbed TLS 3.6.7 submodule.KernelLookupSocketNative_nid_no_patch. It checks libkernel's socket table, then the one libSceNet registers, so bothsocket()andsceNetSocketnumbers work.sceSslDeleteConnection. Each pool now has its own lock, so a handshake or read does not hold the library lock. A connection keeps its pool alive aftersceSslTerm.sceSslLoadCert(chain, validity dates, host name, also sent as SNI). A loaded client certificate is sent when the server asks for one.MbedConfig.hppturns offMBEDTLS_SSL_PROTO_TLS1_3, and libSceSsl now links thembedtlsSSL library. SharpProspero'sSceSslVersionstops at TLS 1.2, and Mbed TLS's TLS 1.3 needs process-wide PSA state that can't come from a context's pool.docs/dev/debt/libSceSsl.mdrecords everything that throws or isn't verified on a console.Questions for maintainers
Anything the sources don't settle throws for now:
sceSslConnectthrows, because no root bundle is shipped. Should a host bundle be trusted? #5280 serves the host's CA bundle to the sandbox, which could fill this.sceSslConnectthrow. SharpProspero gives the arguments (an id, failure bits, the chain, its length, the user argument; a negative return fails the handshake), but not whether the id is the context or the connection, what the bits mean, what type the chain entries are, or when the callback runs.0x8095F006,0x8095F004,0x8095F007and sharpemu's0x8095F008are known.sceSslReadwith flags 0. It returns what one record read delivers, the same asMsgFlagPartialRead(1). SharpProspero leaves open whether flags 0 waits to fill the buffer. Peek (3) throws.Overlap
#5911 (verify options, min version, ALPN), #5953 and #5969 (certificate readers; #5969 also changes
sceSslClose's signature) and #6511 (certificate reader arguments) editlibSceSsl/Export.cppand its debt entry, but none implements the handshake or I/O. Whichever merges second will need a rebase; I'm happy to do it.#6044 (test reorganization) conflicts in
core/libs/prx/libSceSsl/CMakeLists.txt: it moves the SSL tests tocore/libs/tests/networking/and registers them withadd_library_test. Whichever lands second movesGuestSslTransport.cpp(andSslCertificateFixture.hpp, if #6044 moves it) there and registersguest_ssl_transport_kernelandguest_ssl_transport_netthe same way. #6222 also editscore/libs/prx/libkernel/Socket/src/Udp.cppbut merges cleanly with this PR.Tested
Tested locally by the author on a machine with an NVIDIA GeForce RTX 3080 (12 GB).
Linux (Ubuntu 24.04, GCC 13), full Release build with
BUILD_TESTING=ON, merged with currentmain:guest_ssl_transport_kernelandguest_ssl_transport_netrun an in-process Mbed TLS server on loopback that requires a client certificate, about 0.3 s each:PoolCalloc.guest_sslandguest_ssl_load.windowsjob ofbuild.yml, run on a GitHub-hostedwindows-latestrunner with this PR merged intomain(run 38911524761, jobwindows). Configure, test registration,cmake --build build,--target libs, the fullctest --parallel 4andcheck_skips.py --job windowsall pass.guest_ssl,guest_ssl_load,guest_ssl_transport_kernel,guest_ssl_transport_netandguest_memory_pool_statsran and passed, the transport tests over Winsock loopback sockets; the 494 skips are all expectedagc*and display/Vulkan tests (the runner has no Vulkan driver), and no test went over 30 s. The Linux job of that run was not run, as it needs upstream's self-hosted runner; Linux is covered above.agc_driver_graphics,guest_datagram_*×4,guest_named_shm_concurrencyandguest_tcpfail the same way on unmodifiedmainin that container (no IPv6, running as root, "VOP2 opcode is not implemented").guest_kernel_fcntlaborted once under full-suite load. It then passed 30 runs alone and 3 loaded runs of all guest tests.python3 tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functionsNotImplemented_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 MarcZX10 on 2026-10-16T13:34:13Z.
The current conventions check is failing because the PR description labels
What,Tested, andChecklistare plain text; the repository template requires Markdown headings (for example### What). Please reformat those section headers and rerun conventions. I also noticed the new transport path is a substantial addition that is not built with the WinLibs toolchain, so please keep the platform-specific build status explicit as you have in the body.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T13:40:07Z.
Thanks for fixing the template; the latest conventions run passes. I reviewed the socket ownership, per-session locking, pool lifetime and error cleanup, and do not have a concrete correctness finding to request. One validation gap remains before I can recommend merge: this adds direct Winsock
send/recv, Windows test setup, and MinGW-specific Mbed TLS compile options, but neither the PR report nor current checks include a build with the supported WinLibs toolchain (the platform jobs are absent). Could you run the focused transport target and relevant SSL tests with that toolchain, or explain which known environment limitation prevents it? The Ubuntu MinGW syntax check does not validate the project’s Windows build/link setup.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T14:39:34Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceSsl/CMakeLists.txtL78, L80-81docs/dev/debt/libSceSsl.mdL7-8Some 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.
core/libs/prx/libkernel/Socket/src/Udp.cppdocs/dev/debt/libSceSsl.mdcore/libs/prx/libSceSsl/CMakeLists.txtcore/libs/tests/SslCertificateFixture.hppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppcore/libs/prx/libkernel/Socket/src/Udp.cppImported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T14:46:02Z.
I attempted a project-level Windows cross-configuration on this Linux host with its installed
x86_64-w64-mingw32-g++(GCC 12-posix). CMake stops at the repository's MinGW exception-model check: this compiler selects SjLj exceptions with-fno-asynchronous-unwind-tables, while AnyPS5 requires DWARF unwinding. This toolchain therefore cannot provide the requested project build, link, or Windows runtime validation, and it is not a substitute for the supported WinLibs toolchain. The Windows validation gap remains open.Imported from boykopovar/AnyPS5. Originally posted by loyalburrito on 2026-10-16T18:32:34Z.
@MarcZX100 thanks for the review. The WinLibs build now exists, so the Windows gap should be closed.
I ran this repository's own windows job from build.yml (WinLibs MinGW-w64 GCC 15.2.0 posix-seh ucrt r7, windows-latest) from my fork, with this PR's head
9ce634amerged into main: run 38911524761, job windows. Every step passed:configure, including the MinGW -fno-asynchronous-unwind-tables options on the Mbed TLS targets
check_test_registration.py
cmake --build build, which links libSceSsl.prx against Winsock and guest_ssl_transport_tests against ws2_32/bcrypt
cmake --build build --target libs
the full ctest --parallel 4
check_skips.py --job windows: "494 test(s) skipped, all expected" (only agc* and display/Vulkan tests; the runner has no Vulkan driver)
the slow-test report: nothing over 30 s
So guest_ssl, guest_ssl_load, guest_ssl_transport_kernel, guest_ssl_transport_net and guest_memory_pool_stats ran and passed on Windows. The two transport tests ran the handshake, round trip and four parallel connections over Winsock loopback sockets, using the direct send/recv path and the PATH setup for the test runs. That run's Linux job is skipped, because it needs the self-hosted runner. Linux is covered by my local full build with ASan/UBSan and TSan.
On your cross-configuration attempt: that matches what I'd expect. The repository's exception-model check rejects SjLj toolchains such as GCC 12-posix, which is why I used the pinned WinLibs zip through the project's own job instead.
I've updated the description's Windows line with these results. Since then, upstream main has moved 22 commits; none touches these files, the PR still merges cleanly, and the SSL tests pass on the merge. Upstream's own Windows and Linux jobs still need a maintainer to approve the workflows.
Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-17T09:50:06Z.
Rebase handoff — rebased onto current
main(the two authored commits, authorship unchanged; the head's empty merge flattened away). The conflicts reconciledmain's newer SSL context state with this PR's Mbed TLS session design:SslConnectionkeepsmain'sverifyOptions/minimumVersion/alpnfields alongside yourshared_ptr<Session>oid.hformain's cert-name readers,error.h/net_sockets.hfor yourSession)main's restructuring with your connection-entry rewrite andsceSslLoadCerttail applied; two ofmain's clauses were minimally reworded where your transport made them stale ("untilsceSslConnecthas a transport" → "nothing reads them"; "as no handshake completes" → "as the protocol negotiated by the handshake is not read") — worth your eyeverifyOptions/minimumVersion/alpnare recorded but not yet consumed bySession::Configure— wiring them into the Mbed TLS config would be new work beyond both diffsVerified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, AMD RX 9070 XT / RADV):tools/check_conventions.py --base origin/mainpassesmainregression (agc_driver_tessellationsegfault, #4727), not this PR; the SSL transport tests passTo pick it up:
Head is
925c37aa0.Imported from boykopovar/AnyPS5. Originally posted by frankea on 2026-10-18T04:02:41Z.
@loyalburrito the one gap blawesom's handoff left, the recorded verify options, minimum version and ALPN that
Session::Configurenever reads, I've done against your branch as a pull request to your fork: https://github.com/loyalburrito/AnyPS5/pull/3. It makessceSslConnectreturn the console'sSSL_ERROR_*verification codes underVERIFY_OPTIONALinstead of requiring a loaded CA and throwing, offers the ALPN list and reports the selection, floors the version at TLS 1.2, and maps would-block, reset, timeout and fatal-alert to their codes so a non-blocking socket can resume the handshake. The verify callback,sceSslCloseand the initial-options default are left as they are. Built with WinLibs on Windows 11, the two transport tests rewritten and passing withguest_ssl,guest_ssl_loadand the pool-stats test; details in the fork PR. Take it, cherry-pick it, or tell me what you'd rather see; it's your PR. My #7319 stays a draft on top of this.AI-assisted: yes (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T06:02:07Z.
The offered follow-up on loyalburrito/AnyPS5#3 directly addresses the gap from the rebase review: the connection’s verify options, ALPN list, and minimum-version field are now consumed, with focused Windows transport tests reported passing. I have reviewed the changed handshake and result-code paths and am checking this independently before carrying it onto #6828; the report still identifies non-blocking socket behavior as untested end to end. I will keep the handoff separate until that review is complete.