I am trying to get my flask application to communicate with my HiveMQ Broker Cluster. The cluster only takes TLS communication through port 8883. As I understand it, I would require some certificate files in order to be able to do this, but all guides instructing me on how to create these that I've come across havent helped..
This is my simple test snippet that I cant get to publish to my topic through TSL:
from flask import Flask, render_template, redirect
from flask_mqtt import Mqtt
app = Flask(__name__)
# MQTT configuration
app.config['MQTT_BROKER_URL'] = 'xxxxxxxxxxxxxxxxxxxxx.s2.eu.hivemq.cloud'
app.config['MQTT_BROKER_PORT'] = 8883
app.config['MQTT_USERNAME'] = 'my_user_name'
app.config['MQTT_PASSWORD'] = 'my_password'
app.config['MQTT_TLS_ENABLED'] = True
app.config['MQTT_TLS_INSECURE'] = True
app.config['MQTT_TLS_CA_CERTS'] = '' # Is this needed? If yes, how is such a file created?
app.config['MQTT_TLS_CERTFILE '] = '' # Is this needed? If yes, how is such a file created?
app.config['MQTT_TLS_KEYFILE'] = '' # Is this needed? If yes, how is such a file created?
mqtt = Mqtt(app)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/publish', methods=['POST'])
def publish():
mqtt.publish("control/", "toggle_valve")
return redirect('/', 200)
if __name__ == '__main__':
app.run(debug=True)
I am trying to follow the Flask-MQTT documentation/examples, but I keep getting the error SSL: NO_CIPHERS_AVAILABLE] no ciphers available when trying to run the code..
Are these certification files something that I should get directly from HiveMQ, or do I have to create them myself with openssl or something similar?
Extra info: I am already sure that the url, port, and username+password works, because I have gotten it to work with the paho-mqtt library outside of flask.
Thank you for your time!