MQTT fails to connect using SSL

883 views
Skip to first unread message

HariKrishnan

unread,
Jan 29, 2014, 6:46:13 AM1/29/14
to mq...@googlegroups.com
I am using org eclipse paho c Library to connect to a Mosquitto Broker over SSL . But it returns status -1 . 
 
The code is like : 



    MQTTClient client;
    MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
    MQTTClient_SSLOptions sslopts = MQTTClient_SSLOptions_initializer;
    MQTTClient_message pubmsg = MQTTClient_message_initializer;
    MQTTClient_deliveryToken token;
    int rc;

    MQTTClient_create(&client, ADDRESS, CLIENTID,
        MQTTCLIENT_PERSISTENCE_NONE, NULL);
    conn_opts.keepAliveInterval = 20;
    conn_opts.cleansession = 1;

    sslopts.trustStore="(path to ca.crt)";
    sslopts.keyStore="(path to client.crt )";
    conn_opts.ssl=&sslopts;
    MQTTClient_setCallbacks(client, NULL, connlost, msgarrvd, delivered);

    if ((rc = MQTTClient_connect(client, &conn_opts)) != MQTTCLIENT_SUCCESS)
    {
        printf("Failed to connect, return code %d\n", rc);
        exit(-1);
    }

I have the tried the same thing using Java Library of Eclipse Paho by using the same certificates and it gets connected .. 
Plz Help .. 

Andy Piper

unread,
Jan 29, 2014, 8:49:53 AM1/29/14
to mq...@googlegroups.com
Hi 

This group is for discussion of the MQTT protocol in general rather than specific implementations.

Probably the best thing to do would be to ask this question on the paho-dev mailing list where the Eclipse Paho team can help you ... it doesn't sound like it is a mosquitto issue if the Java client is working... if it is a server issue you could ask on the mosquitto list, but I would start by asking the Paho list.

Also note that the Paho C client has tracing options (documented in the README.md) which may help you here.

Andy


--
To learn more about MQTT please visit http://mqtt.org
---
You received this message because you are subscribed to the Google Groups "MQ Telemetry Transport" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mqtt+uns...@googlegroups.com.
To post to this group, send email to mq...@googlegroups.com.
Visit this group at http://groups.google.com/group/mqtt.
For more options, visit https://groups.google.com/groups/opt_out.



--
Andy Piper | Kingston upon Thames, London (UK)
blog: http://andypiper.co.uk   |   skype: andypiperuk
twitter: @andypiper  |  images: http://www.flickr.com/photos/andypiper

Sai Surya Narayan

unread,
Aug 20, 2016, 5:29:03 AM8/20/16
to MQTT

Sai Surya Narayan

unread,
Aug 20, 2016, 5:31:42 AM8/20/16
to MQTT
Hi HariKrishnan,

Is your problem solved, If so please guide me i am also using Paho-Mqtt C library and i also want to use ssl authentication on that. I am very new to MQTT so please give me some guidelines to use ssl options and authentication in paho-mqtt C library.

Thank you in advance

Reply all
Reply to author
Forward
0 new messages