微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何确定使用 libmosquitto 时使用的加密类型

如何解决如何确定使用 libmosquitto 时使用的加密类型

我正在使用 libmosquitto 为 Linux 开发 C 应用程序,用于我的应用程序和其他地方的 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);
_mqttClient->tls_opts_set(1,"tlsv1.2",NULL);
_mqttClient->tls_insecure_set(FALSE);

解决方法

tls_opts_set 的第三个选项是您允许的密码。在您的主机上运行 openssl ciphers 以查看可用内容。您应该能够在此处传递 AES256 以获取包含 AES256 的所有密码,但如果没有,您可以运行 openssl ciphers AES 并使用该冒号分隔的字符串。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。