I’m not sure this works with this client. I checked their repo and didn’t find a mention of cipher suites and also the WithTls() doesn’t seem to have the option to set the cipher suites.
public static async Task Connect_Client_With_TLS_Encryption()
{
/*
* This sample creates a simple MQTT client and connects to a public broker with enabled TLS encryption.
*
* This is a modified version of the sample _Connect_Client_! See other sample for more details.
*/
var mqttFactory = new MqttFactory();
using (var mqttClient = mqttFactory.CreateMqttClient())
{
var mqttClientOptions = new MqttClientOptionsBuilder().WithTcpServer("test.mosquitto.org", 8883)
.WithTls(
o =>
{
o.SslProtocol = SslProtocols.Tls12; // The default value is determined by the OS. Set manually to force version.
})
.Build();
// In MQTTv5 the response contains much more information.
var response = await mqttClient.ConnectAsync(mqttClientOptions, CancellationToken.None);
Console.WriteLine("The MQTT client is connected.");
response.DumpToConsole();
}
}
A workaround, I can think of at the spot, would be to find out what cipher suites the client supports and then add one of them to the broker cipher suites.
You can find out what cipher suites the client support by running your current code again but monitor the traffic between client and broker with Wireshark, the “Client Hello” of the client contains the supported cipher suites of the client.