allow unsafe ssl context for downloads

Signed-off-by: vladmandic <[email protected]>
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
+1
View File
@@ -78,6 +78,7 @@ For full list of changes, see full changelog.
- disable fallback on models with custom loaders
- refactor triggering of prompt parser and set secondary prompts when needed
- refactor handling of seeds
- allow unsafe ssl context for downloads
- **Fixes**
- extension tab: update checker, date handling, formatting etc., thanks @awsr
- controlnet with non-english ui locales
-1
View File
@@ -40,7 +40,6 @@ def download_urllib(args):
fn = ''
req = urllib.request.Request(args.url, headers=headers)
res = urllib.request.urlopen(req)
res.getheader('content-length')
content_length = int(res.getheader('content-length') or 0)
fn = get_filename(args, res)
print(f'downloading: url={args.url} file={fn} size={content_length if content_length > 0 else "unknown"} lib=urllib block={args.block}')
+5 -5
View File
@@ -781,20 +781,20 @@ def install_rocm_zluda():
zluda_installer.install()
zluda_installer.set_default_agent(device)
except Exception as e:
log.warning(f'Failed to install ZLUDA: {e}')
log.error(f'Install ZLUDA: {e}')
try:
zluda_installer.load()
except Exception as e:
log.warning(f'Failed to load ZLUDA: {e}')
log.error(f'Load ZLUDA: {e}')
else: # TODO rocm: switch to pytorch source when it becomes available
if device is None:
log.warning('No ROCm agent was found. Please make sure that graphics driver is installed and up to date.')
log.error('ROCm: no agent found - make sure that graphics driver is installed and up to date')
if isinstance(rocm.environment, rocm.PythonPackageEnvironment):
check_python(supported_minors=[11, 12, 13], reason='ROCm backend requires a Python version between 3.11 and 3.13')
check_python(supported_minors=[11, 12, 13], reason='ROCm: python==3.11/3.12/3.13 required')
torch_command = os.environ.get('TORCH_COMMAND', f'torch torchvision --index-url https://rocm.nightlies.amd.com/{device.therock}')
else:
check_python(supported_minors=[12], reason='ROCm Windows preview requires Python version 3.12')
check_python(supported_minors=[12], reason='ROCm: Windows preview python==3.12 required')
torch_command = os.environ.get('TORCH_COMMAND', '--no-cache-dir https://repo.radeon.com/rocm/windows/rocm-rel-6.4.4/torch-2.8.0a0%2Bgitfc14c65-cp312-cp312-win_amd64.whl https://repo.radeon.com/rocm/windows/rocm-rel-6.4.4/torchvision-0.24.0a0%2Bc85f008-cp312-cp312-win_amd64.whl')
else:
#check_python(supported_minors=[10, 11, 12, 13, 14], reason='ROCm backend requires a Python version between 3.10 and 3.13')
+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():