Why Do Https Requests Produce Ssl Certificate_Verify_Failed Error?

Why Do Https Requests Produce Ssl Certificate_Verify_Failed Error?

Here is my Python code:

    import requests
    requests.get(')

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:

My OS is Windows 7 Professional.

3

6 Answers

requests.get(' verify='/path/to/certfile')

or you can skip verifications by doing this:

requests.get(' verify=False)

You should specify your CA.

7

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

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

1

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.

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.

1

I resolved my problem by installing openssl you can go here and download the Light version or any version suited to your needs:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Robert Thorne
Author

Robert Thorne

Robert Thorne covers electric vehicle innovations, autonomous driving systems, global mobility trends, and automotive engineering developments.