Skip to content

Commit 8c087a9

Browse files
DownloadManager: make certificates explicit
1 parent eca3a08 commit 8c087a9

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

internal_filesystem/lib/mpos/net/download_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ async def _download_url_async(cls, url, outfile=None, total_size=None,
105105
print("DownloadManager: aiohttp not available")
106106
raise ImportError("aiohttp module not available")
107107

108+
import ssl
109+
sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
110+
sslctx.verify_mode = ssl.CERT_OPTIONAL # CERT_REQUIRED might fail because MBEDTLS_ERR_SSL_CA_CHAIN_REQUIRED
108111
session = aiohttp.ClientSession()
109112
print("DownloadManager: Created new aiohttp session")
110113
print(f"DownloadManager: Downloading {url}")
@@ -115,7 +118,7 @@ async def _download_url_async(cls, url, outfile=None, total_size=None,
115118
if headers is None:
116119
headers = {}
117120

118-
async with session.get(url, headers=headers) as response:
121+
async with session.get(url, headers=headers, ssl=sslctx) as response:
119122
if response.status < 200 or response.status >= 400:
120123
print(f"DownloadManager: HTTP error {response.status}")
121124
raise RuntimeError(f"HTTP {response.status}")

0 commit comments

Comments
 (0)