pythonsslrequestcertificate

Why do HTTPS requests produce SSL CERTIFICATE_VERIFY_FAILED error?


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.


Solution

  • 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.