requests.exceptions.SSLError: certificate verify failed

1

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

I noticed that this impacted on a number of scripts I had, mostly those that talk to https. For example, my PushNotification has stopped working, my script that downloads social media images has 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')],)",),))

Here is my version of requests:

requests==2.18.4

In this specific example, I'm trying to download an Youtube avatar.

EDIT

Here's a snippet of code. I tried to use verify=False but it did not work, otherwise it is not recommended, the warning itself 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 verify=False , the error return is different but it means the same thing ..

ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)
    
asked by anonymous 30.05.2018 / 17:51

1 answer

0

One way to try to work around HTTPS-bound errors within lib requests is to use the verify parameter and save its value as False .

As in the example documentation :

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

If this does not solve your problem, please post a snippet of code that will allow the community to test locally and thus identify the best solution.

    
30.05.2018 / 18:21