I'm trying to get an application running in amazon freertos that uses the just in time provisioning mechanism to allow provisioning of a fleet of devices.
I have run through the steps to set up a demo application in freertos for an Espressif ESP32 device. This works fine, but it involves effectively manually copying in your credentials directly into the source code, in one of the scripts you run. Good proof of concept, but no good for production.
I have separately run through the process of setting up JITP in the AWS backend. The last step is to manually invoke mosquitto from bash to send up a fake message, mimicking an MQTT transmission from a device.
This has the effect of correctly provisioning a device.
My question is how do I take these building blocks and build multiple hardware devices and have them all provision and connect successfully to AWS IOT.
Some specific points: 1. What files go into the device firmware? I confess a lack of expertise in the crypto and certificates side. My guess would be I need to put root.cert; deviceVertAndCACert.crt; deviceCert.key into the device and ping the MQTT request exactly as per the fake message. But how does this vary for multiple devices? What distinguishes one device from another?
I assume the actual code in the hardware device is the same for all devices. Is this assumption valid?
If I succeed in provisioning a large number of devices, how do I handle the incoming data stream in AWS IOT. I would envisage invoking a rule to handle the incoming messages.
Mosquitto fake message:
$ mosquitto_pub --cafile root.cert --cert deviceCertAndCACert.crt --key deviceCert.key -h <prefix>.iot.us-east-1.amazonaws.com -p 8883 -q 1 -t foo/bar -I anyclientID --tls-version tlsv1.2 -m "Hello" -d