requests.exceptions.SSLError: [SSL: CERTIFICATE_VE

2019-02-26 10:00发布

I cannot request a popular SSL site without geting the error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed.

The requests documentation states that

By default Requests bundles a set of root CAs that it trusts, sourced from the Mozilla trust store. However, these are only updated once for each Requests version. This means that if you pin a Requests version your certificates can become extremely out of date.

As this is a popular site it should be in the store when I use verify=True, however it keeps failing. I have also tried with other SSL addresses and it also fails with this error.

import requests

headers = {
    'User-agent': 'Mozilla/5.0'
}

proxies = {
    'http' : 'http://1.2.3.4:80',
    'https' : 'http://1.2.3.4:443'
}

r = requests.get('https://www.example.com', proxies=proxies, verify=True)

Note that https://www.example.com is a popular UK news website, so it should be in the CA store.

Python Version: Python 2.7.11

Requests Version: requests (2.10.0)

OS: Windows 8

Am I doing something fundamentally wrong?

1条回答
ら.Afraid
2楼-- · 2019-02-26 11:04
r = requests.get('https://www.example.com', proxies=proxies, verify=False)

Change this line and it will work.

查看更多
登录 后发表回答