Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[paho-dev] SSL Connection error using paho C client

Hi,

 

I am getting an error when I try to make a SSL connection with the paho C client. I am using the mosquito broker (V 1.4.2) and have created self-signed certificates on the server with OpenSSL. I am using the mosquitto sub/pub functions on my local machine which worked but the Paho Client doesn't seem to be working. Here are some lines of my source code:   

 

    MQTTClient client;

    MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;

    MQTTClient_SSLOptions sslopts = MQTTClient_SSLOptions_initializer;

    int rc;

 

    while (1)

    {

 

        MQTTClient_create(&client, “ssl://10.10.13.70:8883”, CLIENT_ID,

            MQTTCLIENT_PERSISTENCE_NONE, NULL);

 

        conn_opts.keepAliveInterval = “60”;

        conn_opts.cleansession = “0”;

        conn_opts.reliable = “1”;

        if (username != "")

            conn_opts.username = “username”;

        if (password != "")

            conn_opts.password = “password”;

        conn_opts.connectTimeout = “60”;

        conn_opts.retryInterval = “10”;

 

                sslopts.enabledCipherSuites = “TLSv1”;

                sslopts.trustStore="mqtt-ca.pem";

            sslopts.keyStore=keyStore;

            sslopts.privateKey=privateKey;

 

        sslopts.privateKeyPassword = “passphrase”;

                sslopts.enableServerCertAuth = 0;

        conn_opts.ssl = &sslopts;

 

                if ((rc = MQTTClient_connect(client, &conn_opts)) == MQTTCLIENT_SUCCESS)

          {

            std::cout << "Connection Success";

                    break;

                  }

    }

 

When I start my program here are the error messages I am getting:
rc: -1

20150812 130313.023 getaddrinfo failed for addr ssl://10.10.13.70 with rc -2

20150812 130313.023 ssl://10.10.13.70 is not a valid IP address

 

I know a similar error was reported with the asynchronous connection options but working off the solution, I’m still getting an error.

 

I would be grateful to anyone who could help or point me in the right direction. Thanks.

 

Regards,

Adam


Back to the top