Skip to content

feat: send over TLS instead of plain TCP - #61

Merged
DavidCozens merged 1 commit into
mainfrom
stage-13-tls
Aug 16, 2026
Merged

feat: send over TLS instead of plain TCP#61
DavidCozens merged 1 commit into
mainfrom
stage-13-tls

Conversation

@DavidCozens

@DavidCozens DavidCozens commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Wrap the byte stream in TLS, layered over the TCP stream from the previous stage. The device verifies
the collector against a trust anchor it already holds, so records can be read only by that collector
and cannot be altered in transit. The collector is authenticated to the device; the device is not yet
authenticated to the collector.

struct SolidSyslogMbedTlsStreamConfig tlsConfig = {
    .Transport  = SolidSyslogLwipRawTcpStream_Create(&tcpConfig),
    .Sleep      = SyslogSleep,
    .Rng        = DeviceCertStore_Rng(),
    .CaChain    = DeviceCertStore_CaChain(),
    .ServerName = SYSLOG_COLLECTOR_HOST,
};

.Stream = SolidSyslogMbedTlsStream_Create(&tlsConfig),

ServerName is checked against the collector's certificate, so it has to match a name that
certificate carries. The trust anchor and the DRBG are passed as handles rather than paths or PEM, so
the device's crypto is initialised before the scheduler starts.

A second concurrent session has to be paid for upstream. The mbedTLS allocator and the task that
carries the handshake both need sizing for it; both fail loudly when they are not, and neither can be
sized from the run that fails.

If your device does not already run TLS, the library and its trust material will dominate
everything on this page. This device already holds a TLS session for its own broker, so what this
stage adds is the adapter and a second session.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@DavidCozens

Copy link
Copy Markdown
Contributor Author

@coderabbitai pause

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@DavidCozens

Copy link
Copy Markdown
Contributor Author

@coderabbitai pause

Base automatically changed from stage-12-origin-ip to main August 16, 2026 17:57
An mbedTLS stream wrapping the lwIP TCP stream, and the collector moves to 6514.
Server authentication only: the device verifies the collector against the trust
anchor it already holds and presents nothing of its own.

  Flash        +13,084 B    (+704 on the previous stage)
  RAM          +37,452 B    (+28,280)
  mbedTLS peak  +14,660 B  (35,992 absolute)
  Log stack       +680 B  (unchanged)
  Service       +3,768 B     (+2,808)

Only 632 bytes of the RAM is the library. The rest is a second concurrent session
upstream: the mbedTLS pool grows 32 -> 53 KiB and the service seam 2 -> 8 KiB.
Likewise the flash, which measures the code that drives TLS rather than TLS
itself — a device already speaking mTLS was carrying mbedTLS long before
SolidSyslog arrived.

Both resizes were forced by the device and both failed loudly. The pool was sized
for the broker session alone, so the handshake could not allocate: MbedTlsStream
category 0x0402, repeatedly, and nothing reached the collector. Given room, the
handshake then overflowed the service seam, which takes the device down before it
can report — so neither figure can be read from the run that fails.

The pool follows this device's existing rule, the measured peak times 1.5 rounded
up to the next KiB. The service seam is generous for now and comes back with the
rest at the end.

The TLS stream takes the trust anchor and DRBG as handles at create time, not
paths or PEM, so the device's crypto is initialised before the scheduler starts.
ServerName is checked against the collector's certificate. The drain window
covers a connect and handshake rather than a datagram.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews paused.

@DavidCozens
DavidCozens merged commit 633a053 into main Aug 16, 2026
1 check passed
@DavidCozens
DavidCozens deleted the stage-13-tls branch August 16, 2026 17:57
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.

1 participant