File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,18 +50,25 @@ IManagedMqttClient mqttClient
5050 _maxRetryAttempts = mqttConfig . GetValue < int > ( "MaxRetryAttempts" ) ;
5151 _shouldFailOnMaxRetries = mqttConfig . GetValue < bool > ( "ShouldFailOnMaxRetries" ) ;
5252
53- var tlsOptions = new MqttClientTlsOptions
54- {
55- UseTls = true ,
56- /* Currently disabled to use self-signed certificate in the internal broker communication */
57- //if (_notProduction)
58- IgnoreCertificateChainErrors = true ,
59- } ;
53+ bool allowInsecure = mqttConfig . GetValue < bool > ( "AllowInsecureLocalConnections" ) ;
54+
6055 var builder = new MqttClientOptionsBuilder ( )
6156 . WithTcpServer ( _serverHost , _serverPort )
62- . WithTlsOptions ( tlsOptions )
6357 . WithCredentials ( username , password ) ;
6458
59+ if ( allowInsecure )
60+ {
61+ _logger . LogWarning (
62+ "MQTT TLS disabled — insecure connections allowed. Do NOT use in production."
63+ ) ;
64+ }
65+ else
66+ {
67+ builder . WithTlsOptions (
68+ new MqttClientTlsOptions { UseTls = true , IgnoreCertificateChainErrors = true }
69+ ) ;
70+ }
71+
6572 _options = new ManagedMqttClientOptionsBuilder ( )
6673 . WithAutoReconnectDelay ( _reconnectDelay )
6774 . WithClientOptions ( builder . Build ( ) )
Original file line number Diff line number Diff line change 4141 " isar/+/inspection_value"
4242 ],
4343 "MaxRetryAttempts" : 5 ,
44- "ShouldFailOnMaxRetries" : false
44+ "ShouldFailOnMaxRetries" : false ,
45+ "AllowInsecureLocalConnections" : false
4546 },
4647 "Analysis" : {
4748 "Analyses" : {
You can’t perform that action at this time.
0 commit comments