requests.exceptions.Sslerror: Certificate Verify failed

Asked

Viewed 2,424 times

1

I’m having a big problem with Django requests. In the last few months I upgraded to version 2.0 of Django, and I’m updating all libs.

I noticed that this impacted several scripts that I had, mainly those that talk with https. For example, my Pushnotification stopped working, my script that downloads images from social networks stopped working and everything. For all these errors I get the following error message:

requests.exceptions.SSLError: HTTPSConnectionPool(host='yt3.ggpht.com', port=443): Max retries exceeded with url: /a-/XXXXXXXXXXXXXXXXXXj-k-no (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))

Follow my version of requests:

requests==2.18.4

In this particular example, it’s me trying to download an avatar from Youtube.

EDIT

Follow an excerpt from the code. I tried to use the verify=False but did not help, outside that is not recommended, the very Warning warns..

from django.core.files.base import ContentFile
import requests

response = requests.get('https://yt3.ggpht.com/-Tn306TYaqpw/AAAAAAAAAAI/AAAAAAAAHOw/XsdeQ5H6Bds/s176-nd-c-c0xffffffff-rj-k-no/photo.jpg', verify=False)
yt_avatar = ContentFile(response.content)

Trying with the verify=False the error return is different but means the same thing..

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)

1 answer

0

One way to try to circumvent errors linked to HTTPS within lib requests is to use the parameter verify and save its value as False.

As in the example of documentation:

>>> requests.get('https://kennethreitz.org', verify=False)
<Response [200]>

If this doesn’t solve your problem, please post a chunk of code that allows the community to test locally and thus identify the best solution.

  • So I took the test and I only get a Warning saying it’s not recommended. But it doesn’t work, the return is different but it’s the same meaning...

  • What is your version of python? If it is 2.x, take a look here.

  • My mole is 3.x

Browser other questions tagged

You are not signed in. Login or sign up in order to post.