Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
Merge pull request #526 from danielkaiser/fix-py310-ssl-context
Browse files Browse the repository at this point in the history
Fix ssl context for Python 3.10
  • Loading branch information
cpainchaud authored Jul 8, 2022
2 parents 22431fc + 4d8f51f commit a477315
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions custom_components/reolink_dev/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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

0 comments on commit a477315

Please sign in to comment.