Use bundled certificates if port matches mqtts (#6429)

* Use bundled certificates if port matches mqtts

* Move import requests.certs to top, since it's used in more places

* Add happy and non-happy path tests for default certificate bundle on mqtts port
This commit is contained in:
Dennis de Greef authored and Paulus Schoutsen committed 2017-03-05 14:08:29 -08:00
1 parent eaaa0442e2
commit 1b23b32817
2 files changed
+39

No files matched your search

@@ -9,6 +9,7 @@ import logging
import os
import socket
import time
import requests.certs
import voluptuous as vol
@@ -310,6 +311,10 @@ def async_setup(hass, config):
certificate = os.path.join(os.path.dirname(__file__),
'addtrustexternalcaroot.crt')
# When the port indicates mqtts, use bundled certificates from requests
if certificate is None and port == 8883:
certificate = requests.certs.where()
will_message = conf.get(CONF_WILL_MESSAGE)
birth_message = conf.get(CONF_BIRTH_MESSAGE)