Skip to content

fix(connector): hold Anycubic client identity and pin Kobra 3 before writing - #971

Draft
bloodf wants to merge 2 commits into
mainfrom
orq/tp2nlu/ship-12
Draft

bloodf wants to merge 2 commits into
mainfrom
orq/tp2nlu/ship-12

Conversation

@bloodf

@bloodf bloodf commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Draft until the Full Review verdict on the exact head.

Fixes the four findings from the #965 review that reached main when #965 merged early (#969):

  1. Client identity before the pin check: every Anycubic LAN socket is now built with connectAnycubicTls. When a client certificate is configured (certPem and keyPem), it uses holdClientIdentity: true with TLS 1.3 only, as the Kobra X client does, so no client certificate reaches a server before the CA and pin pass. Without a client certificate it stays on TLS 1.2+.
  2. Kobra 3 (20024) pinned path: the separate rejectUnauthorized: !pin branch and its post-handshake leaf-hash check are gone. 20024 goes through connectAnycubicTls, so a configured CA and pin are both enforced, and nothing (MQTT CONNECT or a client certificate) is written before the check. Pin-only and no-pin behaviour is unchanged, except that a 20024 pin may now also match the key (SPKI) hash, as for the other models.
  3. Relay tests (tests/node/fix-965.test.ts): a relay in front of a TLS server that requests a client certificate asserts that no client certificate and zero MQTT bytes reach the server on a wrong pin, for 20028 and 20024, against TLS 1.3, TLS 1.3 with HelloRetryRequest, and a TLS 1.2-only peer. Positive tests show a matching pin connects and presents the client certificate.
  4. Cancel outcome (Kobra 4 / S1 Max driver): a cancel is confirmed only by a report whose job reads canceled or stopped without a fault code. A bare idle leaves the outcome unknown and nothing is resent. The simulator now reports a canceled job once after a stop (synthetic; no hardware capture exists).

Tests that fail on revert:

  • Reverting the transport fails "20024 refuses a matching pin when the configured CA is wrong" and both TLS 1.2-only wrong-pin cases (the old transport sends the client Certificate). The TLS 1.3 and HelloRetryRequest wrong-pin cases still pass on the old code (on loopback the old socket closes before its TLS 1.3 client flight); they remain as regression guards.
  • Reverting the driver fails the idle-after-cancel and explicit-cancel tests.

Known follow-ups, not in this PR yet:

  • Kobra 3's own driver (anycubic/control-driver.ts ~216-222) still maps idle after a cancel to cancelled.
  • docs/fullfarmmanager/evidence/anycubic-fdm-models.md:86 still says a job seen to end only as free is recorded as cancelled.
  • If real Kobra 4 / S1 Max printers report only free after a stop, hardware cancels will end as uncertain. That is the safe direction, but it needs hardware evidence.

Local: 46/46 focused tests pass (fix-965, fix-963, anycubic-models, qualify-anycubic). The host's required checks must pass on this head before merging.

Closes #969

…writing

Route every model, Kobra 3 (20024) included, through connectAnycubicTls:
a configured CA and pin are both checked, and nothing (MQTT CONNECT or a
client certificate) is written before they pass. A configured client
certificate is held until the check, over TLS 1.3 only.

A cancel is confirmed only by a report whose job reads canceled or
stopped without a fault code; a bare idle leaves the outcome unknown.

(cherry picked from commit 4611ed4f9f19a6aa24ced2551a500a7c90919ffa)
The LAN control driver now needs explicit cancel evidence. The simulator
reported only free after a stop; it now reports the job as canceled once
first. Synthetic, never captured on hardware.

(cherry picked from commit bd11b5c569cbea07b34d773b4cc7d2776e0d552f)

@bloodf bloodf left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TLS changes look sound at 202903f and all six required checks passed. Please fix qualified cancel confirmation before merging: reject failed envelopes and fault codes before accepting any terminal spelling, with simulator-only regression coverage. Where an identifier is available, correlate the confirmation with the command. Kobra 3 also needs a separate follow-up for confirming cancellation from plain idle; leave the outcome uncertain without explicit evidence.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[medium] Anycubic TLS: client certificate sent before the pin check; Kobra 3 pinned path not hardened

1 participant