Repository navigation
net: TLS in the connection engine (ARIADNE_NET_ENGINE N3) - #1552
Merged
Merged
Conversation
Listener TLS for cvc::net's connection engine, through OpenSSL's libssl (optional; Boost.Asio's ssl::context loads the files): - listener_options.tls (tls_options): certificate and key files, TLS 1.2 and 1.3 with the minimum as a setting, cipher lists, a client certificate asked for and accepted as sent, a handshake timeout, and a watch on the files' modification times. - Each session runs over a BIO of the engine's own, inside N1's readiness loop: the queue still holds one refcounted buffer a broadcast, and each TLS connection encrypts as it writes, small sends packed into a record. - accepted is posted after the handshake, with conn_info's tls_version, tls_cipher, tls_sni and the client certificate's SHA-256 and keyprint. A failed or timed-out handshake closes as tls_handshake, counted and never posted. - listener_options.detect_tls: a plain port that also speaks TLS. The first byte decides (0x16 starts TLS), or the wait's end makes it plain; accepted comes after the decision, so NMDC's $Lock goes out on the right layer. - reload_tls(listener[, tls]) serves new files to new connections and keeps open ones; tls_reloaded carries the new keyprint. The watch loads a change once both files have kept their times for one interval. - tls_keyprint(listener): SHA256/ and the unpadded base32 of the DER's SHA-256 ([ADC-EXT] KEYP). - pycvc: tls_options, tls_protocol_*, reload_tls, tls_keyprint, net_listener.keyprint, .reload_tls() and .on_tls_reload on the loop; pycvc.ariadne.net has the names, and arisrvx_net runs a TLS listener. Tests: net_engine_test's TLS cases (handshakes on 1.2 and 1.3, a refused version and a stalled handshake, the keyprint against the openssl command, reloads with open connections, the watch, detection with TLS, plain, slow and silent clients, TLS backpressure and writable, a broadcast to a group mixing TLS and plain, a TLS fan-out measurement), required in the sanitizer lanes; test_pycvc_net's TLS section.
transfix
enabled auto-merge (squash)
November 26, 2026 08:59
… Enter Two package-linux / libcvc-debug failures on PRs this week, neither in their changes: - PhysicsFieldWake.PackedBodiesStayBoundedAndSleep ran 1059 s in that lane on master (c7b050f) and timed out at 1200 s on #1552's and #1553's runs, three tries each. physics_field_test gets 2400 s. - ari_run_file_pick_upload_tvision failed three tries on both: the Open file window showed the typed name but never took the Enter (tvision reads keys that come in one burst as a paste). Enter now goes once the field shows the name, and again, up to three times, while the window stays open.
transfix
disabled auto-merge
November 26, 2026 20:02
transfix
enabled auto-merge (squash)
November 26, 2026 20:02
transfix
pushed a commit
that referenced
this pull request
Nov 26, 2026
… Enter Two package-linux / libcvc-debug failures on PRs this week, neither in their changes: - PhysicsFieldWake.PackedBodiesStayBoundedAndSleep ran 1059 s in that lane on master (c7b050f) and timed out at 1200 s on #1552's and #1553's runs, three tries each. physics_field_test gets 2400 s. - ari_run_file_pick_upload_tvision failed three tries on both: the Open file window showed the typed name but never took the Enter (tvision reads keys that come in one burst as a paste). Enter now goes once the field shows the name, and again, up to three times, while the window stays open.
transfix
disabled auto-merge
November 26, 2026 21:08
transfix
enabled auto-merge (squash)
November 26, 2026 21:08
transfix
added a commit
that referenced
this pull request
Nov 27, 2026
* chore: bump libcvc to 4.0.10 * arigl_web_smoke: run the silent-relay case on arigl-web alone; master's ariglx-web (wasm-mt) is red #1546 gated the case on the browser's WebSocket API in the module's glue. ariglx-web's threaded (wasm-mt) ariglx.js has that API even though the package is built without the WebSocket transport, so the case ran there, the page never dialed ("this build has no conference transport"), and the job failed: on #1546's last head and on master since c7b050f. The single-threaded ariglx-web job skipped it as meant. The case now runs only on arigl-web (arigl.js, no ariglx.js), the one package with a conference transport. * tests: physics_field_test's Debug budget, and the tvision file pick's Enter Two package-linux / libcvc-debug failures on PRs this week, neither in their changes: - PhysicsFieldWake.PackedBodiesStayBoundedAndSleep ran 1059 s in that lane on master (c7b050f) and timed out at 1200 s on #1552's and #1553's runs, three tries each. physics_field_test gets 2400 s. - ari_run_file_pick_upload_tvision failed three tries on both: the Open file window showed the typed name but never took the Enter (tvision reads keys that come in one burst as a paste). Enter now goes once the field shows the name, and again, up to three times, while the window stays open. * cvcgl_volume_grid_segment: a volume large enough that a cooperative run spans frames on any runner The live-labels check needs a cooperative run (CVC_SLICED_THREADING=cooperative, about 4 ms of work a frame) to span several frames, so some frame sees the labels so far. On a package-linux runner (#1556's run, 2026-11-26) the 56^3 run finished inside one frame's slice on all three tries: "labels so far shown while marching (56^3, cooperative): no". 96^3 is about five times the work. --------- Co-authored-by: Joe Rivera <[email protected]>
transfix
added a commit
to cy-pca/sublevels
that referenced
this pull request
Nov 28, 2026
install.sh pins libcvc 4.0.10+cvc.2 with arisrvx and pycvc-cp312 4.0.10+cvc.1. Every libcvc symbol they import is defined there (checked with nm: arisrvx 268, _pycvc.so 1359, none missing). 4.0.10 has the engine's TLS (N3, transfix/libcvc#1552). On the engine transport, NMDCS is now an engine listener beside plain NMDC, sharing one engine and one fan-out, so a group send is still one broadcast: - TLS 1.2 and up, the engine's default minimum; - the hub publishes the listener's keyprint (net_listener.keyprint, the same SHA256/<base32> form); - the engine's watch reloads the certificate and key when they change, and on_tls_reload hands the hub the new keyprint. An engine without TLS (libcvc before 4.0.10, or built without libssl) keeps NMDCS on asyncio, as before, and says so. The arisrvx smoke run requires NMDCS on arisrvx's engine with a published keyprint. The NMDCS login and keyprint-reload socket tests run on both transports. The CI header and READMEs no longer say NMDCS waits for N3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part N3 of the native connection engine (docs/roadmap/ARIADNE_NET_ENGINE.md §2.5, §3): listener TLS, reload, the keyprint, and TLS detection on a plain port. It is for cy-pca/sublevels' NMDCS, which still runs on asyncio because the engine had no TLS.
What it adds
listener_options.tlsis atls_options: certificate and key PEM files, TLS 1.2 and 1.3 withmin_versionas a setting,ciphers/ciphersuites, a client certificate asked for and accepted as sent (request_peer_certificate, on by default),handshake_timeout(10 s) andwatch. The engine links OpenSSL's libssl (cvcpkg's openssl is already in the recipe), optionally: without itnet_engine::tls_available()is false and a TLS listener fails to listen.ssl::streamwould need a read buffer for each connection and its own async operations, so onlyssl::contextis used. Each session runs over a BIO of the engine's own, two strings the connection reads into and writes from through the same readiness waits. The queue still holds one refcounted buffer for every receiver of a broadcast, and each TLS connection encrypts as it writes, packing small sends into one record. A flushing close sends the queue, then close_notify.acceptedis posted after the handshake, withtls_version,tls_cipher,tls_sni,tls_peer_sha256(hex) andtls_peer_keyprint. A handshake that fails or times out closes with the new reasontls_handshake, which is counted but never posted, because the program never heard of that connection.net_counters.tls_acceptedcounts completed handshakes.listener_options.detect_tls(ms), the engine waits that long for the first byte: 0x16 starts TLS, any other byte makes the connection plain at once, and nothing in time makes it plain when the wait ends.acceptedcomes only after the decision, so NMDC's$Lockgoes out on the right layer.reload_tls(listener)rereads the files, andreload_tls(listener, tls)takes new options. Either serves new connections only; open ones keep their session. A reload that works poststls_reloadedwith the new keyprint. One that fails returns false (OSError in Python) and keeps the certificate in use. The watch loads a change once both files have kept their times for one interval, so a certificate and key written one after the other are read together. A watched load that fails posts the listener'serroronce.tls_keyprint(listener)returnsSHA256/plus the unpadded base32 of the SHA-256 of the certificate's DER ([ADC-EXT] KEYP), for the hub to publish beside itsnmdcs://address.tls_options,tls_protocol_*,tls_available,reload_tls(listener, tls=None),tls_keyprint, and onnet_listenerthe.keyprintproperty,.reload_tls()and.on_tls_reload(keyprint)(which runs on the loop).pycvc.ariadne.nethas the names, andhost.net's docstring shows a TLS listener.Tests
net_engine_testadds ten TLS cases:openssl x509 -outform DER | openssl dgst -sha256, against an EVP_Digest ofi2d_X509, and against the openssl command at run time where one exists;SAN_REQUIRED_NET.test_pycvc_net.pygains a TLS section that uses Python'ssslas the client (keyprint againsthashlib, conn_info, detection, reload and its OSError, a refused 1.2,on_tls_reloadand an asyncio TLS client).arisrvx_netruns a TLS listener too (run_arisrv.cmakenow checks up to EXPECT9).Verified locally (prettyhatemachine, gcc 13, OpenSSL 3.4.1 from deps)
All on the pushed head (e619f11):
net_engine_testRelease: 34/34, five runs.-DCVC_NET_ASYNC_WRITES=1, the Windows write path: 34/34, three runs.setarch -R): 34/34, three runs, no reports.AWatchedListenerReloadsWhenItsFilesChange: a tick fell between the test's two writes and reported a second error.test_pycvc_net.py, three runs, passes. It has to be run by hand here: this box needs deps' lib dir on LD_LIBRARY_PATH for libcurl's libssl 3.2.arisrvx_netpasses and printsnet_program: tls ok: b'$Lock tls|' TLSv1.3 SHA256/IIEB….cvcflags nothing innet_engine.cpp. The BIO method lives in each loaded context, not in a static.Not verified: Windows and macOS (CI will show). clang's TSan was not run locally.
Measured
NetEngineTlsFanOut(1000 receivers per group, 2 I/O threads, load 7), I/O CPU per receiver per message:SSL_MODE_RELEASE_BUFFERSmade no measurable difference, so it stays on.Design doc
The doc now marks N3 built. It corrects §1, which claimed libcvc already used OpenSSL's TLS through its transports: it linked only libcrypto, and its TLS client was libcurl's. It adds an (N3) block to §2.5 and the TLS counters to §2.10. One difference from the design:
first_frame_timeoutnow counts fromaccepted, so on TLS it starts after the handshake.Not for merge without Joe's OK.