mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Fix MQTT certificates (#16999)
This commit is contained in:
parent
677714ecab
commit
1ca2e5226b
@ -424,25 +424,22 @@ async def async_setup_entry(hass, entry):
|
|||||||
keepalive = conf[CONF_KEEPALIVE]
|
keepalive = conf[CONF_KEEPALIVE]
|
||||||
username = conf.get(CONF_USERNAME)
|
username = conf.get(CONF_USERNAME)
|
||||||
password = conf.get(CONF_PASSWORD)
|
password = conf.get(CONF_PASSWORD)
|
||||||
|
certificate = conf.get(CONF_CERTIFICATE)
|
||||||
client_key = conf.get(CONF_CLIENT_KEY)
|
client_key = conf.get(CONF_CLIENT_KEY)
|
||||||
client_cert = conf.get(CONF_CLIENT_CERT)
|
client_cert = conf.get(CONF_CLIENT_CERT)
|
||||||
tls_insecure = conf.get(CONF_TLS_INSECURE)
|
tls_insecure = conf.get(CONF_TLS_INSECURE)
|
||||||
protocol = conf[CONF_PROTOCOL]
|
protocol = conf[CONF_PROTOCOL]
|
||||||
|
|
||||||
# For cloudmqtt.com, secured connection, auto fill in certificate
|
# For cloudmqtt.com, secured connection, auto fill in certificate
|
||||||
if (conf.get(CONF_CERTIFICATE) is None and
|
if (certificate is None and 19999 < conf[CONF_PORT] < 30000 and
|
||||||
19999 < conf[CONF_PORT] < 30000 and
|
broker.endswith('.cloudmqtt.com')):
|
||||||
conf[CONF_BROKER].endswith('.cloudmqtt.com')):
|
|
||||||
certificate = os.path.join(
|
certificate = os.path.join(
|
||||||
os.path.dirname(__file__), 'addtrustexternalcaroot.crt')
|
os.path.dirname(__file__), 'addtrustexternalcaroot.crt')
|
||||||
|
|
||||||
# When the certificate is set to auto, use bundled certs from requests
|
# When the certificate is set to auto, use bundled certs from requests
|
||||||
elif conf.get(CONF_CERTIFICATE) == 'auto':
|
elif certificate == 'auto':
|
||||||
certificate = requests.certs.where()
|
certificate = requests.certs.where()
|
||||||
|
|
||||||
else:
|
|
||||||
certificate = None
|
|
||||||
|
|
||||||
if CONF_WILL_MESSAGE in conf:
|
if CONF_WILL_MESSAGE in conf:
|
||||||
will_message = Message(**conf[CONF_WILL_MESSAGE])
|
will_message = Message(**conf[CONF_WILL_MESSAGE])
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user