Configuring a connection over the MQTT protocol
Kaspersky IoT Secure Gateway 100 forwards data to the
over the protocol. You can read the MQTT protocol specification on the developer's website. Kaspersky IoT Secure Gateway 100 version 2.0 supports MQTT protocol version 3.1.1.
Securing a connection over the MQTT protocol
To securely transmit data over the MQTT protocol:
- Copy the file containing the of the MQTT client (a chain can consist of one leaf of the client) to the directory
/app/Core/pki/certs/transfer/mqtt/publisher
on theHW-IDS
partition of the microSD card. - Copy the file containing the certificate chain that was used to form the to the directory
/app/Core/pki/certs/transfer/mqtt/publisher
on theHW-IDS
partition of the microSD card. - Copy the file of the private of the MQTT client to the directory
/app/Core/pki/private/transfer/mqtt/publisher
on theHW-IDS
partition of the microSD card.
The certificates and encryption keys used by the MQTT client must be in PEM format. The key length of the client certificate must be at least 2048 bits.
Page topConfiguring data transmission over the MQTT protocol
To configure data transmission over the MQTT protocol:
- Create the
MqttPublisherSettings-0.json
file. - In the
MqttPublisherSettings-0.json
file, specify the MQTT settings and their values in accordance with JSON syntax. - Put the configuration file into the directory
/app/Core/config/transfer/mqtt/publisher
on theHW-IDS
partition of the microSD card.
Sample configuration file:
MqttPublisherSettings-0.json
{
"id": 0,
"name": "Kaspersky IoT Secure Gateway 100 MQTT Publisher",
"description": "Transfer data to MQTT Broker by Kaspersky IoT Secure Gateway 100",
"clientId": "KISG100",
"serverUri": "ssl://192.168.188.8:8883",
"security": {
"clientPkiData": {
"certificate": "mqtt-publisher.crt",
"privateKey": "mqtt-publisher.key"
},
"trustStore": ["ca-bundle.crt"]
},
"userCredentials":{
"username": "KISG100",
"password": "4vRXE84zsCy8bLQcZi2HH82TmC"
},
"lastWill": {
"topicName": "LastWill",
"message": "LastMessage"
},
"keepAlive": 800,
"qualityOfService": 1,
"topics": [
{
"id": 0,
"name": "Heartbeat",
"topicName": "Heartbeat"
},
{
"id": 1,
"name": "Temperature",
"topicName": "Temperature"
},
{
"id": 2,
"name": "Speed",
"topicName": "Speed"
}
]
}
To edit files in JSON format, we recommend using a text editor that supports JSON syntax highlight. This will help avoid potential errors (for example, unbalanced braces).
Parameters description in the MqttPublisherSettings-0.json configuration file
The required parameters should be explicitly defined. The other parameters are optional. For optional parameters that are not included in the configuration file, the default value prescribed by the MQTT protocol may be used.
Parameters in the MqttPublisherSettings-0.json file
Parameter name |
Required parameter |
Description |
Possible values and notes |
---|---|---|---|
|
Yes |
ID of the MQTT client that will send data to the MQTT broker. |
The value of this parameter must match the value of the |
|
Yes |
Name of the MQTT client that will send data to the MQTT broker. |
Example: |
|
No |
Description of the MQTT client that will send data to the MQTT broker. |
Example: |
|
No |
Unique identifier of the MQTT client. |
The internal architecture of Kaspersky IoT Secure Gateway 100 involves interaction between a receiving hub and a sending hub. The The |
|
Yes |
Address of the server that the MQTT client will connect to. |
Example:
|
|
Yes |
Parameter block for configuring a secure connection. Contains the |
The |
|
Yes |
Parameter block containing the names of the certificate and private encryption key files of the MQTT client for an encrypted connection. |
|
|
Yes |
Name of the file containing the certificate chain to the MQTT client certificate. |
|
|
Yes |
Private encryption key file name. |
The key length must be at least 2048 bits. |
|
Yes |
Array that includes the name of the file containing the certificate chain to the MQTT broker certificate. |
Name of the file containing the certificate chain to the certificate of the Certification Authority that signed the MQTT broker certificate. |
|
Yes |
Parameter block responsible for authentication of the MQTT client on the server. |
|
|
No |
Name of the user account for authorization on the MQTT server. |
|
|
No |
Password of the user account for authorization on the MQTT server. |
|
|
No |
Parameter block for configuring a message informing that the client was improperly disconnected (LWT message). |
The client can specify the LWT message when connecting to the MQTT broker for the first time. The MQTT broker will store this message until it detects an improper disconnection of the client. Upon detection of an improper connection, it will send the LWT message to all clients that have subscribed to this type of message. The MQTT broker does not send this message when the client is properly disconnected. |
|
No |
Name of the that determines the information channel where the LWT message will be published. |
Example: |
|
No |
Contents of the LWT message. |
Example: |
|
No |
Period of time that the MQTT broker can wait to receive a message from the MQTT client before terminating the connection due to inactivity. |
The default value is Available values: If the If the server deems a client to be inactive or if the client is not responding to queries, the server can disconnect the client at any time, irrespective of the |
|
No |
Parameter defining a guarantee to send messages. |
Agreement between the message sender (publisher) and message recipient (subscriber) that defines a guarantee to deliver a specific message. The MQTT specification defines the following three levels of
The default value is |
|
Yes |
Array from the parameter blocks of MQTT topics. |
Array of A separate parameter block in the array is completed for each MQTT topic. |
|
Yes |
ID of the destination port. |
Example: |
|
Yes |
Name of the destination port. This name must match the outbound port nodes parameter block in the OpcUaClientSettings-0.json configuration file.
|
Example: To correctly transfer data from the OPC UA server to the MQTT broker, you need to map the MQTT topics to their corresponding OPC UA . Thename value is used for mapping.
|
|
Yes |
Name of the MQTT topic. |
Example: See also: Special considerations when generating names of MQTT topics. |
Special considerations when generating names of MQTT topics
When filling in the values for topicName
, please adhere to the following guidelines:
- Wildcard characters cannot be used in the names of MQTT topics. We also do not recommend using the
$
character in the names of MQTT topics. - The name of an MQTT topic cannot be blank (it must contain at least one character).
- The names of MQTT topics are case sensitive.
- The names of MQTT topics can contain a blank space character.
- MQTT topics that are separated by only a
/
character at the beginning or end of the name are considered to be different MQTT topics. - An MQTT topic name consisting of only a
/
character is permitted. - The name of an MQTT topic must not contain the null character (NUL).
- Names of MQTT topics are UTF-8 strings of size that does not exceed 65535 bytes.
Required actions when an MQTT broker certificate is revoked
When an MQTT broker certificate is revoked, you will need to obtain a new certificate from the MQTT broker administrator and replace the revoked certificate. If you do not do this, Kaspersky IoT Secure Gateway 100 will trust both the revoked certificate and the new certificate until the revoked certificate expires. This could lead to a situation in which a connection established over a secure channel is not actually secure.
To use a new MQTT broker certificate instead of a revoked certificate:
- In the
/app/Core/pki/certs/transfer/mqtt/publisher
directory on theHW-IDS
partition of the microSD card, delete the file indicated in thetrustStore
parameter of the MqttPublisherSettings-0.json configuration file. - In the
trustStore
parameter of theMqttPublisherSettings-0.json
configuration file, specify the name of the new certificate file. - Copy the new certificate file to the
/app/Core/pki/certs/transfer/mqtt/publisher
directory on theHW-IDS
partition.