Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error During Generate: Certificate Verify Failed #5

Closed
don1138 opened this issue Sep 11, 2022 · 14 comments
Closed

Error During Generate: Certificate Verify Failed #5

don1138 opened this issue Sep 11, 2022 · 14 comments
Labels
macOS installation error stale The issue has not been updated in a while, and is likely outdated

Comments

@don1138
Copy link

don1138 commented Sep 11, 2022

Add-on, Application and OS versions

Dream Textures 0.0.3
Blender 3.3
Mac OS 10.15.7

Describe the bug

When generating a texture, two certificate issues caused it to fail.

1.) future: <Task finished name='Task-1' coro=<DreamTexture.dream_texture() done, defined at /Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/__init__.py:448> exception=URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)'))>

2.) urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>

and perhaps related, no current event loop was found.

How to Reproduce

On Mac with same specs, generate new texture.

Error message

Full event log:

>> cuda not available, using device cpu
Global seed set to 27427138
>> Loading model from /Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/models/ldm/stable-diffusion-v1/model.ckpt
LatentDiffusion: Running in eps-prediction mode
DiffusionWrapper has 859.52 M params.
making attention of type 'vanilla' with 512 in_channels
Working with z of shape (1, 4, 32, 32) = 4096 dimensions.
making attention of type 'vanilla' with 512 in_channels
Downloading: "https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/checkpoint_liberty_with_aug.pth" to /Users/***/.cache/torch/hub/checkpoints/checkpoint_liberty_with_aug.pth
Task exception was never retrieved
future: <Task finished name='Task-1' coro=<DreamTexture.dream_texture() done, defined at /Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/__init__.py:448> exception=URLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)'))>
Traceback (most recent call last):
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 1348, in do_open
    h.request(req.get_method(), req.selector, req.data, headers,
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/http/client.py", line 975, in send
    self.connect()
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/http/client.py", line 1454, in connect
    self.sock = self._context.wrap_socket(self.sock,
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/ssl.py", line 512, in wrap_socket
    return self.sslsocket_class._create(
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/ssl.py", line 1070, in _create
    self.do_handshake()
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/ssl.py", line 1341, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/__init__.py", line 493, in dream_texture
    t2i.load_model()
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/simplet2i.py", line 592, in load_model
    model = self._load_model_from_config(config, self.weights)
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/simplet2i.py", line 664, in _load_model_from_config
    model = instantiate_from_config(config.model)
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/util.py", line 89, in instantiate_from_config
    return get_obj_from_str(config['target'])(
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/models/diffusion/ddpm.py", line 657, in __init__
    self.instantiate_cond_stage(cond_stage_config)
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/models/diffusion/ddpm.py", line 768, in instantiate_cond_stage
    model = instantiate_from_config(config)
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/util.py", line 89, in instantiate_from_config
    return get_obj_from_str(config['target'])(
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/util.py", line 99, in get_obj_from_str
    return getattr(importlib.import_module(module, package=None), cls)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/stable_diffusion/ldm/modules/encoders/modules.py", line 7, in <module>
    import kornia
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/__init__.py", line 10, in <module>
    from . import (
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/augmentation/__init__.py", line 43, in <module>
    from .container import AugmentationSequential, ImageSequential, PatchSequential, VideoSequential
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/augmentation/container/__init__.py", line 1, in <module>
    from .augment import AugmentationSequential
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/augmentation/container/augment.py", line 17, in <module>
    from .patch import PatchSequential
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/augmentation/container/patch.py", line 9, in <module>
    from kornia.contrib.extract_patches import extract_tensor_patches
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/contrib/__init__.py", line 4, in <module>
    from .image_stitching import ImageStitcher
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/contrib/image_stitching.py", line 7, in <module>
    from kornia.feature import LocalFeatureMatcher, LoFTR
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/feature/__init__.py", line 4, in <module>
    from .integrated import (
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/feature/integrated.py", line 52, in <module>
    class LAFDescriptor(nn.Module):
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/feature/integrated.py", line 65, in LAFDescriptor
    patch_descriptor_module: nn.Module = HardNet(True),
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/kornia/feature/hardnet.py", line 66, in __init__
    pretrained_dict = torch.hub.load_state_dict_from_url(
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/torch/hub.py", line 727, in load_state_dict_from_url
    download_url_to_file(url, cached_file, hash_prefix, progress=progress)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/site-packages/torch/hub.py", line 593, in download_url_to_file
    u = urlopen(req)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 519, in open
    response = self._open(req, data)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 536, in _open
    result = self._call_chain(self.handle_open, protocol, protocol +
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 496, in _call_chain
    result = func(*args)
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 1391, in https_open
    return self.do_open(http.client.HTTPSConnection, req,
  File "/Applications/Blender.app/Contents/Resources/3.3/python/lib/python3.10/urllib/request.py", line 1351, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)>
/Users/***/Library/Application Support/Blender/3.3/scripts/addons/dream_textures/async_loop.py:62: DeprecationWarning: There is no current event loop
  loop = asyncio.get_event_loop()

Screenshots

n/a

@carson-katri
Copy link
Owner

With a normal Python install there is a InstallCertificates.command file you can run to setup the certificates, but I don’t think blenders Python will have this. So maybe you can try this answer from SO: https://stackoverflow.com/a/61142526 Using Blender’s Python though. If that works for you, I will add that script to the addon.

@davidrwilliamson
Copy link

I have the same issue in Blender 3.3 on Ubuntu 20.04.5 LTS.

That SO script did not work, because the OpenSSL directory it looks for does not exist. ssl.get_default_verify_paths() returns DefaultVerifyPaths(cafile=None, capath=None, openssl_cafile_env='SSL_CERT_FILE', openssl_cafile='/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/ssl/cert.pem', openssl_capath_env='SSL_CERT_DIR', openssl_capath='/home/sybren/buildbot-builder/linux_glibc217_x86_64_cmake/build_deps/deps/Release/ssl/certs').

Sybren is a Blender developer so I suppose this is a Blender bug where their OpenSSL path has found its way in when compiling Python.

@felipejoribeiro
Copy link

I'm having the same problem. I tried to create the file structure but macOS doesn't allow me. Even with sudo su. It responds with. mkdir: sybren: Operation not supported.

@Teralink
Copy link

Dream Textures 0.0.5 was released 3 days ago. The release notes say 'fixes an error with macOS installation'. Does it solve the problem of this thread? Or is it something else?

@carson-katri
Copy link
Owner

@Teralink It attempted to fix a different error with CLIP model downloading. I do not know of a solution for this yet.

@YAFU
Copy link

YAFU commented Sep 21, 2022

I have the same issue in Blender 3.3 on Ubuntu 20.04.5 LTS.

From here:
Rapptz/discord.py#5968 (comment)

After installing those packages you should run Blender from the same terminal where you executed the line "export SSL_CERT_DIR=/etc/ssl/certs"

SSL certificate error is gone, but now I get an error related to:

File "/media/TEMP/@Blender_Buildboot/blender/3.4/python/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1768, in from_pretrained
raise EnvironmentError(
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.
/media/TEMP/@Blender_Buildboot/blender/3.4/scripts/addons/dream-textures/async_loop.py:62: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop

@carson-katri
Copy link
Owner

@YAFU good find. You should be able to run the script in the dream textures addon directory dream_textures/stable_diffusion/scripts/preload_models.py to download those.

@YAFU
Copy link

YAFU commented Sep 21, 2022

@carson-katri I'm not sure what to do, just run preload_models.py?
I get the following:
https://pastebin.com/UxDjZ6Hq

I have Python 3.10 installed on my system now.

BTW, I am using addon dependencies installed from addon "install dependencies" button now (dependencies installed in /blender/3.4/python/ of master/buildbot 3.4 portable folder). For now I have abandoned trying the method of installing dependencies on the system.

@diramazioni
Copy link

@YAFU SSL_CERT_DIR=/etc/ssl/certs does work thanks!
Just run "Install dependencies" again from the addon preferences and you are set

@davidrwilliamson
Copy link

I have the same issue in Blender 3.3 on Ubuntu 20.04.5 LTS.

From here: Rapptz/discord.py#5968 (comment)

After installing those packages you should run Blender from the same terminal where you executed the line "export SSL_CERT_DIR=/etc/ssl/certs"

SSL certificate error is gone, but now I get an error related to:

File "/media/TEMP/@Blender_Buildboot/blender/3.4/python/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 1768, in from_pretrained
raise EnvironmentError(
OSError: Can't load tokenizer for 'openai/clip-vit-large-patch14'. If you were trying to load it from 'https://huggingface.co/models', make sure you don't have a local directory with the same name. Otherwise, make sure 'openai/clip-vit-large-patch14' is the correct path to a directory containing all relevant files for a CLIPTokenizer tokenizer.
/media/TEMP/@Blender_Buildboot/blender/3.4/scripts/addons/dream-textures/async_loop.py:62: DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop

@YAFU good find. You should be able to run the script in the dream textures addon directory dream_textures/stable_diffusion/scripts/preload_models.py to download those.

These steps fixed the issue for me.

@civviGH
Copy link

civviGH commented Sep 27, 2022

@YAFU SSL_CERT_DIR=/etc/ssl/certs does work thanks! Just run "Install dependencies" again from the addon preferences and you are set

im on ubuntu 18.04, this fixed the exact same issue for me too. i also ran "install dependencies" from the preference window again and everything worked as expected.
thank you for the good find.

@Alzy
Copy link

Alzy commented Mar 14, 2023

I found the fix for this in another thread. Use the certifi module which is bundled with Blender as @john-shine proposed here. This example uses aiohttp but should lead you in the right direction even if you're using a different module.

import ssl
import certifi

sslcontext = ssl.create_default_context(cafile=certifi.where())
with aiohttp.Timeout(10):
        ......
        async with session.get(url, ssl=sslcontext) as response:
            ......

@github-actions
Copy link

This issue is stale because it has been open for 60 days with no activity.

@github-actions github-actions bot added the stale The issue has not been updated in a while, and is likely outdated label May 19, 2023
@github-actions
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
macOS installation error stale The issue has not been updated in a while, and is likely outdated
Projects
None yet
Development

No branches or pull requests

9 participants