From 16085fd5940285f6374971db6369314cdf14cbfd Mon Sep 17 00:00:00 2001 From: Benjamin Dweck Date: Tue, 20 Oct 2020 20:05:30 +0200 Subject: [PATCH] MQTT Client initialized incorrectly with paho-mqtt tls_insecure_set(True) --- torch_agent/torch_agent.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/torch_agent/torch_agent.py b/torch_agent/torch_agent.py index f34f211..d199f7d 100755 --- a/torch_agent/torch_agent.py +++ b/torch_agent/torch_agent.py @@ -77,17 +77,16 @@ def main(): client = mqtt.Client() 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"): 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.publish(mqtt_topic, json.dumps(payload))