You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've kind of reached an impass now trying to get a dotnet 8 Maui App to connect successfully to AWS IoT Core. In MQTTnet v4, one would do something similar to this:
var aCerts = new List<X509Certificate>();
// Load CA
string vPemCertCa = _pemCertCa
.Replace("-----BEGIN CERTIFICATE-----", null)
.Replace("-----END CERTIFICATE-----", null);
var oPemCertCaZ = new X509Certificate2(Convert.FromBase64String(vPemCertCa));
aCerts.Add(oPemCertCaZ );
// Load Device (X509)
string vPemCertX509 = _pemCertX509
.Replace("-----BEGIN CERTIFICATE-----", null)
.Replace("-----END CERTIFICATE-----", null);
var oPemCertX509Z = new X509Certificate2(Convert.FromBase64String(vPemCertX509));
aCerts.Add(oPemCertX509Z );
// Build client
var oMsgBuilderZ = new MqttClientOptionsBuilder().WithCleanSession();
oMsgBuilderZ = oMsgBuilderZ .WithTcpServer(MQTT_Host, MQTT_Port);
oMsgBuilderZ = oMsgBuilderZ .WithTls(new MqttClientOptionsBuilderTlsParameters()
{
SslProtocol = SslProtocols.Tls12,
AllowUntrustedCertificates = true,
UseTls = true,
Certificates = aCerts,
});
In MQTTnet v5 of course, MqttClientTlsOptionsBuilder no longer has WithTls(), having been replaced with WithTlsOptions(). WithTlsOptions() doesn't have the property Certificates (or Certificate) but does have WithTlsOptions().WithTrustChain(<chain-here).
However, on Android, one just gets the error Exception of type 'Interop+AndroidCrypto+SslException' was thrown. On iOS, the error is a little different: Could not resolve assembly "system.net.security.resources".
Has anyone successfully managed to connect, publish and subscribe to an AWS IoT Core device MQTT topic using MQTTnet v5
and if so, please, please, please post your code!!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've kind of reached an impass now trying to get a dotnet 8 Maui App to connect successfully to AWS IoT Core. In MQTTnet v4, one would do something similar to this:
In MQTTnet v5 of course,
MqttClientTlsOptionsBuilder
no longer hasWithTls()
, having been replaced withWithTlsOptions()
.WithTlsOptions()
doesn't have the propertyCertificates
(orCertificate
) but does haveWithTlsOptions().WithTrustChain(<chain-here)
.However, on Android, one just gets the error
Exception of type 'Interop+AndroidCrypto+SslException' was thrown.
On iOS, the error is a little different:Could not resolve assembly "system.net.security.resources"
.Within the examples, there is a
Connect_With_Amazon_AWS()
(https://github.com/dotnet/MQTTnet/blob/master/Samples/Client/Client_Connection_Samples.cs) method but it doesn't include the certificates perhaps suggesting the certificates need to be put somewhere so that they can be automatically grabbed? Not really sure, we're guessing at this point!Has anyone successfully managed to connect, publish and subscribe to an AWS IoT Core device MQTT topic using MQTTnet v5
and if so, please, please, please post your code!!
Beta Was this translation helpful? Give feedback.
All reactions