This project simulates an IoT device that connects to both Azure IoT Hub via Device Provisioning Service (DPS) and AWS IoT Core using MQTT over TLS. It demonstrates secure communication, telemetry data transmission, and command handling.
-
Python 3.7 or higher
-
Install required packages:
pip install paho-mqtt cryptography
-
OpenSSL for generating certificates
-
Azure IoT Hub and DPS setup
-
AWS IoT Core setup
-
Certificates for both Azure and AWS
-
Configuration file (
config.json)
# Generate Root CA
openssl genrsa -out rootCA.key 2048
openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.pem -subj "/CN=IoTDevSimRootCA" -config .\openssl.conf
# Generate Device Certificate signed by Root CA
openssl genrsa -out device.key 2048
openssl req -new -key device.key -out device.csr -subj "/CN=IoTDevSimRootCA" -config .\openssl.conf
openssl x509 -req -in device.csr -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out device.pem -days 365 -sha256
# Output of last command
Certificate request self-signature ok
subject=CN = IoTDevSimRootCA