fix(virtual-printer): #1610 add Bambu cipher pin to every slicer-facing TLS context

The #620 patch fixed the OpenSSL-3.x-strips-plain-RSA-AES-GCM cipher
  mismatch on the printer-facing TLSProxy client context. The same fix
  was never applied to the four other slicer-facing TLS contexts. On
  hardened distros (Fedora / RHEL with update-crypto-policies, hardened
  Alpine builds) where the system narrows DEFAULT to forward-secrecy
  only, the slicer's ClientHello finds no overlap with what Bambuddy
  offers and the handshake aborts with the slicer reporting code=-1
  before any application data flows. The reporter pinpointed the missing
  set_ciphers call in bind_server.py against the #620 lineage; the
  audit-wide sweep here extends the same fix to mqtt_server.py,
  tcp_proxy._create_server_ssl_context (the missing other half of #620),
  and ftp_server.py.

  For the three new contexts (bind / mqtt / proxy-server) the cipher
  string is DEFAULT:AES256-GCM-SHA384:AES128-GCM-SHA256 — verbatim match
  with the #620 client-side fix. For FTPS the original HIGH baseline is
  kept (HIGH:AES256-GCM-SHA384:AES128-GCM-SHA256:!aNULL:!MD5:!RC4) so the
  cipher set stays a strict superset of what shipped before — HIGH
  offers ~58 suites DEFAULT doesn't (CCM / ARIA / CAMELLIA / DSS) that
  no Bambu slicer is known to pick, but narrowing a compat surface
  without proof would violate the existing don't-remove-compat-pinning
  rule. TLS version pins (TLSv1_2 minimum across all four, TLSv1_2 max
  on FTPS for the BambuStudio PSK-reuse compat) and verify-mode settings
  are unchanged — only the cipher list is widened.
This commit is contained in:
maziggy
2026-06-03 10:04:37 +02:00
parent fee7c722f5
commit 9cc4b6aa60
6 changed files with 244 additions and 2 deletions
@@ -77,6 +77,15 @@ class BindServer:
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ctx.load_cert_chain(str(self.cert_path), str(self.key_path))
ctx.minimum_version = ssl.TLSVersion.TLSv1_2
# Match real Bambu printer cipher behaviour: include the plain-RSA
# AES-GCM suites the slicer's bind/connect path expects. On hardened
# distros (Fedora / RHEL with `update-crypto-policies`, hardened Alpine
# builds) the OpenSSL `DEFAULT` list strips these suites, leaving no
# overlap with the slicer's ClientHello and producing `code=-1` on the
# slicer side (#1610). Same fix the #620 client-side patch applied to
# `tcp_proxy.py::_create_client_ssl_context`; the bind-server / server
# side needs it too.
ctx.set_ciphers("DEFAULT:AES256-GCM-SHA384:AES128-GCM-SHA256")
ctx.verify_mode = ssl.CERT_NONE
return ctx