Equipment MQTT secure access method and device under smart home platform, and storage medium

By adopting multiple authentication and timed detection of offline devices in the smart home platform, the problem of secure access to the device is solved, the security and load balancing of MQTT server information are ensured, and the user security and platform stability are improved.

CN119544253APending Publication Date: 2025-02-28四川长虹新网科技有限责任公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411400422.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-09
Publication Date
2025-02-28

AI Technical Summary

Technical Problem

In smart home platforms, the security access problem of devices causes third parties to simulate device requests, obtain server information and connect, causing risks to user security and platform operations.

Method used

By defining the method of using the MQTT protocol to securely access the smart home platform by terminal devices, including multiple authentication and timed detection of offline devices, ensuring that the MQTT server information is not easily leaked and balancing the load of different MQTT servers.

Benefits of technology

It effectively prevents the leakage of MQTT server information, ensures the safe use of users and the normal operation of the platform, and avoids the collapse of a certain MQTT server due to excessive connection pressure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119544253A_ABST
    Figure CN119544253A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of Internet of Things smart home, in particular to a device MQTT secure access method and device under a smart home platform and a storage medium. According to the method, an MQTT server and data are configured on a smart home platform, a to-be-added device initiates an adding request to the smart home platform to obtain MQTT server information, and if the request is added to a setting rule of the smart home platform under an MQTT protocol through a user-defined terminal device, the to-be-added device is added to the smart home platform. If yes, the smart home platform returns a preset number of MQTT server information to the to-be-added device; and the to-be-added device is added into the MQTT server according to the MQTT server information, and after the MQTT server information succeeds, the smart home platform stores the information of the MQTT connection of the added device, and counts the number of connections of different MQTT servers. According to the method provided by the invention, the problems that the information of the MQTT server is not easy to leak and the MQTT server after information leakage cannot be randomly connected are solved, the problem of load balancing of different MQTT servers is also solved, and the situation that the connection pressure of a certain MQTT server is too large is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Internet of Things smart home technology, and in particular to an MQTT secure access method, device and storage medium for devices on a smart home platform. Background Art

[0002] With the rapid development of science and technology, smart home has penetrated into all aspects of life, and it is also developing rapidly, greatly enriching people's lives. People are also more and more willing to try new things. Among them, terminal devices, as the actual access users of smart homes, are crucial to ensuring the safe use of users and the safe operation of providers while meeting the various functional requirements of users. This technology solves the problem of secure device access to the smart home platform, making it difficult for third parties to simulate device requests, obtain key server information and connect, so as to ensure the safe use of users and the normal operation of the platform. Summary of the invention

[0003] In view of the deficiencies in the prior art, the present invention provides a method, device and storage medium for secure MQTT access of devices under a smart home platform. By defining a secure method for terminal devices to join the smart home platform through the MQTT protocol, the information of the MQTT server is not easily leaked, and the MQTT server cannot be connected at will after the information is leaked. The problem of load balancing of different MQTT servers is also solved, avoiding excessive connection pressure on a certain MQTT server.

[0004] The present invention discloses a method for securely accessing a device MQTT on a smart home platform through an embodiment, including:

[0005] Initialize several MQTT servers and data, configure the MQTT server information to the smart home platform, and import the device information to be added to the smart home platform;

[0006] The device to be added initiates a request to the smart home platform to obtain the MQTT server information. If the request is verified, the smart home platform returns a preset amount of MQTT server information to the device to be added;

[0007] The device to be joined joins the MQTT server according to the MQTT server information. If successful, the smart home platform stores the MQTT connection information of the joined device and counts the number of connections to different MQTT servers.

[0008] Furthermore, the method also includes the smart home platform periodically checking whether there are offline devices. If there are, the MQTT connection information of the offline devices is deleted, and the number of connections to the corresponding MQTT server is re-counted. Timely detection of whether there are offline devices is necessary, because once the device is offline, there may be a risk of information leakage when it is connected again. Therefore, it is necessary to delete the MQTT connection information of the offline device in time to prevent it from leaking information after it is connected again. At the same time, the server connection resources can be cleaned up in time to prevent server resources from being wasted due to offline devices.

