You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement the opt-in N2N TLS bridge from discussion #8611, carrying both consensus and forwarded requests over service-endorsed mutual TLS.
This makes TLS usable in real services while retaining a rolling-upgrade path for legacy peers.
Safety and compatibility
Select TLS only when local configuration enables it and recorded peer metadata advertises it; connection failures never trigger a legacy downgrade.
Use separate TLS 1.3 consensus and forwarding streams on one ALPN listener, with the merged sending-key policy. Failed streams reconnect on subsequent sends; forwarded requests are not automatically replayed.
Preserve ledger-mutation ordering and independent ledger protection. Same-key certificate renewal affects future handshakes, not established streams.
Keep the legacy endpoint required for this bridge release. TLS-only configuration and legacy removal remain 8.0 work; older primaries which stripped endpoint metadata require another replacement cycle.
This is a parity-focused MVP for trusted nodes on operator-restricted N2N ports. During establishment, retain only the latest consensus message and at most ten forwarded messages, rejecting additional forwarding sends. Frame assembly is deferred until authentication. Established streams retain baseline buffering behavior; aggregate memory budgets are explicitly deferred and do not block this integration.
Review guide: permanent code versus removable bridge
Permanent transport: NodeTLS owns authentication, ALPN, framing, establishment queues, and connection lifecycle; send_node_frame owns transport-neutral ledger-ordered assembly. The shared engine and client are unchanged; the server gains only a context factory for N2N authentication policy.
Temporary migration adapters: NodeChannelBridge and NodeTransportBridge isolate the legacy paths. The bridge name identifies pieces intended to disappear with legacy interoperability.
Bootstrap and integration: node metadata flows through the consensus configuration and join response so a joiner can reply before it has replicated the node table. Node ingress dispatches authenticated TLS forwarding separately from consensus.
Tests: node_tls.cpp covers transport policy and lifecycle; n2n_tls.py keeps permanent TLS lifecycle coverage; n2n_transport_bridge.py adds disposable legacy-only and mixed-network coverage.
The unused recv_authenticated_with_load chain is removed, and the test-only have_channel query no longer belongs to the production N2N interface.
Resource-policy review disposition
Following review, the earlier multi-stage output byte budgets, aggregate receive accounting, N2N ingress charging, and bespoke incoming admission limits have been removed rather than expanded.
That removes the new quadratic queue scans and overflow-close path; retained vector capacity is intentionally not claimed to obey an aggregate allocation budget.
See the agreed scope and non-blocking follow-up.
Broader memory-budget work should justify its guarantees and failure behavior against actual workloads and the legacy baseline.
Trace logging remains untouched, as discussed in review.
Validation and independent review
Validation includes a complete Debug clang-tidy build, focused transport/consensus/frontend/snapshot unit tests, real TLS and legacy/mixed lifecycle networks, certificate renewal, ledger rekey, primary replacement, disaster recovery, exact OpenAPI snapshot validation, strict Sphinx, repository checks, and scoped C++ case checks.
The establishment-parity suite passed ten repeated runs.
An independent review identified a close-versus-handshake callback race; queued sends are now discarded at close and authentication rejects closing streams.
The Virtual B and C failures were reproduced locally: the metadata test used an unresolvable bind address after the listener became active, and the new CLI flag lacked its host-config mapping.
Both full Debug nodes_test (including IPv4 and IPv6 reconfiguration) and sandbox_test pass with narrow infrastructure/test fixes.
LTS validation before the latest main merge passed live interoperability with 7.0.24 and ledger/snapshot recovery from 6.0.28 and 7.0.24.
The latest main merge contains upstream's COSE-only snapshot compatibility policy; pre-7.0 snapshot support is not restored by this PR.
#8757 is now merged into main and included here. #8758 remains open: N2N recovery tolerates unclean closure and does not rely on successful graceful close-notify.
Adds opt-in, service-authenticated TLS 1.3 for CCF node-to-node consensus and request forwarding, while preserving legacy interoperability during rolling upgrades.
Changes:
Introduces separate TLS consensus and forwarding streams, connection limits, and lifecycle handling.
Propagates TLS endpoint metadata through configuration and joining, with shared ledger-ordered frame assembly.
Adds transport coverage, upgrade validation, operator documentation, and API schema updates.
Custom instructions used
.github/instructions/reviewing.instructions.md
File
Description
tests/n2n_transport_bridge.py
Adds legacy-only and mixed-network coverage.
tests/n2n_tls.py
Exercises TLS traffic, renewal, replacement, and recovery.
tests/lts_compatibility.py
Validates TLS adoption after legacy upgrades.
tests/infra/node.py
Configures and resolves TLS listener addresses.
tests/infra/interfaces.py
Adds optional TLS interfaces to host specifications.
tests/infra/e2e_args.py
Adds the TLS enablement option.
tests/ci-buckets.txt
Assigns new transport suites to CI.
src/tls/test/openssl_server_test.cpp
Covers bounded-output cleanup and handshake expiry.
src/tls/openssl_server.h
Adds custom contexts, output limits, and handshake deadlines.
src/tls/openssl_connection_engine.h
Adds outbound queue and buffer limits.
src/tls/openssl_client.h
Bounds output during connection establishment.
src/node/test/node_tls.cpp
Tests TLS authentication, framing, lifecycle, and transport selection.
src/node/rpc/serialization.h
Serializes TLS endpoint metadata.
src/node/rpc/node_frontend.h
Exposes TLS addresses through join and node APIs.
src/node/rpc/node_call_types.h
Adds trusted-peer TLS addresses to join responses.
src/node/rpc/forwarder.h
Handles TLS-authenticated forwarded messages.
src/node/rpc/call_types.h
Adds TLS interface metadata to node responses.
src/node/node_transport.h
Extends transport interfaces for TLS.
src/node/node_to_node.h
Shares consensus header parsing and removes unused APIs.
src/node/node_to_node_channel_manager.h
Removes obsolete receive support and isolates a test query.
src/node/node_tls.h
Implements authenticated TLS streams and framing.
src/node/node_state.h
Integrates TLS bootstrap and message dispatch.
src/node/node_inbound_message.h
Queues TLS ingress with admission accounting.
src/node/node_channel_bridge.h
Selects TLS or legacy channels from metadata.
src/node/hooks.h
Carries TLS endpoints into consensus configuration.
src/node/channels.h
Removes the unused authenticated-load receive path.
src/kv/kv_types.h
Adds TLS addresses to consensus configuration records.
src/host/run.cpp
Creates the optional listener and transport bridge.
src/host/node_transport_bridge.h
Connects legacy and TLS transport backends.
src/host/node_frame.h
Extracts shared ledger-ordered frame assembly.
src/host/node_connections.h
Uses shared frame assembly for legacy sends.
src/enclave/enclave.h
Wires TLS ingress and shutdown.
src/consensus/aft/consensus_channels.h
Adds TLS address association support.
src/consensus/aft/cft.h
Supplies recorded TLS endpoints to channels.
include/ccf/service/node_info_network.h
Updates the TLS endpoint documentation comment.
doc/schemas/node_openapi.json
Documents TLS fields in API schemas.
doc/releases/migration_7_x_to_8_x.rst
Explains staged TLS migration and metadata repair.
doc/operations/configuration.rst
Documents listener configuration and transport selection.
doc/architecture/tls_internals.rst
Describes TLS-specific engine policies and limits.
doc/architecture/node_to_node.rst
Documents transport architecture and compatibility behavior.
CMakeLists.txt
Registers transport tests and enables TLS upgrade coverage.
Name unused interface parameters, make optional access explicit, and remove redundant member initializers. Extract outbound queue admission from the connection dispatcher to keep its cognitive complexity within the configured limit.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
TLS forwarding exposes decrypted requests and responses in Trace logs, including Authorization headers, private request bodies, and private response data.
Submission overflow queues a graceful close, so an established stream with backpressured output waits for that output to drain instead of discarding it. Until another closure condition occurs, the stream remains registered and later sends can continue queuing on it rather than reconnecting, contrary to the documented exhaustion policy. Give overflow commands a distinct abort flag and handle it by setting force_close on the loop, while preserving ordinary graceful-close behavior.
Recording the agreed resource-policy scope for the next revision of this PR:
This is a parity-focused MVP for TLS between trusted service nodes. Operators restrict access to N2N ports; general-purpose listener hardening is not a goal here.
Match legacy during establishment: keep only the latest consensus message and at most ten forwarded messages in arrival order, rejecting further forwarding sends. Defer frame assembly and ledger reads until authentication succeeds.
Keep the existing maximum incoming frame size, TLS key-usage policy, ledger-mutation ordering, idle/recovery behavior, and no automatic replay of forwarded requests.
Remove the proposed multi-stage output byte budgets, aggregate receive accounting, N2N ingress charging, and bespoke incoming connection/handshake admission policy. Once connected, use the shared engine's baseline buffering behavior.
The retained-capacity, repeated queue-scan, and overflow-close review concerns arose from the extra accounting policy. The local revision removes that machinery rather than adding capacity tracking, queue byte counters, or another abort command.
Deferred, non-blocking follow-up: evaluate memory budgets/backpressure across established N2N streams using actual workloads and slow-peer behavior. Any stronger policy should specify the resource it bounds and its consensus/forwarding failure semantics, and justify the complexity against the legacy baseline. This follow-up must not block the initial TLS integration.
Keep the latest consensus send and at most ten forwarded sends until TLS authentication, deferring ledger framing and discarding failed-stream work without replay. Remove the additional memory budgets and admission bookkeeping from this parity-focused bridge.
Fix the sandbox CLI metadata mapping and adapt the endpoint metadata regression to an active TLS listener with a resolved local bind address and preserved published address.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Pushed 0367833 with the agreed legacy-parity queue policy and both reproduced CI fixes. Virtual C was missing the new CLI flag in host-config metadata; Virtual B used an unresolvable TLS bind address in the old inactive-metadata test. Both full Debug sandbox_test and nodes_test now pass locally, including IPv4/IPv6 reconfiguration. The full Debug clang-tidy build, focused unit tests, TLS/legacy/mixed lifecycle tests, strict Sphinx, and repository checks also passed during validation.
The review overview also noted submission overflow requesting graceful rather than forced closure. That additional overflow policy/path is removed entirely with the shared-engine byte limits, rather than adding an abort command. The three accounting threads have replies and are resolved; the separately resolved Trace logging behavior remains untouched. Memory-budget work remains deferred and non-blocking as agreed. New CI results are still pending.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
The new authentication boundary and asynchronous consensus transport require human security/consensus review and runtime interoperability evidence unavailable in this source-only review.
Move peer endpoint registration into the removable bridge and retain it across connection closure and reconnects. Reject conflicting registrations while allowing unknown peers to acquire metadata later.
Clarify intended bridge removal and simplify startup port discovery following review feedback.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This PR carries consensus and forwarded requests over TLS 1.3, using existing service-endorsed node identities and the shared OpenSSL connection engine.
Consensus and forwarding use separate connections on one listener, distinguished by ALPN (ccf-consensus/1 and ccf-forwarding/1), isolating consensus from large forwarded messages at the TCP-stream level.
TLS is opt-in: it is selected when local configuration enables it and the peer's recorded metadata advertises it; otherwise the pair uses legacy channels.
A TLS failure never triggers a legacy downgrade.
The legacy endpoint remains required in this bridge release.
What is a "bridge"?
The bridge classes are temporary shims for the dual-transport period:
NodeTransportBridge connects those calls to legacy sockets or the TLS owner, including identity, address, and lifecycle plumbing.
Their names and separate files identify code intended for removal with legacy interoperability.
They isolate legacy behavior to simplify eventual removal of the backend and its caller/interface plumbing.
Forwarding is kept separate from TLS consensus so its eventual removal is independent.
Follow an outgoing message
Colour key: green = new code; blue = modified or extracted code; grey = existing logic reused.
Colours describe the paths shown.
Dashed arrows represent deferred callbacks or queued work.
The first diamond reads the peer's fixed backend registration. NodeTransportBridge::associate_tls_address() registers TLS when local configuration enables it and the peer has a recorded TLS endpoint; otherwise it registers legacy.
Before metadata is available, a lookup miss follows the existing legacy path without registering a choice.
Registration is immutable and survives connection expiry and reconnects; repeated registration must agree.
The second follows the delivery callback supplied by that caller: either the legacy socket callback or the TLS callback tied to a stream ID.
Legacy performs custom channel authentication/encryption; TLS relies on the authenticated connection. send_node_frame() extracts shared replication-frame assembly from the legacy socket owner, preserving ledger-mutation ordering for both transports.
Ledger encryption and integrity validation remain independent of connection protection.
The shared engine and client are unchanged; the server gains a context factory for N2N authentication policy.
Incoming TLS: one listener, two purposes
NodeTLS::select_alpn() selects the stream's purpose during the handshake. handshake() binds that purpose to the verified service-endorsed peer identity before admitting application traffic.
flowchart TD
Accept["OpenSSLServer<br/>accept on the single N2N TLS listener"]
Negotiate["TLS handshake<br/>NodeTLS::select_alpn()"]
Admit{"NodeTLS::handshake()<br/>Verified peer certificate AND<br/>supported negotiated ALPN?"}
Bind["Bind stream to peer ID and purpose<br/>ccf-consensus/1 OR ccf-forwarding/1"]
Read["NodeTLS::receive()<br/>parse complete frame within size limit"]
Match{"Frame sender matches peer ID AND<br/>frame type matches stream purpose?"}
Ingress["NodeIngress::recv_node_tls_inbound()<br/>ordered node ingress"]
Dispatch{"NodeState::recv_node_tls_inbound()<br/>Which authenticated purpose?"}
ConsensusRecv["Consensus::recv_message()<br/>normalized header and ledger payload"]
ForwardRecv["Forwarder::recv_message()<br/>TLS-authenticated request or response"]
Reject["Reject / close stream<br/>no application dispatch"]
Accept --> Negotiate
Negotiate --> Admit
Admit -->|No| Reject
Admit -->|Yes| Bind
Bind --> Read
Read --> Match
Match -->|No| Reject
Match -->|Yes| Ingress
Ingress -.-> Dispatch
Dispatch -->|consensus| ConsensusRecv
Dispatch -->|forwarding| ForwardRecv
classDef added fill:#176b36,stroke:#0b4220,stroke-width:3px,color:#ffffff;
classDef changed fill:#0958b5,stroke:#063b7a,stroke-width:3px,color:#ffffff;
classDef reused fill:#505965,stroke:#303740,stroke-width:3px,color:#ffffff;
class Negotiate,Admit,Bind,Read,Match,Dispatch,Reject added;
class Accept,Ingress,ForwardRecv changed;
class ConsensusRecv reused;
Loading
Each frame must match the stream's authenticated sender and purpose; the final diamond dispatches that fixed purpose.
Legacy traffic retains its separate listener and authentication path.
Establishment: preserve legacy's small queues
NodeTLS::send() preserves the small queues already used by legacy Channel::send_unsafe():
While establishing
What is retained?
When another message arrives
Consensus
One message
Replace it with the latest
Forwarding
Up to ten messages, in order
Reject additional messages
After authentication, submit the retained messages for ledger-ordered frame assembly; subsequent sends proceed directly.
Established streams use the shared engine's existing buffering behavior.
Other boundaries worth reviewing
Failure and recovery: queued work belongs to one stream ID.
If that stream closes, it is discarded rather than replayed onto a replacement.
Consensus retries through its protocol; forwarded calls may time out because a request might already have executed.
The merged TLS sending-key policy can also cause such closures.
Renewal: expired node certificates remain accepted as in legacy; same-key renewal updates future handshakes without reconnecting established streams.
TLS traffic-key updates and ledger rekey remain separate.
Scope: trusted nodes on operator-restricted N2N ports, retaining the existing frame-size limit.
Broader memory-budget work is deferred.
Metadata and test evidence
Metadata has four consumers: config enables the local listener; the replicated node table records peer endpoints; the join response supplies bootstrap addresses before table replication; node APIs expose recorded endpoints for inspection.
Config/KV support was added earlier; this PR connects it to transport selection and those bootstrap/API paths.
See the migration notes for the older-primary metadata caveat.
node_tls.cpp covers authentication, framing, establishment queues, and lifecycle. n2n_tls.py exercises TLS traffic, renewal, rekey, replacement, and recovery; n2n_transport_bridge.py adds legacy-only and mixed runs and is intended for removal with the bridge.
Most other E2E suites still default to legacy; LTS compatibility explicitly enables TLS on upgraded local nodes.
Retain the N2N transport test registrations while adopting main's removal of the documentation test from the CI bucket inventory.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Partition coverage update:partitions_test now defaults to node-to-node TLS in this PR, including dynamically added nodes (9dddeb9).
Partition rules now cover both legacy and TLS listeners, so the intended faults actually isolate TLS connections.
A new regression verifies that listener connections succeed before a partition, are blocked during it, and succeed again afterwards; it failed against the original rules.
A clean run of all eight partition-test groups passed with TLS: basic, certs, isolate-reconnect, reconfiguration, sessions, recovery-elections, ledger-chunks, and in-place-restart.
The legacy basic group also passed.
The change is confined to test configuration and infrastructure; no C++ transport fixes were needed.
Keep bind and published addresses in one interface object with JSON helpers. Replace the startup dictionary merge and metadata-test address patching, and use the type throughout TLS test setup.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use HostSpec.with_args() so --node-to-node-tls creates the sandbox TLS interface while applying RPC options only once.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Security-critical mutual-TLS consensus changes require human review of cross-layer authentication, ledger-ordering, and asynchronous teardown invariants, plus confirmation of mixed-version, recovery, and lifecycle validation.
Cover both legacy and TLS listeners in partition rules so enabling TLS cannot silently leave inbound connections unpartitioned. Keep dynamically created joiners on the requested transport and add a real TCP listener isolation regression.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Security-critical mutual TLS and cross-thread connection lifecycles across consensus and mixed-version upgrades warrant human review and runtime validation beyond static inspection.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
TLS authentication derives SHA-256 node IDs for DID-key peers, causing identity checks to reject their connections and frames and blocking replication and forwarding without a legacy fallback.
Reply over authenticated accepted streams before peer metadata arrives. Resolve competing dials by public-key ID without an age heuristic, abort losing-stream output without replay, and preserve idle expiry. Add the partition catch-up regression and duplex/forced-close unit coverage.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A send-draining race can violate per-peer FIFO, the configured timeout is not applied to connection establishment, and competing-dial arbitration lacks deterministic regression coverage.
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
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.
Implement the opt-in N2N TLS bridge from discussion #8611, carrying both consensus and forwarded requests over service-endorsed mutual TLS.
This makes TLS usable in real services while retaining a rolling-upgrade path for legacy peers.
Safety and compatibility
Review guide: permanent code versus removable bridge
NodeTLSowns authentication, ALPN, framing, establishment queues, and connection lifecycle;send_node_frameowns transport-neutral ledger-ordered assembly. The shared engine and client are unchanged; the server gains only a context factory for N2N authentication policy.NodeChannelBridgeandNodeTransportBridgeisolate the legacy paths. Thebridgename identifies pieces intended to disappear with legacy interoperability.node_tls.cppcovers transport policy and lifecycle;n2n_tls.pykeeps permanent TLS lifecycle coverage;n2n_transport_bridge.pyadds disposable legacy-only and mixed-network coverage.The unused
recv_authenticated_with_loadchain is removed, and the test-onlyhave_channelquery no longer belongs to the production N2N interface.Resource-policy review disposition
Following review, the earlier multi-stage output byte budgets, aggregate receive accounting, N2N ingress charging, and bespoke incoming admission limits have been removed rather than expanded.
That removes the new quadratic queue scans and overflow-close path; retained vector capacity is intentionally not claimed to obey an aggregate allocation budget.
See the agreed scope and non-blocking follow-up.
Broader memory-budget work should justify its guarantees and failure behavior against actual workloads and the legacy baseline.
Trace logging remains untouched, as discussed in review.
Validation and independent review
Validation includes a complete Debug clang-tidy build, focused transport/consensus/frontend/snapshot unit tests, real TLS and legacy/mixed lifecycle networks, certificate renewal, ledger rekey, primary replacement, disaster recovery, exact OpenAPI snapshot validation, strict Sphinx, repository checks, and scoped C++ case checks.
The establishment-parity suite passed ten repeated runs.
An independent review identified a close-versus-handshake callback race; queued sends are now discarded at close and authentication rejects closing streams.
The Virtual B and C failures were reproduced locally: the metadata test used an unresolvable bind address after the listener became active, and the new CLI flag lacked its host-config mapping.
Both full Debug
nodes_test(including IPv4 and IPv6 reconfiguration) andsandbox_testpass with narrow infrastructure/test fixes.LTS validation before the latest main merge passed live interoperability with 7.0.24 and ledger/snapshot recovery from 6.0.28 and 7.0.24.
The latest main merge contains upstream's COSE-only snapshot compatibility policy; pre-7.0 snapshot support is not restored by this PR.
#8757 is now merged into main and included here.
#8758 remains open: N2N recovery tolerates unclean closure and does not rely on successful graceful close-notify.