【发布时间】:2021-02-01 16:03:54
【问题描述】:
我正在使用libmosquitto 为我的应用程序和其他地方的 MQTT 代理之间的 MQTT 通信开发适用于 Linux 的 C 应用程序。
我正在启用 TLS 进行身份验证和加密。
我如何才能真正了解在通信过程中使用了哪种类型的加密? AES-256 是要求。
我的 MqttClient 类:
#include <mosquittopp.h>
#include <mosquitto.h>
class MqttClient : public mosqpp::mosquittopp
{
public:
MqttClient(std::string name, uint16 id, std::string rev);
~MqttClient();
void setConnectionInfo(std::string host, int port);
void setUsernamePassw(std::string username, std::string password);
void connect_client();
int publish_message(const std::string _topic, const std::string _message, int QoS, bool retain);
int subscribe_topic(const char * _message);
const std::string getJsonString(const std::string _parameter, const std::string _value);
}
在代码的其他地方,我按如下方式连接我的客户端(显然这只是一个缺少信息的代码 sn-p,但只是为了展示我如何使用该类):
MqttClient _mqttClient = new MqttClient("client1", 12345, "1");
_mqttClient->setConnectionInfo(_mqtt_params.host, _mqtt_params.portNum);
_mqttClient->setUsernamePassw(_mqtt_params.username, _mqtt_params.password);
_mqttClient->tls_set("/etc/certs/cert.pem", NULL, NULL, NULL, NULL);
_mqttClient->tls_opts_set(1, "tlsv1.2", NULL);
_mqttClient->tls_insecure_set(FALSE);
【问题讨论】:
标签: c aes mqtt tls1.2 libmosquitto