allow unsafe ssl context for downloads

Signed-off-by: vladmandic <mandic00@live.com>
This commit is contained in:
vladmandic
2026-01-19 17:36:01 +01:00
parent ae357a5e49
commit 8cf27dffdb
7 changed files with 38 additions and 17 deletions
+4 -1
View File
@@ -274,13 +274,16 @@ def load_civitai(model: str, url: str):
def download_url_to_file(url: str, dst: str):
# based on torch.hub.download_url_to_file
import ssl
import uuid
import tempfile
from urllib.request import urlopen, Request
from rich.progress import Progress, TextColumn, BarColumn, TaskProgressColumn, TimeRemainingColumn, TimeElapsedColumn
file_size = None
req = Request(url, headers={"User-Agent": "sdnext"})
u = urlopen(req) # pylint: disable=R1732
context = ssl._create_unverified_context() # pylint: disable=protected-access
u = urlopen(req, context=context) # pylint: disable=R1732
meta = u.info()
if hasattr(meta, 'getheaders'):
content_length = meta.getheaders("Content-Length")
+7 -1
View File
@@ -105,7 +105,6 @@ def set_prompt(p,
prompts, negative_prompts, prompts_2, negative_prompts_2 = fix_prompt_batch(p, prompts, negative_prompts, prompts_2, negative_prompts_2)
prompts, negative_prompts, prompts_2, negative_prompts_2 = fix_prompt_model(cls, prompts, negative_prompts, prompts_2, negative_prompts_2)
args = set_fallback_prompt(args, possible, prompts=None, negative_prompts=None, prompts_2=prompts_2, negative_prompts_2=negative_prompts_2) # we dont parse secondary prompts
if prompt_parser_diffusers.embedder is not None:
if 'prompt' in possible:
@@ -127,6 +126,8 @@ def set_prompt(p,
else:
if 'prompt_embeds' in possible:
args['prompt_embeds'] = prompt_embeds
else:
args = set_fallback_prompt(args, possible, prompts=prompts, negative_prompts=None, prompts_2=None, negative_prompts_2=None)
if 'pooled_prompt_embeds' in possible:
args['pooled_prompt_embeds'] = prompt_pooled_embeds
if 'StableCascade' in cls:
@@ -156,6 +157,8 @@ def set_prompt(p,
else:
if 'negative_prompt_embeds' in possible:
args['negative_prompt_embeds'] = negative_embeds
else:
args = set_fallback_prompt(args, possible, prompts=None, negative_prompts=negative_prompts, prompts_2=None, negative_prompts_2=None)
if 'negative_pooled_prompt_embeds' in possible:
args['negative_pooled_prompt_embeds'] = negative_pooled_embeds
if 'StableCascade' in cls:
@@ -170,6 +173,9 @@ def set_prompt(p,
args = set_fallback_prompt(args, possible, prompts=prompts, negative_prompts=negative_prompts, prompts_2=None, negative_prompts_2=None)
prompt_attention = 'fixed'
if 'prompt_embeds' not in args and 'negative_prompt_embeds' not in args: # pass secondary prompts as-in
args = set_fallback_prompt(args, possible, prompts=None, negative_prompts=None, prompts_2=prompts_2, negative_prompts_2=negative_prompts_2)
if (prompt_parser_diffusers.embedder is not None) and (not prompt_parser_diffusers.embedder.scheduled_prompt):
prompt_parser_diffusers.embedder = None # not scheduled so we dont need it anymore
+3 -1
View File
@@ -252,10 +252,12 @@ def update_extension(extension_path, search_text, sort_column):
def refresh_extensions_list(search_text, sort_column):
global extensions_list # pylint: disable=global-statement
import ssl
import urllib.request
try:
shared.log.debug(f'Updating extensions list: url={extensions_index}')
with urllib.request.urlopen(extensions_index, timeout=3.0) as response:
context = ssl._create_unverified_context() # pylint: disable=protected-access
with urllib.request.urlopen(extensions_index, timeout=3.0, context=context) as response:
text = response.read()
extensions_list = json.loads(text)
with open(os.path.join(paths.script_path, "html", "extensions.json"), "w", encoding="utf-8") as outfile:
+18 -8
View File
@@ -1,5 +1,6 @@
import os
import sys
import ssl
import site
import ctypes
import shutil
@@ -84,14 +85,23 @@ def install():
args.use_nightly = True
if args.use_nightly:
platform = "nightly-" + platform
urllib.request.urlretrieve(f'https://github.com/lshqqytiger/ZLUDA/releases/download/rel.{commit}/ZLUDA-{platform}-rocm{rocm.version[0]}-amd64.zip', '_zluda')
with zipfile.ZipFile('_zluda', 'r') as archive:
infos = archive.infolist()
for info in infos:
if not info.is_dir():
info.filename = os.path.basename(info.filename)
archive.extract(info, path)
os.remove('_zluda')
log.debug(f'Install ZLUDA: rocm={rocm.version} platform={platform} commit={commit}')
ssl._create_default_https_context = ssl._create_unverified_context # pylint: disable=protected-access
try:
urllib.request.urlretrieve(f'https://github.com/lshqqytiger/ZLUDA/releases/download/rel.{commit}/ZLUDA-{platform}-rocm{rocm.version[0]}-amd64.zip', '_zluda')
if not os.path.exists('_zluda'):
raise RuntimeError('ZLUDA download failed')
with zipfile.ZipFile('_zluda', 'r') as archive:
infos = archive.infolist()
for info in infos:
if not info.is_dir():
info.filename = os.path.basename(info.filename)
archive.extract(info, path)
except Exception as e:
raise RuntimeError(f'Install ZLUDA: {e}') from e
finally:
if os.path.exists('_zluda'):
os.remove('_zluda')
def uninstall():