[0009] Furthermore, the MQTT server and data are initialized, the MQTT server information is configured to the smart home platform, and the information of the devices to be added is imported to the smart home platform, including: deploying several MQTT server clusters, deploying MQTT services on multiple servers, setting the platform user name and platform password used by the smart home platform to connect to the MQTT server, and generating a real platform password through certain characters of the platform user name and certain characters of the platform password for the smart home platform to connect; setting the device user name and device password used by the device to be added to connect to the MQTT server, and generating a real device password through certain characters of the device user name and certain characters of the device password for the device to be added. For example, after the user determines the platform user name and platform password, the specific characters of the user name and the specific characters of the password are obtained through the MD5 encryption algorithm.

[0010] Import the MQTT server information into the smart home platform, including the MQTT server list, the connection IP address, port number, platform user name, platform password, real platform password, device user name, device password, and topic information to be subscribed to for each MQTT server; import the device MAC, SN, type, and model of the device information to be added into the smart home platform for authentication of the device connection to be added. The smart home platform is connected to the MQTT server.

[0011] Furthermore, the device to be added initiates a request to the smart home platform to obtain the MQTT server information. If the request is verified, the smart home platform returns a preset amount of MQTT server information to the device to be added, including: the device to be added requests the current timestamp from the smart home platform, generates a verification key through the timestamp, and generates a device token through the verification key and the device user name. Specifically, the timestamp and a 9-digit random number form the verification key; a few characters of the device user name and the verification key are encrypted through MD5 to obtain the device token.

[0012] The device to be added sends the device MAC, verification key and device token in JSON format as parameters to the smart home platform to initiate an HTTPS request to obtain the MQTT server information;

[0013] After the smart home platform obtains parameter information through HTTPS request, it verifies whether the device MAC, verification key and device token are legal. After the verification is passed, the information of the first several MQTT servers with the least number of connections is returned to the device to be added. Preferably, among these several MQTT servers, they are arranged in order of the least number of connections, so that the device to be added can give priority to the MQTT server with the least number of connections when connecting.

[0014] The MQTT server information includes: MQTT server list, MQTT server user name and password.

[0015] The device to be added joins the MQTT server according to the MQTT server information, including: the device to be added tries to connect for a preset number of times in sequence from the MQTT server with the least number of connections according to the MQTT server information until the connection is successful; if all are unsuccessful, re-initiate a request to the smart home platform. For example, try to initiate a connection to the server ranked first, if successful, proceed to the next step, if unsuccessful, the next MQTT server should be selected after several attempts, if all are unsuccessful, re-initiate a request to the smart home platform, and re-perform the connection process according to the above operations.

[0016] Furthermore, the smart home platform stores the information of the MQTT connection of the device to be added, and counts the number of connections to the MQTT server, including: the device to be added reports the connection success information to the smart home platform through the MTQQ server to which it is successfully connected according to the specified topic and the specified command, and the connection success information includes the MAC of the device to be added and the information of the MQTT server to which the device to be added is successfully connected; after the smart home platform reports the connection success information, it obtains and stores the MAC of the device to be added and the information of the MQTT server to which the device to be added is successfully connected. In this way, the number of connections of each MQTT server can be counted in real time, so that when the information of the first several MQTT servers with the least number of connections is returned to the device to be added, the MQTT server with the least number of connections can be sent down to achieve a balanced number of connections for each MQTT server, and prevent a certain MQTT server from crashing due to too many connections.

[0017] In order to achieve the above-mentioned objectives, the present invention also provides an MQTT security access device for devices under a smart home platform, which includes: a first setting module, used to initialize a number of MQTT servers and data, configure the MQTT server information to the smart home platform, and import the information of the device to be added to the smart home platform; a second request verification module, in which the device to be added initiates a request to the smart home platform to obtain the MQTT server information. If the request passes the verification, the smart home platform returns a preset number of MQTT server information to the device to be added; a third recording module, used for the device to be added to join the MQTT server according to the MQTT server information. If successful, the smart home platform stores the MQTT connection information of the added device and counts the number of connections to the MQTT server.

[0018] In order to achieve the above-mentioned purpose, the present invention also provides a storage medium storing a number of computer instructions for executing the above-mentioned MQTT device secure access method under the smart home platform.

