From 1bdd3d88de12b498200f68e1d7443bb4db8dda54 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Tue, 26 Dec 2017 12:10:24 +0100 Subject: [PATCH] Bugfix SSL settings on proxy (#288) * Bugfix SSL settings on proxy * fix lint --- hassio/api/__init__.py | 4 ++-- hassio/api/proxy.py | 8 +++++--- hassio/core.py | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/hassio/api/__init__.py b/hassio/api/__init__.py index 31757d193..12afcac4c 100644 --- a/hassio/api/__init__.py +++ b/hassio/api/__init__.py @@ -77,9 +77,9 @@ class RestAPI(object): self.webapp.router.add_post('/homeassistant/start', api_hass.start) self.webapp.router.add_post('/homeassistant/check', api_hass.check) - def register_proxy(self, homeassistant, websession): + def register_proxy(self, homeassistant): """Register HomeAssistant API Proxy.""" - api_proxy = APIProxy(self.loop, homeassistant, websession) + api_proxy = APIProxy(self.loop, homeassistant) self.webapp.router.add_get( '/homeassistant/api/websocket', api_proxy.websocket) diff --git a/hassio/api/proxy.py b/hassio/api/proxy.py index 13a759a40..1190ebe05 100644 --- a/hassio/api/proxy.py +++ b/hassio/api/proxy.py @@ -16,11 +16,13 @@ _LOGGER = logging.getLogger(__name__) class APIProxy(object): """API Proxy for Home-Assistant.""" - def __init__(self, loop, homeassistant, websession): + def __init__(self, loop, homeassistant): """Initialize api proxy.""" self.loop = loop self.homeassistant = homeassistant - self.websession = websession + + # Use homeassistant websession to ignore SSL + self.websession = homeassistant.websession async def _api_client(self, request, path, timeout=300): """Return a client request with proxy origin for Home-Assistant.""" @@ -109,7 +111,7 @@ class APIProxy(object): try: client = await self.websession.ws_connect( - url, heartbeat=60) + url, heartbeat=60, verify_ssl=False) # handle authentication for _ in range(2): diff --git a/hassio/core.py b/hassio/core.py index 3be311e3e..d4965879b 100644 --- a/hassio/core.py +++ b/hassio/core.py @@ -91,7 +91,7 @@ class HassIO(object): self.supervisor, self.snapshots, self.addons, self.host_control, self.updater) self.api.register_homeassistant(self.homeassistant) - self.api.register_proxy(self.homeassistant, self.websession) + self.api.register_proxy(self.homeassistant) self.api.register_addons(self.addons) self.api.register_security() self.api.register_snapshots(self.snapshots)