Extract SSL context creation to helper (#15483)

* Extract SSL context creation to helper

* Lint
This commit is contained in:
Paulus Schoutsen 2018-07-16 10:32:07 +02:00 committed by GitHub
parent dd7890c848
commit ad4cba70a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 23 deletions

View file

@ -1,6 +1,5 @@
"""Helper for aiohttp webclient stuff."""
import asyncio
import ssl
import sys
import aiohttp
@ -8,11 +7,11 @@ from aiohttp.hdrs import USER_AGENT, CONTENT_TYPE
from aiohttp import web
from aiohttp.web_exceptions import HTTPGatewayTimeout, HTTPBadGateway
import async_timeout
import certifi
from homeassistant.core import callback
from homeassistant.const import EVENT_HOMEASSISTANT_CLOSE, __version__
from homeassistant.loader import bind_hass
from homeassistant.util import ssl as ssl_util
DATA_CONNECTOR = 'aiohttp_connector'
DATA_CONNECTOR_NOTVERIFY = 'aiohttp_connector_notverify'
@ -154,9 +153,7 @@ def _async_get_connector(hass, verify_ssl=True):
return hass.data[key]
if verify_ssl:
ssl_context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
ssl_context.load_verify_locations(cafile=certifi.where(),
capath=None)
ssl_context = ssl_util.client_context()
else:
ssl_context = False