All Products
Search
Document Center

IoT Platform:Calculate MQTT signature parameters

Last Updated:Jun 03, 2026

When you connect a device to IoT Platform using a custom MQTT client, you must provide the MQTT signature authentication parameters: username, passwd, and mqttClientId.

Overview

Choose one of the following methods to obtain MQTT signature parameters.

Method

Description

Obtain from the IoT Platform console

The supported signature algorithm is hmacsha256.

The device's client ID defaults to ${ProductKey} + '.' + ${DeviceName} and cannot be modified.

Calculate using a Node.js script

The supported signature algorithm is hmacsha256.

The device's client ID defaults to ${ProductKey} + '.' + ${DeviceName} and can be modified.

Obtain from the IoT Platform console

  1. Log on to the IoT Platform console.

  2. On the Overview page, find the instance that you want to manage and click the instance ID or instance name.

  3. In the left-side navigation pane, select Devices > Device to go to the Device page.

  4. Find your device and click View to go to the Device Details page.

  5. On the Device Information tab, click View next to MQTT Connection Parameters to view the MQTT signature parameters.

    Important

    The clientId parameter here maps to mqttClientId, not the device's client ID. MQTT-TLS communication.

    The MQTT Connection Parameters dialog box displays the clientId, username, passwd, mqttHostUrl, and port values. Click Copy All to copy them.

Calculate using a Node.js script

  1. Download and decompress the signTool.zip package, then modify and save the following parameters in the mqttSignTool.js file.

    Parameter

    Example

    Description

    productKey

    a1Ee***

    The device certificate saved when you added the device. Device certificate information.

    View this information on the Device Details page in the console.

    deviceName

    8Co5***

    deviceSecret

    bcabcf***

    timestamp

    2524608000000

    The current time in milliseconds.

    briefId

    12345

    Optional. The device client ID.

    Defaults to ${ProductKey} + '.' + ${DeviceName}. Example: var briefId = '12345'.

    Important

    Custom value, up to 64 characters. Use the device MAC address or SN for easy identification.

  2. Download and install Node.js. This example uses Ubuntu 16.04 (64-bit) with node-v16.5.0-linux-x64.tar.gz.

    1. Log on to your Linux VM.

    2. Download and decompress the package.

      wget https://nodejs.org/dist/v16.5.0/node-v16.5.0-linux-x64.tar.gz
      tar xf node-v16.5.0-linux-x64.tar.gz
      cd node-v16.5.0-linux-x64
      ./bin/node -v

      A successful installation returns the version number.

      v16.5.0
    3. Add the node and npm commands from node-v16.5.0-linux-x64/bin to global PATH.

      ln -s /root/node-v16.5.0-linux-x64/bin/npm   /usr/local/bin/
      ln -s /root/node-v16.5.0-linux-x64/bin/node   /usr/local/bin/
  3. Exit the node-v16.5.0-linux-x64 directory and create a signTool project folder.

    cd..
    mkdir signTool
    cd signTool/
  4. Upload the modified mqttSignTool.js from step 1 to the signTool directory.

  5. In the signTool directory, download the signature library.

    npm install crypto-js
    ls

    Expected directory contents:

    mqttSignTool.js  node_modules  package.json  package-lock.json
  6. Run the mqttSignTool.js script.

    node mqttSignTool.js

    The output contains the MQTT signature authentication parameters.

    Important

    The clientId parameter here maps to mqttClientId, not the device's client ID. MQTT-TLS communication.

    username:
    xxx
    clientId:
    xxx|securemode=2,signmethod=hmacsha256,timestamp=2524608000000|
    passwd:
    xxx