From 4d8f51f3ca57cc41aa3473bdf14b7c1b560df812 Mon Sep 17 00:00:00 2001 From: Daniel Kaiser Date: Fri, 8 Jul 2022 20:07:45 +0200 Subject: [PATCH] Fix ssl context for Python 3.10 --- custom_components/reolink_dev/base.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/custom_components/reolink_dev/base.py b/custom_components/reolink_dev/base.py index 0bd6682..4ae6d13 100644 --- a/custom_components/reolink_dev/base.py +++ b/custom_components/reolink_dev/base.py @@ -5,6 +5,7 @@ import datetime as dt from typing import Optional +import ssl from urllib.parse import quote_plus from dateutil.relativedelta import relativedelta @@ -19,7 +20,7 @@ from homeassistant.core import Context, HomeAssistant from homeassistant.helpers.network import get_url, NoURLAvailableError from homeassistant.helpers.storage import STORAGE_DIR -from homeassistant.helpers.aiohttp_client import async_get_clientsession +from homeassistant.helpers.aiohttp_client import async_create_clientsession import homeassistant.util.dt as dt_util from reolink.camera_api import Api @@ -548,5 +549,11 @@ def callback_get_iohttp_session(): global last_known_hass if last_known_hass is None: raise Exception("No Home Assistant instance found") - session = async_get_clientsession(last_known_hass, verify_ssl=False) + + context = ssl.create_default_context() + context.set_ciphers("DEFAULT") + context.check_hostname = False + context.verify_mode = ssl.CERT_NONE + session = async_create_clientsession(last_known_hass, verify_ssl=False) + session.connector._ssl = context return session