Repository navigation
feat(ssl): run TLS 1.2 client connections over Mbed TLS - #6828
Conversation
sceSslConnect performs the client handshake on the host socket that the guest number maps to in the libkernel or libSceNet socket table, and sceSslRead and sceSslWrite carry application data. Session state comes from the context's memory pool, and the server is verified against the CAs loaded with sceSslLoadCert; a loaded client certificate is sent when the server asks for one. libkernel exports KernelLookupSocketNative_nid_no_patch, which checks its own socket table before the one libSceNet registers. Pools take a lock so connections can allocate outside the library lock. TLS 1.3 is compiled out. A missing CA, a verify callback, would-block sockets and every failure whose console code is unknown throw, as recorded in the libSceSsl debt entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoU3ZF76A6uR8sCA7NMLch
feat(ssl): run TLS 1.2 client connections over Mbed TLS
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoU3ZF76A6uR8sCA7NMLch
Each client thread handshakes, writes, reads the reply and the end of the stream, so session setup and record allocations from several threads contend for the same context pool. The pool memory must return to its loaded size afterwards. Initialize the pool's mutex explicitly, which -Wextra asks for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoU3ZF76A6uR8sCA7NMLch
|
The current conventions check is failing because the PR description labels |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoU3ZF76A6uR8sCA7NMLch
|
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 |
|
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.
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.
|
|
I attempted a project-level Windows cross-configuration on this Linux host with its installed |
|
@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 9ce634a merged into main: run 38911524761, job windows. Every step passed: configure, including the MinGW -fno-asynchronous-unwind-tables options on the Mbed TLS targets 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. |
|
Rebase handoff — rebased onto current
Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
Brings in main's connection verify options, minimum version, ALPN and certificate readers. The conflicts in libSceSsl/Export.cpp and the libSceSsl debt entry take the resolution from blawesom's rebase of this pull request (blawesom/AnyPS5 rebase/6828 at 925c37a): SslConnection keeps main's verifyOptions, minimumVersion and alpn next to the session, and the debt entries follow main's structure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoU3ZF76A6uR8sCA7NMLch
With MBEDTLS_SELF_TEST, ecp.c counts point additions, doublings and field multiplications in unsynchronized globals. Handshakes on separate connections run in parallel, each under its own session lock, so the counters race; ThreadSanitizer reports it on the parallel transport test. Nothing calls the self-test functions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoU3ZF76A6uR8sCA7NMLch
|
@loyalburrito the one gap blawesom's handoff left, the recorded verify options, minimum version and ALPN that AI-assisted: yes (Claude Code). |
|
The offered follow-up on loyalburrito#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. |
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? feat(libkernel): serve the sandbox CA bundle from host TLS roots #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)