Skip to content

Commit 746488f

Browse files
lxsaahclaude
andcommitted
feat(mqtt-connector): TLS, auth, and SNTP time source for the Embassy client
Implements design 044: mqtts:// broker support behind a new embassy-tls feature. - embedded-tls 1.3 session over the Embassy TCP socket; rustpki (pure Rust, rsa+p384) certificate verification against an app-embedded root CA; SNI + hostname verification from the broker URL (IP-literal mqtts URLs are rejected at build()). - Entropy injected via TlsOptions (&'static mut dyn CryptoRngCore) — the app owns the TRNG; buffers are app-provided statics (D3, D10). - Connector-internal SNTPv4 task (UDP + DNS) backs the TlsClock; the first handshake waits for time sync so validity is always checked (D4, D5). The wire codec is feature-independent and host-tested. - The TLS manager loop is a connector-local port of mountain-mqtt-embassy's run() (which hard-codes a plain TcpSocket); the session speaks a custom Connection impl tracking decrypted plaintext + socket readiness, and re-subscribes inbound routes per session. The plain path is untouched (D6). - with_credentials() feeds MQTT CONNECT on both transports; the fork submodule gains upstream 0.4's ConnectionSettings::with_auth/ authenticated (aimdb-dev/mountain-mqtt@89a7129) (D8). - make check gains the embassy-runtime,embassy-tls,defmt clippy leg. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 9f0dbf8 commit 746488f

9 files changed

Lines changed: 1583 additions & 45 deletions

File tree

Cargo.lock

Lines changed: 499 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ clippy:
252252
cargo clippy --package aimdb-knx-connector --target thumbv7em-none-eabihf --no-default-features --features "embassy-runtime" -- -D warnings
253253
@printf "$(YELLOW) → Clippy on MQTT connector (embassy + defmt)$(NC)\n"
254254
cargo clippy --package aimdb-mqtt-connector --target thumbv7em-none-eabihf --no-default-features --features "embassy-runtime,defmt" -- -D warnings
255+
@printf "$(YELLOW) → Clippy on MQTT connector (embassy + TLS + defmt)$(NC)\n"
256+
cargo clippy --package aimdb-mqtt-connector --target thumbv7em-none-eabihf --no-default-features --features "embassy-runtime,embassy-tls,defmt" -- -D warnings
255257
@printf "$(YELLOW) → Clippy on KNX connector (embassy + defmt)$(NC)\n"
256258
cargo clippy --package aimdb-knx-connector --target thumbv7em-none-eabihf --no-default-features --features "embassy-runtime,defmt" -- -D warnings
257259
@printf "$(YELLOW) → Clippy on WS protocol$(NC)\n"

_external/mountain-mqtt

aimdb-mqtt-connector/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ embassy-runtime = [
3838
"heapless",
3939
"static_cell",
4040
]
41+
# TLS (`mqtts://`) for the Embassy client — design 044. embedded-tls 1.3
42+
# session over the Embassy TCP socket, pure-Rust certificate verification
43+
# (`rustpki`; `rsa`/`p384` so public CA chains verify out of the box), broker
44+
# hostname resolution (embassy-net DNS), and the SNTP time source (UDP).
45+
embassy-tls = [
46+
"embassy-runtime",
47+
"dep:embedded-tls",
48+
"dep:embedded-io-async",
49+
"dep:rand_core",
50+
"embassy-net/dns",
51+
"embassy-net/udp",
52+
]
4153
tracing = ["dep:tracing", "aimdb-core/tracing"]
4254
defmt = ["dep:defmt", "aimdb-core/defmt"]
4355

@@ -84,6 +96,15 @@ mountain-mqtt = { version = "0.2.0", default-features = false, optional = true,
8496
] }
8597
mountain-mqtt-embassy = { version = "0.2.0", optional = true }
8698

99+
# TLS for the Embassy client (no_std TLS 1.3; design 044)
100+
embedded-tls = { version = "0.19", default-features = false, optional = true, features = [
101+
"rustpki",
102+
"rsa",
103+
"p384",
104+
] }
105+
embedded-io-async = { workspace = true, optional = true }
106+
rand_core = { version = "0.6", default-features = false, optional = true }
107+
87108
# Embedded utilities
88109
heapless = { workspace = true, optional = true }
89110
static_cell = { version = "2.0", optional = true }

0 commit comments

Comments
 (0)