【问题标题】:How to determine the type of encryption used when using libmosquitto如何确定使用 libmosquitto 时使用的加密类型
【发布时间】: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


    【解决方案1】:

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

    【讨论】:

    • 谢谢。
    猜你喜欢
    • 2017-10-17
    • 1970-01-01
    • 1970-01-01
    • 2019-05-14
    • 1970-01-01
    • 1970-01-01
    • 2021-04-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多