[0019] The technical principle of the present invention is: a secure method for joining the smart home platform through the MQTT protocol through a custom terminal device. Each time the device needs to join the server of the smart home platform, it needs to undergo multiple authentications and will be deleted in time after going offline.

[0020] Compared with the prior art, the present invention has the following beneficial effects: it makes the information of the MQTT server less likely to be leaked, and the MQTT server after the information is leaked cannot be connected at will. It also solves the problem of load balancing of different MQTT servers and avoids excessive connection pressure on a certain MQTT server. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solution of the present invention and facilitate further understanding of the technical effects, technical features and purposes of the present invention, the present invention is described in detail below in conjunction with the accompanying drawings. The accompanying drawings constitute an essential part of the specification and are used together with the embodiments of the present invention to illustrate the technical solution of the present invention, but do not constitute a limitation to the present invention.

[0022] Figure 1 A flow chart of the method of the present invention;

[0023] Figure 2 This is a flow chart of setting an MQTT server in an embodiment of the method of the present invention;

[0024] Figure 3 This is a flow chart of a device requesting to join an MQTT server in an embodiment of the method of the present invention;

[0025] Figure 4This is a flow chart of device connection and statistics of MQTT server connection information in an embodiment of the method of the present invention. DETAILED DESCRIPTION

[0026] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. Of course, the specific embodiments described below are only intended to explain the technical solutions of the present invention, rather than to limit the present invention. In addition, the parts described in the embodiments or the accompanying drawings are only examples of the relevant parts of the present invention, rather than the entirety of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art should naturally belong to the protection scope of the present invention.

[0027] like Figure 1-4 As shown, the present invention proposes a device MQTT secure access method under a smart home platform through the following embodiments, including the following steps:

[0028] Initialize several MQTT servers and data, configure the MQTT server information to the smart home platform, and import the device information to be added to the smart home platform;

[0029] The device to be added initiates a request to the smart home platform to obtain the MQTT server information. If the request is verified, the smart home platform returns a preset amount of MQTT server information to the device to be added;

[0030] The device to be joined joins the MQTT server according to the MQTT server information. If successful, the smart home platform stores the MQTT connection information of the joined device and counts the number of connections to different MQTT servers.

[0031] In this embodiment, if Figure 4 As shown, the method also includes the smart home platform periodically checking whether there are offline devices. If there are, the MQTT connection information of the offline devices is deleted, and the number of connections to the corresponding MQTT server is re-counted. Timely detection of offline devices is necessary because once a device is offline, there may be a risk of information leakage when it is connected again. Therefore, it is necessary to delete the MQTT connection information of the offline device in time to prevent it from leaking information after it is connected again. At the same time, the server connection resources can be cleaned up in time to prevent server resources from being wasted due to offline devices.

[0032] In this embodiment, if Figure 2As shown, the MQTT server and data are initialized, the MQTT server information is configured to the smart home platform, and the information of the devices to be added is imported into the smart home platform, including: deploying several MQTT server clusters, deploying MQTT services on multiple servers, setting the platform user name and platform password used by the smart home platform to connect to the MQTT server, and generating a real platform password through certain characters of the platform user name and certain characters of the platform password, which is used for the smart home platform connection; setting the device user name and device password used by the device to be added to connect to the MQTT server, and generating a real device password through certain characters of the device user name and certain characters of the device password, which is used for the device to be added to connect. For example, after the user determines the platform user name and platform password, the specific characters of the user name and the specific characters of the password are obtained through the MD5 encryption algorithm. Specifically, taking the platform username "kiuoaoli" and the platform password "ui*78*dfaf^5%asdf" as an example, the real platform password is the string composed of the first 5 digits of the platform username + the last 6 digits of the platform password, which is encrypted with md5 and calculated as: ad6838694ce0d8821a67c1136be44a10. Finally, set the username: kiuoaoli and password: ad6838694ce0d8821a67c1136be44a10 to the MQTT server.

[0033] Import the MQTT server information into the smart home platform, including the MQTT server list, the connection IP address, port number, platform user name, platform password, real platform password, device user name, device password, and topic information to be subscribed to for each MQTT server; import the device MAC, SN, type, and model of the device information to be added into the smart home platform for authentication of the device connection to be added. The smart home platform is connected to the MQTT server.

