Skip to content

Commit

Permalink
Fix public broker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chkr1011 committed Sep 6, 2023
1 parent 888714c commit 0cdcc44
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions Source/MQTTnet.TestApp/PublicBrokerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ public static async Task RunAsync()
UseTls = true,
SslProtocol = SslProtocols.Tls13,
// Don't use this in production code. This handler simply allows any invalid certificate to work.
CertificateValidationHandler = w => true
AllowUntrustedCertificates = true,
IgnoreCertificateChainErrors = true,
CertificateValidationHandler = _ => true
};
#endif
// Also defining TLS12 for servers that don't seem no to support TLS13.
Expand All @@ -34,7 +36,9 @@ public static async Task RunAsync()
UseTls = true,
SslProtocol = SslProtocols.Tls12,
// Don't use this in production code. This handler simply allows any invalid certificate to work.
CertificateValidationHandler = w => true
AllowUntrustedCertificates = true,
IgnoreCertificateChainErrors = true,
CertificateValidationHandler = _ => true
};

// mqtt.eclipseprojects.io
Expand Down Expand Up @@ -97,10 +101,10 @@ await ExecuteTestAsync(
"test.mosquitto.org WS TLS12",
new MqttClientOptionsBuilder().WithWebSocketServer(o => o.WithUri("test.mosquitto.org:8081/mqtt")).WithProtocolVersion(MqttProtocolVersion.V311).WithTlsOptions(unsafeTls12).Build());

// await ExecuteTestAsync(
// "test.mosquitto.org WS TLS12 (WebSocket4Net)",
// new MqttClientOptionsBuilder().WithWebSocketServer("test.mosquitto.org:8081/mqtt").WithProtocolVersion(MqttProtocolVersion.V311).WithTls(unsafeTls12).Build(),
// true);
await ExecuteTestAsync(
"test.mosquitto.org WS TLS12 (WebSocket4Net)",
new MqttClientOptionsBuilder().WithWebSocketServer(o => o.WithUri("test.mosquitto.org:8081/mqtt")).WithProtocolVersion(MqttProtocolVersion.V311).WithTlsOptions(unsafeTls12).Build(),
true);

// broker.emqx.io
await ExecuteTestAsync(
Expand Down Expand Up @@ -150,7 +154,6 @@ await ExecuteTestAsync(
true);

// mqtt.swifitch.cz: Does not seem to operate any more

// cloudmqtt.com: Cannot test because it does not offer a free plan any more.

Write("Finished.", ConsoleColor.White);
Expand Down Expand Up @@ -197,9 +200,10 @@ static async Task ExecuteTestAsync(string name, MqttClientOptions options, bool

Write("[OK]\n", ConsoleColor.Green);
}
catch (Exception e)
catch (Exception exception)
{
Write("[FAILED] " + e.Message + "\n", ConsoleColor.Red);
Write("[FAILED]" + Environment.NewLine, ConsoleColor.Red);
Write(exception + Environment.NewLine, ConsoleColor.Red);
}
}

Expand Down

0 comments on commit 0cdcc44

Please sign in to comment.