DrvCnlMqtt: add CA pinning, mutual TLS, and revocation control - #126
Open
xtim8719xCopilot wants to merge 1 commit into
Open
xtim8719xCopilot wants to merge 1 commit into
xtim8719xCopilot wants to merge 1 commit into
Conversation
Member
|
Hello, |
Author
The MQTT channel driver's UseTls option only ever called
MqttClientTlsOptionsBuilder.UseTls() with no further configuration -
no way to trust a private or self-signed CA, no client certificate
support for mutual TLS, and no control over revocation checking.
Adds four new connection options, all optional and off by default:
- CaCertFile: pins the broker's certificate chain to a specific CA
file via a custom X509Chain (CustomRootTrust), instead of trusting
whatever the OS trust store happens to contain. This validates the
chain properly against the given CA - it is not a bypass.
- ClientCertFile / ClientCertPassword: presents a client certificate
(PFX) for mutual TLS authentication.
- AllowUntrustedCertificates: explicit opt-in bypass, only used when
no CaCertFile is given.
- IgnoreCertificateRevocationErrors: skips CRL/OCSP revocation
checking. Useful because ScadaComm often runs as a Windows service
account (e.g. LocalSystem) that can fail to complete an online
revocation check, which otherwise surfaces as an opaque
"Specified method is not supported" error at connect time with no
indication that revocation checking was the cause.
Also improves MqttClientHelper's connection error logging: it
previously logged only the AggregateException's generic message
("One or more errors occurred."), discarding the real inner exception
and its stack trace. Now unwraps and logs the actual cause, which is
what made the revocation-check failure above diagnosable at all.
The options dialog (FrmMqttClientChannelOptions) gains matching
fields: CA certificate file / client certificate file (with browse
buttons), client certificate password, and the two checkboxes.
xtim8719xCopilot
force-pushed
the
feat/mqtt-tls-ca-pinning-mtls
branch
from
August 6, 2026 18:21
4080b38 to
b3d8c12
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
The MQTT channel driver's
UseTlsoption only ever calledMqttClientTlsOptionsBuilder.UseTls()with no further configuration. That's fine against a broker with a publicly-trusted certificate, but there was no way to:MQTTnet itself already supports all of this (
WithCertificateValidationHandler,WithClientCertificates,WithIgnoreCertificateRevocationErrors, etc.) — it just wasn't exposed throughMqttConnectionOptionsor the options dialog.What's added
Four new connection options on
MqttConnectionOptions, all optional and off by default (fully backward compatible — verified the siblingDrvMqttClient/DrvMqttPublisherdrivers that also referenceDrvMqtt.Commonstill build unchanged):CaCertFile— pins the broker's certificate chain to a specific CA file via a customX509Chain(X509ChainTrustMode.CustomRootTrust), instead of trusting whatever happens to be in the OS trust store. This performs real chain validation against the given CA — it is not a bypass.ClientCertFile/ClientCertPassword— presents a client certificate (PFX) for mutual TLS authentication.AllowUntrustedCertificates— explicit opt-in bypass, only applied when noCaCertFileis given.IgnoreCertificateRevocationErrors— skips CRL/OCSP revocation checking. Useful because ScadaComm often runs as a Windows service account (e.g.LocalSystem), which can fail to complete an online revocation check — and that failure surfaces as an opaqueNotSupportedException("Specified method is not supported") with nothing indicating revocation checking was the cause.Also improved
MqttClientHelper's connection error logging: it previously logged only the wrappingAggregateException's generic message ("One or more errors occurred."), discarding the real inner exception and stack trace. It now unwraps and logs the actual cause — which is what made the revocation-check failure above diagnosable in the first place, instead of a dead-end guess.The options dialog (
FrmMqttClientChannelOptions) gains matching fields: CA certificate file / client certificate file (with browse buttons), client certificate password, and the two checkboxes. English and Russian language files updated.Test plan
DrvCnlMqtt.View.csprojandDrvMqtt.Common.csprojin Release against a clean checkout ofdevelop, perHowToBuild.txt.DrvCnlMqtt.Logic,DrvMqttClient.Logic, andDrvMqttPublisher.Logic(all consumers ofDrvMqtt.Common) still build unchanged against the extended options class.CaCertFile) — confirmedMqttClientHelper.Connect()succeeds and the line shows "MQTT client, connected".Note: this PR is independent of #125 (protocol version dropdown fix) — they don't depend on each other and can be reviewed/merged separately.