MQTT Connection Authentication Through CONNECT Messages
Interface Function
The IoT platform provides the CONNECT message interface for MQTT devices to access the IoT platform. For details about the API specifications, see mqtt-v3.1.1-os.pdf. After the device is authenticated, the MQTT connection between the device and the IoT platform is established.
The IoT platform supports only MQTTS access. When a device establishes an MQTT connection to the IoT platform through the CONNECT message interface, the TLS certificate must be carried. Visit Obtaining Development Resources to obtain the TLS certificate from the AgentLite directory.
Parameters
Parameter |
Mandatory or Optional |
Type |
Description |
clientId |
Mandatory |
String(256) |
The value of this parameter consists of device ID, authentication type, password signature type, and timestamp, which are separated by underscores (_). The device ID is deviceId returned after the device is registered successfully when the device uses deviceId to access the IoT platform. The value can also be nodeId entered during device registration with the IoT platform when the device uses nodeId to access the IoT platform.
|
username |
Mandatory |
String(256) |
|
password |
Mandatory |
String(256) |
The value of this parameter is the value of the device secret encrypted by using the HMACSHA256 algorithm with the timestamp as the key. The device secret is returned by the IoT platform after the successful device registration. |
The IoT platform performs authentication based on the CONNECT message of the MQTT protocol. The information contained in clientId must be intact. When receiving a CONNECT message, the IoT platform checks the authentication type and password digest algorithm of the device.
- When the timestamp is verified using the HMACSHA256 algorithm, the IoT platform checks whether the message timestamp is consistent with the platform time and then checks whether the secret is correct.
- The timestamp must be contained in the CONNECT message even when the timestamp is not verified using the HMACSHA256 algorithm, but the IoT platform does not check whether the time is correct. In this case, only the secret is checked.
If the authentication fails, the IoT platform returns an error message and automatically disconnects the MQTT link.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot