mirror of
https://github.com/nadimkobeissi/mkbsd.git
synced 2024-12-22 18:55:33 +00:00
Cannot connect to host SSLCertVerificationError fixes
This commit is contained in:
parent
82e50c64f0
commit
dbe829e422
10
mkbsd.py
10
mkbsd.py
|
@ -4,9 +4,12 @@ import os
|
||||||
import time
|
import time
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import ssl
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s'
|
url = 'https://storage.googleapis.com/panels-api/data/20240916/media-1a-i-p~s'
|
||||||
|
|
||||||
|
|
||||||
async def delay(ms):
|
async def delay(ms):
|
||||||
await asyncio.sleep(ms / 1000)
|
await asyncio.sleep(ms / 1000)
|
||||||
|
|
||||||
|
@ -23,7 +26,12 @@ async def download_image(session, image_url, file_path):
|
||||||
|
|
||||||
async def main():
|
async def main():
|
||||||
try:
|
try:
|
||||||
async with aiohttp.ClientSession() as session:
|
# Create an SSL context that does not verify certificates
|
||||||
|
ssl_context = ssl.create_default_context()
|
||||||
|
ssl_context.check_hostname = False
|
||||||
|
ssl_context.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
|
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=ssl_context)) as session:
|
||||||
async with session.get(url) as response:
|
async with session.get(url) as response:
|
||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
raise Exception(f"⛔ Failed to fetch JSON file: {response.status}")
|
raise Exception(f"⛔ Failed to fetch JSON file: {response.status}")
|
||||||
|
|
Loading…
Reference in a new issue