B - MQTT in the Cloud & AWS* IoT Core
Many users asked whether SmoothMQTT works with cloud services. Now that SSL is implemented it should work with any cloud service that provides MQTT over Sockets. Here you find a very basic and not super secure approach on setting smoothMQTT up to work with AWS IoT Core. If you need proper security, please always hire a security specialist. These exact instructions are meant for proof of concept only.
- Login to IoT Core
- Go to Secure-Policies and select "create Policy
- As name choose something like "smoothMQTT"
- As action type "iot:*"
- As resource type "*"
- Check "Allow"
- Click "Create"
- In the menu select Manage->Things and Create a Single Thing
- Give it a name e.g. "smoothMQTT-client"
- Click "Next"
- Check "Auto-generate a new certificate
- In the attach policies screen select the policy named in 2
- Download the public and private key for your client
- Download the RSA2048 Amazon Root CA public certificate
- Use openssl to convert the public and private key to a pfx file (see Appendix A)
- In Unity create two certificate assets (see chapter 5.2)
- Name one "CA cert" (or something similar) and select the amazon root CA file. Copy it to StreamingAssets using the inspector button
- Name the other one "client cert" and link the pfx file created in step 4.
- Create a scene with SmoothMQTT's MqttManagerWithoutBroker
- Link up certificate assets to the settings
- As host insert the Device data endpoint address. It looks like "something.something.amazonaws.com" (You'll find the correct address in the Settings on IoT Core)
- Set port to 8883
- Set useSSL to true
- Create a publisher or subscriber with a topic (e.g. smoothmqtt/test) and [optionally] a payload.
- On IoT Core open the MQTT test client and subscribe to "smoothmqtt/test" or even "#" and see whether your unity published messages arrive. If you used a subscriber in unity, select "Publish to a topic" on IoT Core and send a message.
Security considerations: If you want to build a secure business solution, you will need to setup proper policies for IoT core, so certain clients can only interact with certain topics and actions. However, a detailed description is out of scope of this manual.
info
*AWS (Amazon Web Services) is a registered trademark in the USA and other countries.