2

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?

Danny Cullen
  • 1,782
  • 5
  • 30
  • 47
  • 1
    It might be that your proxy is doing SSL interception. It might also be that the setup of the site causes problems. It might also be that you are using a very old version of requests with an old certificate store. Unfortunately it is impossible to tell with the information you provide what went wrong, because essentially you are only telling that you are using some unknown version of requests with some unknown proxy accessing some unknown site. Apart from that it is uncommon that you have different proxy setting for http and https and that a https proxy is running on port 443 etc. – Steffen Ullrich Jul 22 '16 at 10:21
  • I have added in the versions, it is the latest version. It could be that the proxy is doing some interception like you mentioned. – Danny Cullen Jul 22 '16 at 10:32
  • 1
    I've decided it must be the proxy, which is using SSL inspection. – Danny Cullen Jul 22 '16 at 11:17

1 Answers1

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

Change this line and it will work.

Melody
  • 182
  • 2
  • 12