The invention discloses a
secure communication method and
system of an
MQTT protocol based on a national cryptographic module, a
server and a
client based on
MQTT protocol communication are both configured with the national cryptographic module, and the
secure communication method comprises the following steps: the
server and the
client generate an initial key pair based on the national cryptographic module, signature
verification is carried out based on a national cryptographic
algorithm and the initial key pair, so that security identity
authentication between the
server and the
client is realized; negotiating an
encryption key between the server and the client based on a national secret
algorithm; the client sends a connection message of an
MQTT protocol encrypted based on an
encryption key and a national cryptographic
algorithm to the server, and
verification of a client user name and a
password is carried out; the MQTT protocol communication based on the
encryption key and the national cryptographic algorithm is carried out based on the
verification result, SM2 algorithm signature and signature verification are fused in the MQTT protocol based on the national
cryptographic hardware cryptographic module, the SM4 algorithm is adopted to symmetrically encrypt and decrypt data transmitted by the MQTT protocol, the MQTT protocol conforming to the national cryptographic algorithm is designed, and the
confidentiality of the data is ensured.