refactor(mqtt): .Browser references .Driver — extract the client-options builder so the layering exception can go
#512
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Browser.csprojcarries aProjectReferencetoDriver.Mqtt(line 44) in addition to.Contracts. Every other driver's.Browserdepends on.Contractsonly.Why it was accepted. The browser needs to open its own broker connection, which means building MQTTnet
client options with the same TLS / CA-pinning / auth semantics the driver uses. Reusing
MqttConnection.BuildClientOptionswas judged better than duplicating security-relevant TLS and CA-pin logicin a second place, where the two copies would drift and one of them would drift open. The exception is
documented rather than silent.
Clean fix. Extract the pure options-building function to
.Contracts(it is transport-free — it mapsMqttDriverOptionsto client options; it does not connect), leavingMqttConnectionas the only thing thatowns a live client. Then drop the
.Driverreference from.Browser.Guard against the wrong fix: do not resolve this by copy-pasting the TLS setup into the browser. The
duplication is the actual hazard the exception was taken to avoid.
Acceptance.
.Browserreferences.Contractsonly; one implementation of the TLS/CA-pin options builderexists in the tree; the live browse suite still connects over TLS with CA pinning (both the pinned-good and
pinned-wrong cases).
Fixed in master
2a7d1167..Browsernow references.Contracts+ a new.Transportleaf, and not the runtime.Driver.Two corrections to the issue.
1. It costed this as one extraction; it needed two. The browse session decodes births itself, so it
also used
SparkplugTopic/SparkplugMessageType,SparkplugCodecandRebirthRequester— all in.Driver/Sparkplug/. Moving only the client-options builder would have left the.Driverreferenceexactly where it was. Those three moved to
.Contracts, beside the Tahu wire schema they encode.2. The suggested destination for the options builder does not work, and the
.Browsercsprojalready said so in a comment this issue did not account for:
.Contractsis deliberately transport-freeand
BuildClientOptionsreturnsMqttClientOptions, an MQTTnet type. Putting it there would handMQTTnet to every
.Contractsconsumer — including ControlPlane, which has no business with a brokerclient. So it went to the leaf project that comment had already prescribed:
ZB.MOM.WW.OtOpcUa.Driver.Mqtt.Transport(refs.Contracts+ MQTTnet), referenced by both.Driverand
.Browser. Still exactly one copy of the TLS/CA-pin logic — the guard the issue asked for.Measured, not assumed. After the change
Driver.Mqtt.dll,Polly.CoreandSerilogare all absentfrom the AdminUI's output.
Core.dllis not — becauseDriver.Sql.Browserhas the identicalviolation, undocumented. The old comment blamed this browser for Core reaching the AdminUI and was
wrong. Filed as #526 rather than fixed in passing.
MqttBrowserLayeringTestsguards the graph in both directions, including that.Transportstays a leafand
.Contractsstays MQTTnet-free.