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))