python: certificate verified failed

I was just trying to download a file on github (raw) using wget package (or curl) under Python2.7.11 and Windows 7. I got a certificate error as follows:

IOError: [Errno socket error] [ SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590)

As an example, here is the code with a Python shell

import wget
wget.download("https://valid_url_link")

This is not an issue with the tool wget since I got the same message in a windows shell with curl.

After quite a lot of time on stackoverflow and other resources, I finally found a solution on a github page (https://github.com/servo/servo/issues/5917). his may work for other systems so here is the solution that worked for me:

import wget
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
wgte.download("https://valid_url_link")
Please follow and like us:
This entry was posted in Python and tagged , . Bookmark the permalink.

22 Responses to python: certificate verified failed

  1. Pingback: Quicky: If Python and OpenSSL hate each other – 0daylego

  2. Pingback: How to disable SSL verification for urlretrieve? – Peter's blog

Leave a Reply

Your email address will not be published.