Git Product home page Git Product logo

Comments (5)

azogue avatar azogue commented on August 15, 2024 1

Hi @ninjas005, the MQTTConfig object has an .ssl field that you can enable when filling it.

Using it with ssl=True + your secure mqtts host + modified port should work ok. Did you have any problem with it?

from fastapi-mqtt.

azogue avatar azogue commented on August 15, 2024 1

it was not able to connect to the broker, but got refused as broker needs the client certificate to pass me through

The .ssl field is defined as Union[bool, SSLContext] for that reason. If you need extra data for the TLS/SSL connection, you need to configure the SSLContext.

As an example, to connect to https://test.mosquitto.org using port 8883 (MQTT, encrypted, unauthenticated), which requires the cert file, the config should look like this:

from ssl import create_default_context
from fastapi_mqtt import FastMQTT, MQTTConfig

# cert file downloaded from https://test.mosquitto.org/ssl/mosquitto.org.crt
ssl = create_default_context(cafile="tests/mosquitto.org.crt")

mqtt_config = MQTTConfig(host="test.mosquitto.org", port=8883, ssl=ssl)
fast_mqtt = FastMQTT(config=mqtt_config)

from fastapi-mqtt.

ninjas005 avatar ninjas005 commented on August 15, 2024 1

ok thank you.

from fastapi-mqtt.

ninjas005 avatar ninjas005 commented on August 15, 2024

I had already did enabling ssl with the .ssl field and used port 8883. butit was not able to connect to the broker, but got refused as broker needs the client certificate to pass me through.


mqtt_config = MQTTConfig(host=MQTT_CONFIG['host'],
                             port=MQTT_CONFIG['port'],
                             username=MQTT_CONFIG['user'],
                             password=MQTT_CONFIG['pass'],
                             reconnect_retries=-1,
                             reconnect_delay=30,
                             ssl=True
                             )

    fast_mqtt = FastMQTT(config=mqtt_config)

this was my configuration. when i checked the MQTTConfig Class it says about a SSLContext Object which will have the cafile but I am confused how to add that SSLContext object.

from fastapi-mqtt.

azogue avatar azogue commented on August 15, 2024

Closing this as resolved 👍, ok @ninjas005 ?

from fastapi-mqtt.

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.