53

Here is my Python code:

    import requests
    requests.get('https://google.com')

This is the error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='google.com', port=443):
Max retries exceeded with url: / (Caused by SSLError(SSLError(1, 
'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))

Using Insomnia gives me an error related with certificates:

Error shown in Insomnia

My OS is Windows 7 Professional.

David Medinets
  • 5,160
  • 3
  • 29
  • 42
rayashi
  • 1,721
  • 3
  • 20
  • 28

7 Answers7

95
requests.get('https://google.com', verify='/path/to/certfile')

or you can skip verifications by doing this:

requests.get('https://google.com', verify=False)

You should specify your CA.

Hagai Wild
  • 1,904
  • 11
  • 19
5

If you are running under business network, contact the network administrator to apply required configurations at the network level.

Rola
  • 1,598
  • 13
  • 12
4

This fixed it: Python referencing old SSL version

The openssl versions used to differ for python and the one offered by homebrew

if brew install python --with-brewd-openssl doesn't work try
brew install openssl brew install python
after uninstalling python

user13476428
  • 71
  • 1
  • 1
  • 3
2

You might add header and verify argument to by-pass ssl certificate security.

r = requests.get(URL, headers = {'User-agent': 'your bot 0.1'}, verify=False)

You should specify path your certificate if you have.

HITESH GUPTA
  • 149
  • 4
  • This will, of course, remove the benefits SSL certificates give you, including verification that you are actually talking to the server you think you do, and are not being affected by a man-in-the-middle attack. – Daniel Werner Sep 07 '21 at 22:12
2

In the requests.get you can set the verify flag to False. This way the handshake between the program and the server is going to be ignored.

-- This isn't a guaranteed method because some servers have strict policy to deliver responses to requests.

haddagart
  • 68
  • 1
  • 8
2

If you using proxy server,add proxy to your requests. just like:

proxies = {'http':'http://localhost:port','https':'http://localhost:port'}
requests.get('your_request_website', headers=headers, proxies=proxies)

hope this helps.

liaoyk
  • 21
  • 2
-1

I resolved my problem by installing openssl you can go here and download the Light version or any version suited to your needs: https://slproweb.com/products/Win32OpenSSL.html

helloWORLD
  • 135
  • 5