Coder Social home page Coder Social logo

ssl connection problem about paho.mqtt.cpp HOT 9 CLOSED

eclipse avatar eclipse commented on July 1, 2024
ssl connection problem

from paho.mqtt.cpp.

Comments (9)

fpagliughi avatar fpagliughi commented on July 1, 2024

I finally found something that could do this... The GNU Makefile in the samples directory was linking the ssl_publish sample to the non-SSL version of the Paho C library. I just pushed the fix for that to the 'develop' branch.

Please make sure that you're linking to the Paho C library paho-mqtt3as (with the 's' at the end).

I tested this against the certificates in the Paho C test directory. I ran mosquitto with the configuration from there:

git clone https://github.com/eclipse/paho.mqtt.c.git
cd paho.mqtt.c
mosquitto -c test/tls-testing/mosquitto.conf

And then I used the file "test-root-ca.crt" from that directory (paho.mqq.c/test/tls-testing) as the trust store for ssl_publish. That all worked for me.

Other than that, the C++ library just passes the names of the SSL/TLS certificates down to the C library. If there are still issues, perhaps we can get help from the folks working directly with the C library.

from paho.mqtt.cpp.

codavide avatar codavide commented on July 1, 2024

Thank you very much for the suggestions!

I will try it immediately and then I will inform you if this work.

from paho.mqtt.cpp.

codavide avatar codavide commented on July 1, 2024

OK,
thank you again,
I have tested ssl_publish on an ubuntu machine and,, following your iindications, it works properly,
But I have stll the same problem indicated in my first post, running it in my raspberry (with the same configuration and certificates).

Some other hints:

  • sync_publisher works also on the raspberry, it iconnects itself to the mosquitto correctly.
  • I have started mosquitto in verbose mode and when I start the ssl_publish client, it doesn't print on console (it is not a TLS handshake problem). It doesn't receive the connection.

Please, let me know if you have some other suggestion,

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on July 1, 2024

So, if I understand... It works over localhost on either an Ubuntu PC or a Raspberry Pi, but if you try to connect a client on the Pi to the mosquitto broker on a PC, it doesn't work?

Does it work with another client across this connection? (Java client or maybe mosquitto utility like mosquitto_pub)? Could there be a firewall getting in the way? Or the server configured for only localhost?

I have a few hundred RPi's at my office, so I can try this as well. But I won't be there for a few days.

from paho.mqtt.cpp.

codavide avatar codavide commented on July 1, 2024

No sorry I have not been clear,
I have installed the paho.mqtt library and the mosquitto server both on the ubuntu PC and on the raspberry Pi, and for both, I have tested the localhost connection, running mosquitto using the same configuration that you have indicated: test/tls-testing/mosquitto.conf.

If I run ssl_publish on the Ubuntu PC, the connection to the local mosquitto works.
if I run ssl_publish on the Raspberry Pi, the connection to the local msquitto doesn't work.

I hope to have been more clear now,

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on July 1, 2024

Oh. OK. I've got it now. I will test that as soon as I can.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on July 1, 2024

I tested on a RaspberryPi, and it worked as expected. I did not see a problem.

I'm using Raspbian Jessie on an RPi2, and I did a full apt-get update/upgrade before starting the tests. This also updated my version of mosquitto:

$ uname -a
Linux thrivepi 4.4.50-v7+ #970 SMP Mon Feb 20 19:18:29 GMT 2017 armv7l GNU/Linux

$ mosquitto -h
mosquitto version 1.4.11 (build date Mon, 20 Feb 2017 22:47:27 +0000)
...

I tested with the latest development version of both Paho C & C++ (the 'develop' branches of each, as of this morning) and did a native build of both using GCC v 4.9.2.

The sample showed the usual output:

$ ./ssl_publish 
Initializing for server 'ssl://localhost:18885'...
  ...OK

Connecting...
Waiting for the connection...
  ...OK

Sending message...
	Delivery complete for token:   ...OK

Sending next message...
1
	Delivery complete for token: 2
  ...OK

Disconnecting...
  ...OK

and mosquitto (running with the verbose '-v' option) showed:

1492447514: New connection from 127.0.0.1 on port 18885.
1492447514: New client connected from 127.0.0.1 as CppAsyncPublisherSSL (c1, k60, u'testuser').
1492447514: Sending CONNACK to CppAsyncPublisherSSL (0, 0)
1492447514: Received PUBLISH from CppAsyncPublisherSSL (d0, q1, r0, m1, 'hello', ... (0 bytes))
1492447514: Sending PUBACK to CppAsyncPublisherSSL (Mid: 1)
1492447514: Received PUBLISH from CppAsyncPublisherSSL (d0, q1, r0, m2, 'hello', ... (0 bytes))
1492447514: Sending PUBACK to CppAsyncPublisherSSL (Mid: 2)
1492447514: Received DISCONNECT from CppAsyncPublisherSSL
1492447514: Client CppAsyncPublisherSSL disconnected.

from paho.mqtt.cpp.

codavide avatar codavide commented on July 1, 2024

OK, thank you very much for the test,
in my tests I have used the master version of paho-mqtt-c and not the develop branch. I will try with that branch and then I will let you know the result.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on July 1, 2024

This seems to be working now.

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.