Git Product home page Git Product logo

Comments (7)

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

Hello @phariprasadreddy,

Please update your code with the develop branch. @fpagliughi has improved the code for the ssl_options class.

This problem happens because the ssl_options class is calling the std::string constructor with an invalid (nullptr) const char*. You must feed all the SSL strings, not only the trust_store. The default ssl_options constructor uses MQTTAsync_SSLOptions_initializer, which initializes all strings to NULL. The code bellow generates the same problem:

const char* c = nullptr;
std::string s(c);

Edit: @fpagliughi made the code more resilient. But anyway we must improve the SSL error reporting.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on August 18, 2024

Fixed in commit 2dd7479 currently in the develop branch.

from paho.mqtt.cpp.

phariprasadreddy avatar phariprasadreddy commented on August 18, 2024

@guilhermeferreira @fpagliughi Thanks for quick response. The first issue that is reported is fixed.
However, after setting ssl options and I am trying to connect then I am getting MQTT Exception as below.

Error: MQTT exception -1

Please let me know if you have any sample connecting with ssl.

Thanks,
Hari.

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

@phariprasadreddy I'll need more time to check what is happening. But meanwhile, were you able to set this connection up using Paho C? Just to know if the problem is within the Paho C++, Paho C or your certificates and authentication files.

from paho.mqtt.cpp.

phariprasadreddy avatar phariprasadreddy commented on August 18, 2024

@guilhermeferreira Yes I have checked with Paho C it is working fine. Same pem file I am using for connecting with Paho C++.

Thanks,
Hari.

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

Hello @phariprasadreddy,

There is a bug in this implementation. I'm going to upload a patch next week.

The ssl_options class initializes the MQTTAsync_SSLOptions char pointers even if the members are empty [https://github.com/eclipse/paho.mqtt.cpp/blob/develop/src/ssl_options.cpp#L37]. But it turns out the Paho MQTT C considers a invalid value only if the pointer is null [https://github.com/eclipse/paho.mqtt.c/blob/master/src/SSLSocket.c#L478]. And it ends up using the empty SSL parameters empty-initialized by Paho C++.

So, for the C++ library an invalid SSL parameter can be both null or empty, while for the C library only null represents invalid value.

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on August 18, 2024

The pull request #20 solves this issue. Using this fix you will be able to connect with a server using a valid certificate.

from paho.mqtt.cpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.