Skip to content

AWS IOT Device Simulation

Bose Ji edited this page Aug 31, 2016 · 1 revision

Simulating an AWS IoT Node with mqtt-spy

In order the test the cloud solution before deployment, one needs to test out various aspects and stimuli for a given use-case requirement.

AWS-IoT Framework provides a secure device level connectivity to the MQTT Broker in the Cloud.

There are missing pieces in the documentation of How to connect to the AWS IoT service. The way in which TLS is expected to operate or how one needs to use the keys is not clearly explained. Hence this leads to confusion. This document attempts to disambiguate the connectivity options.

One of the Important Missing links is that of the Root certificate root-cert.pem:

VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem

This is mandatory to provide the TLS security. So this needs to be downloaded in every IoT device that needs to be authenticated and talk to the AWS IoT Cloud.

In this document we proceed from creating a new Device to Actually simulating the connect to Cloud using mqtt-spy. Most of this document is inspired by the original AWS-IoT for Raspberry Pi article, however here the focus is on simulation rather than actual device operation.

AWS IoT Device Creation 👶

If one visits the First time to the AWS IoT Page, here is how it looks like:

Get Started

Select the Get Started option to Begin.

1. Create A Device

Create 1

Click on the New Device

Create 2

Enter the Name of the Device and Confirm.

Create 3

Create 4

2. Configure Device

Clicking on the Device itself bring open the Info Pane which contains specifics of the selected IoT device.

Configure 1

Click to actually create the device instance by Connecting a Device button.

Configure 2

First select the Choice as Embedded C to get the Generate Certificate Button to appear. The reason Embedded C is selected as it gives the needed configuration information in one place. Next click on the Generate Certificate Button.

Configure 3

Wait for the Security Key download screen to Appear. All the generated Keys need to stored in safe place. Typically these reside in the embedded MCU's Flash memory. For Simulation purpose we store them on the PC in a directory.

Configure 4

Make sure to Download the Root-Cert Needed for the TLS authentication along with the above files.

There should be 4 Files after this Namely:

  • VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem = Root Certificate of AWS IoT for TLS

  • xxxxxxxxxx-certificate.pem = Client Certificate for TLS

  • xxxxxxxxxx-private.pem.key = Client Private Key for TLS (Non-Encrypted)

  • xxxxxxxxxx-public.pem.key = Client Public Key

3. Click to Continue for Device Config information

Device Info

In this we have the following Inputs:

  • AWS IoT Broker URI used by the Device to establish connection with the Cloud

  • AWS IoT Port its important to note this as its not the default one.

  • AWS IoT Key file names used for TLS encrypted communications

This info would later used to configure the mqtt-spy tool.

mqtt-spy tool and AWS IoT Connection Simulation

1. Add a New Connection

New Connection

Connection Select

2. Configure the Connection

Now use the Earlier noted info about the Broker URI. Make sure to Add the :8883 postfix to the Broker URI as AWS IoT Support different port number. Also make sure that the Client ID is same as the Device name created.

Connection Config 1

3. Add Security

Here after making the TLS selection as shown, all the important files needs to be mapped.

  • CA certificate file = Root CA = VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem

  • Client certificate File = xxxxxxxxxx-certificate.pem

  • Client key file = xxxxxxxxxx-private.pem.key

  • Client key password = though there is not password as mentioned in the key file still entering some thing else in the filed helps to keep the operation consistent.

  • Client key in PEM format = True

Security Config

4. Testing out the connectivity

Successful Connection