-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AWS support? #927
Comments
Did you already take a look at https://github.com/chkr1011/MQTTnet/wiki/Client#connecting-with-amazon-aws? |
You can also try to use the WebSocket4Net extension of this lib because WebSocket4Net supports more protocols than the WebSocket implementation in .NET. |
Thanks for the pointers! I did look at the link but this is all about Sigv4, not certificate authentication. Also, I tried to use WebSocket4Net but i can't seem to find any docs or examples on how to use it. What should I do except The more I read, the more it seems I need to use the "x-amzn-mqtt-ca" header somehow... |
I'm working with the same problem: I want to authenticate in AWS IoT with certificate on port 8883.
I don't think that the problem is in the certificate.pem.crt and privatekey.pen.key released by AWS... |
I haven't been able to get this working. But if you want to make sure your certificates are fine, you can test it like this: openssl s_client -CAfile ca.pem -cert client.pem -key client.key -connect your-endpoint.amazonaws.com:8883 If you ever make this work, I am still very interested! |
Is useful to setup the rootCA certificate? AWS released 3 main files: dev certificate, dev private key and root CA certificate. How to setup the last one? Note: I have found this function that takes the dev's certificate and private key and decodes the certificate (it works)
What can I do now? |
I have performed the test:
|
ok, now the verification works: I have to remove the -CAfile argument... it's strange but works |
Great find! Have you resolved the verification in the .Net code as well? I would love to see a working example of that. |
My terror was that the error is only in the win implementation of dotnet code... nope...
but in the configuration I have specified that
NOTE |
ah my test with openss was:
|
I had a similar problem when connecting to AWS IoT. The trick for me was to export and recreate the certificate in the MqttClientOptionsBuilderTlsParameters. Using only
If there is a better solution, please share it. |
Hi @dasa-asen , thanks! Can you post a little more of your code? I still can't get it to work. Some larger example would be helpfull. Thanks! |
Sure. Here is my code for opening the MQTT/TLS client:
I receive the certificates and keys in PEM format packed in a single zip file. I unzip, read the PEM data and pass the binary content to the constructor of X509Certificate2. I am certainly no TLS expert and have come up with this by trial and error. The Edit: I removed the |
Thanks guys for sharing your tests. I followed this description https://github.com/aws-samples/iot-dotnet-publisher-consumer With these settings I can successfully connect and publish a message with MQTTnet to AWS! |
For others trying this I would like to mention two pitfalls that at first prevented me from publishing messages. Quoted from the AWS IoT docs:
Meaning, don't use |
Hi, |
This looks like a duplicate of #721 I've got working code that I'll share, just deciding on the best way to do that. |
@Chef904 Having the same problem. Were you able to get it working? |
@albert-t25 No, unfortunately not. I use M2MQTTdotnetcore now. When I have time I might look at the problem again. Sorry 😕 |
Thank you @Chef904 . I have tried M2MQTTdotnetcore, but it still times out. |
I answered this in #721 also MQTTNet to AWS IoT - Core It's worth noting that these gists also work for M2MQTT. The trick to it all is loading the certs into X509 objects and using a callback for verification (there's a callback for the M2MQTT signature in the helper class). |
In my case, it was a silly mistake with AWS regions. Anyone with similar problem check out #1079 (comment) |
In my case, the problem was that I was using the default Thing access policy, which only allows connections from the Java, Node.js, and Python SDKs. |
I've collected every troubleshooting tips under https://github.com/chkr1011/MQTTnet/wiki/Client#connecting-with-amazon-aws now. There is a discussion available under #1225 where I'm trying to collect all issues with AWS now since all the same issues seem to occur very often. |
The aws example in this link https://github.com/chkr1011/MQTTnet/wiki/Client#connecting-with-amazon-aws appears to simply not check the CA and always return true, which doesn't seem secure. |
Describe the bug
Is this a bug? Of not supported? I am trying to connect to AWS IoT with client certificate over port 8883. I see some references to ALPN but that doesn't seem a hard requirement. But I couldn't find anyway to configure ALPN as well, so that might be related.
Which project is your bug related to?
Details
I checked that the certificates are valid by using "openssl s_client -CAfile ca.pem -cert client.pem -key client.key -connect your-endpoint.amazonaws.com:8883". Also, I catch the certificate errors in MQTTnet so that all seems fine. But when I try a ConnectAsync, this is the error I receive: "MQTTnet.Exceptions.MqttCommunicationTimedOutException' was thrown".
The text was updated successfully, but these errors were encountered: