Bugfix SSL settings on proxy (#288)

* Bugfix SSL settings on proxy

* fix lint
This commit is contained in:
Pascal Vizeli 2017-12-26 12:10:24 +01:00 committed by GitHub
parent d105552fa9
commit 1bdd3d88de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

View File

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

View File

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

View File

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