Skip to main content
Version: 1.3

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.

  1. Login to IoT Core
  2. Go to Secure-Policies and select "create Policy
    1. As name choose something like "smoothMQTT"
    2. As action type "iot:*"
    3. As resource type "*"
    4. Check "Allow"
    5. Click "Create"
  3. In the menu select Manage->Things and Create a Single Thing
    1. Give it a name e.g. "smoothMQTT-client"
    2. Click "Next"
    3. Check "Auto-generate a new certificate
    4. In the attach policies screen select the policy named in 2
    5. Download the public and private key for your client
    6. Download the RSA2048 Amazon Root CA public certificate
  4. Use openssl to convert the public and private key to a pfx file (see Appendix A)
  5. In Unity create two certificate assets (see chapter 5.2)
    1. Name one "CA cert" (or something similar) and select the amazon root CA file. Copy it to StreamingAssets using the inspector button
    2. Name the other one "client cert" and link the pfx file created in step 4.
  6. Create a scene with SmoothMQTT's MqttManagerWithoutBroker
    1. Link up certificate assets to the settings
    2. 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)
    3. Set port to 8883
    4. Set useSSL to true
  7. Create a publisher or subscriber with a topic (e.g. smoothmqtt/test) and [optionally] a payload.
  8. 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.