[GH-ISSUE #413] SSL certificate error when downloading model weights #352

Open
opened 2026-10-31 21:14:17 +00:00 by bsakaguchi · 1 comment
Owner

Originally created by @linminhtoo on GitHub (Dec 22, 2023).
Original GitHub issue: https://github.com/openai/CLIP/issues/413

I'm getting the below error when downloading model weights

URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)>

Specifically I'm calling CLIP via llama-index and this is the full stack trace:
https://gist.github.com/linminhtoo/b613ffc916e5e96329169e8b4601eff5

Any ideas? I'm on Mac and I could download other pretrained weights from HuggingFace etc without issues

Originally created by @linminhtoo on GitHub (Dec 22, 2023). Original GitHub issue: https://github.com/openai/CLIP/issues/413 I'm getting the below error when downloading model weights ``` URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1006)> ``` Specifically I'm calling CLIP via llama-index and this is the full stack trace: https://gist.github.com/linminhtoo/b613ffc916e5e96329169e8b4601eff5 Any ideas? I'm on Mac and I could download other pretrained weights from HuggingFace etc without issues
Author
Owner

@zyqhnu commented on GitHub (Feb 20, 2024):

In file /Path/to/your/virtualenvs/envs/inpainting/lib/python3.8/site-packages/clip/clip.py temporarily modify the following lines:

with urllib.request.urlopen(url) as source, open(download_target, "wb") as output:

to

import ssl 
context = ssl._create_unverified_context()
with urllib.request.urlopen(url, context=context) as source, open(download_target, "wb") as output:

Cool, that works.
Because the 'clip' is installed from source code, I changed the source code /clip/clip.py@line59 before I install it

<!-- gh-comment-id:1954015273 --> @zyqhnu commented on GitHub (Feb 20, 2024): > In file `/Path/to/your/virtualenvs/envs/inpainting/lib/python3.8/site-packages/clip/clip.py` temporarily modify the following lines: > > ```python > with urllib.request.urlopen(url) as source, open(download_target, "wb") as output: > ``` > > to > > ```python > import ssl > context = ssl._create_unverified_context() > with urllib.request.urlopen(url, context=context) as source, open(download_target, "wb") as output: > ``` Cool, that works. Because the 'clip' is installed from source code, I changed the source code [/clip/clip.py@line59](https://github.com/openai/CLIP/blob/a1d071733d7111c9c014f024669f959182114e33/clip/clip.py#L59) before I install it
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
openai/CLIP#352
No description provided.