我正在为Linux开发一个C应用程序,它使用libmosquitto来实现我的应用程序和其他MQTT代理之间的MQTT通信。
我正在启用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);
}在代码的其他部分,我按照如下方式连接我的客户机(显然,这只是一个缺少信息的代码片段,只是为了说明我是如何使用类的):
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);发布于 2021-02-01 16:27:08
tls_opts_set的第三个选项是您允许的密码。在主机上运行openssl ciphers,查看可用的是什么。您应该能够在这里传递AES256以获得包含AES256的所有密码,但如果没有,则可以运行openssl ciphers AES并使用以冒号分隔的字符串。
https://stackoverflow.com/questions/65996007
复制相似问题