[0034] In this embodiment, if Figure 3As shown, the device to be added initiates a request to the smart home platform to obtain the MQTT server information. If the request is verified, the smart home platform returns a preset amount of MQTT server information to the device to be added, including: the device to be added requests the current timestamp from the smart home platform, generates a verification key through the timestamp, and generates a device token through the verification key and the device user name. Specifically, the timestamp and a 9-digit random number form the verification key; some characters of the device user name and the verification key are encrypted through MD5 to obtain the device token. For example: the timestamp + 9-digit random number is "1705052372123999900980", which is the verification key. The device token "15881b04728b3124372e3835f0782012" is obtained by encrypting the first 5 characters of the device user name "BF9876BC9835" and the verification key through MD5.

[0035] The device to be added sends the device MAC, verification key and device token in JSON format as parameters to the smart home platform to initiate an HTTPS request to obtain the MQTT server information;

[0036] After the smart home platform obtains parameter information through HTTPS request, it verifies whether the device MAC, verification key and device token are legal. After the verification is passed, the information of the first several MQTT servers with the least number of connections is returned to the device to be added. Preferably, among these several MQTT servers, they are arranged in order of the least number of connections, so that the device to be added can give priority to the MQTT server with the least number of connections when connecting.

[0037] The MQTT server information includes: MQTT server list, MQTT server user name and password.

[0038] In this embodiment, the device to be added joins the MQTT server according to the MQTT server information, including: the device to be added tries to connect for a preset number of times in sequence from the MQTT server with the least number of connections according to the MQTT server information until the connection is successful; if all are unsuccessful, re-initiate a request to the smart home platform. For example, try to initiate a connection to the server ranked first, if successful, proceed to the next step, if unsuccessful, the next MQTT server should be selected after several attempts, if all are unsuccessful, re-initiate a request to the smart home platform, and re-perform the connection process according to the above operation.

[0039] In this embodiment, if Figure 4As shown, the smart home platform stores the information of the MQTT connection of the device to be added, and counts the number of connections to the MQTT server, including: the device to be added reports the connection success information to the smart home platform through the MTQQ server to which it is successfully connected according to the specified topic and the specified command, and the connection success information includes the MAC of the device to be added and the information of the MQTT server to which the device to be added is successfully connected; after the smart home platform reports the connection success information, it obtains and stores the MAC of the device to be added and the information of the MQTT server to which the device to be added is successfully connected. In this way, the number of connections of each MQTT server can be counted in real time, so that the information of the first several MQTT servers with the least number of connections is returned to the device to be added, and the MQTT server with the least number of connections can be sent down to achieve a balanced number of connections for each MQTT server, and prevent a certain MQTT server from crashing due to too many connections.

[0040] In order to achieve the above-mentioned objectives, the present invention also provides an MQTT security access device for devices under a smart home platform, which includes: a first setting module, used to initialize a number of MQTT servers and data, configure the MQTT server information to the smart home platform, and import the information of the device to be added to the smart home platform; a second request verification module, in which the device to be added initiates a request to the smart home platform to obtain the MQTT server information. If the request passes the verification, the smart home platform returns a preset number of MQTT server information to the device to be added; a third recording module, used for the device to be added to join the MQTT server according to the MQTT server information. If successful, the smart home platform stores the MQTT connection information of the added device and counts the number of connections to the MQTT server.

[0041] In order to achieve the above-mentioned purpose, the present invention also provides a storage medium storing a number of computer instructions for executing the above-mentioned MQTT device secure access method under the smart home platform.

[0042] It should be noted that the above embodiments are only for more clearly illustrating the technical solutions of the present invention. Those skilled in the art will understand that the implementation methods of the present invention are not limited to the above contents, and obvious changes, replacements or substitutions based on the above contents do not exceed the scope of the technical solutions of the present invention; other implementation methods will naturally fall within the scope of the present invention without departing from the concept of the present invention.

Claims

