MQTT Client initialized incorrectly with paho-mqtt tls_insecure_set(True)

This commit is contained in:
B.J. Dweck 2020-10-20 20:05:30 +02:00
parent 5a2ac0c3dc
commit 16085fd594

View File

@ -77,17 +77,16 @@ def main():
client = mqtt.Client() client = mqtt.Client()
protocol = "mqtt" protocol = "mqtt"
if mqtt_require_certificate:
client.tls_set(
ca_certs=mqtt_ca_file,
certfile=mqtt_cert_file,
keyfile=mqtt_key_file,
cert_reqs=ssl.CERT_REQUIRED)
protocol = "mqtts"
if mqtt_broker_host.endswith(".onion"): if mqtt_broker_host.endswith(".onion"):
client.proxy_set(proxy_type=socks.SOCKS5, proxy_addr="localhost", proxy_port=tor_proxy_port) client.proxy_set(proxy_type=socks.SOCKS5, proxy_addr="localhost", proxy_port=tor_proxy_port)
client.tls_insecure_set(True) else:
if mqtt_require_certificate:
protocol = "mqtts"
client.tls_set(
ca_certs=mqtt_ca_file,
certfile=mqtt_cert_file,
keyfile=mqtt_key_file,
cert_reqs=ssl.CERT_REQUIRED)
client.connect(mqtt_broker_host, mqtt_broker_port, 60) client.connect(mqtt_broker_host, mqtt_broker_port, 60)
client.publish(mqtt_topic, json.dumps(payload)) client.publish(mqtt_topic, json.dumps(payload))