1. A method for securely accessing devices using MQTT on a smart home platform, characterized in that: The steps include: Initialize several MQTT servers and data, configure the MQTT server information to the smart home platform, and import the device information to be added to the smart home platform; The device to be added initiates a request to the smart home platform to obtain MQTT server information. If the request is verified, the smart home platform returns a preset amount of MQTT server information to the device to be added; The device to be joined joins the MQTT server according to the MQTT server information. If successful, the smart home platform stores the MQTT connection information of the joined device and counts the number of connections to the MQTT server.

2. The method for securely accessing a device via MQTT under a smart home platform as claimed in claim 1, characterized in that: Also includes: The smart home platform periodically checks whether there are offline devices. If so, the MQTT connection information of the offline devices is deleted and the number of connections to the corresponding MQTT server is re-counted.

3. The method for securely accessing a device via MQTT under a smart home platform as claimed in claim 2, characterized in that: Initializing the MQTT server and data, configuring the MQTT server information to the smart home platform, and importing the device information to be added to the smart home platform include: Deploy several MQTT server clusters, and set the platform username and platform password used by the smart home platform to connect to the MQTT server, and generate the real platform password through certain characters of the platform username and certain characters of the platform password; set the device username and device password used by the devices to be added to connect to the MQTT server, and generate the real device password through certain characters of the device username and certain characters of the device password; Import the MQTT server information into the smart home platform, including the MQTT server list, the connection IP address, port number, platform user name, table platform password, real platform password, device user name, table device password and topic information to be subscribed to for each MQTT server; Import the device MAC, SN, type, and model of the device information to be added into the smart home platform; The smart home platform is connected to the MQTT server.

4. The method for securely accessing a device MQTT under a smart home platform as claimed in claim 3, characterized in that: The device to be added initiates a request to the smart home platform to obtain the MQTT server information, and if the request passes the verification, the smart home platform returns a preset amount of MQTT server information to the device to be added, including: The device to be added requests the current timestamp from the smart home platform, generates a verification key through the timestamp, and generates a device token through the verification key and the device user name; The device to be added uses the device MAC, verification key and device token as parameters to initiate a request to the smart home platform to obtain MQTT server information; After the smart home platform verifies the device MAC, verification key and device token, it returns the information of the first several MQTT servers with the least number of connections to the device to be added.

5. The method for securely accessing a device via MQTT under a smart home platform as claimed in claim 4, characterized in that: The verification key generated by the timestamp includes a timestamp and a 9-bit random number; The generating of the device token by using the verification key and the device user name includes encrypting certain characters of the device user name and the verification key by using MD5.

6. The method for securely accessing a device MQTT under a smart home platform as claimed in claim 4, characterized in that: The MQTT server information includes: MQTT server list, MQTT server username and password.

7. The method for securely accessing a device via MQTT under a smart home platform as claimed in claim 2, characterized in that: The device to be joined joins the MQTT server according to the MQTT server information, including: The device to be joined attempts to connect for a preset number of times starting from the MQTT server with the least number of connections according to the MQTT server information until the connection is successful; if all attempts fail, the device re-initiates a request to the smart home platform.

8. The method for securely accessing a device via MQTT under a smart home platform as claimed in claim 2, wherein: The smart home platform stores the information of the MQTT connection of the added device and counts the number of connections to the MQTT server, including: The device to be added reports the connection success information to the smart home platform through the MTQQ server to which it is successfully connected according to the specified topic and the specified command, and the connection success information includes the MAC of the device to be added and the information of the MQTT server to which the device to be added is successfully connected; After reporting the connection success information, the smart home platform obtains and stores the MAC of the device to be added and the information of the MQTT server to which the device to be added is successfully connected.

9. The MQTT secure access device for devices under the smart home platform is characterized by: include: The first setting module is used to initialize several MQTT servers and data, configure the MQTT server information to the smart home platform, and import the device information to be added to the smart home platform; A second request verification module, in which the device to be added initiates a request to the smart home platform to obtain MQTT server information. If the request passes the verification, the smart home platform returns a preset amount of MQTT server information to the device to be added; The third recording module is used for the device to be added to join the MQTT server according to the MQTT server information. If successful, the smart home platform stores the MQTT connection information of the added device and counts the number of connections to the MQTT server.

10. A storage medium, characterized in that: A plurality of computer instructions are stored for executing the MQTT secure access method for devices under the smart home platform described in any one of claims 1-8.