0

I've been using the code based on the snipped below for several months and it worked.

import requests

resp = requests.get(
        'https://api.loganalytics.io',
        # verify=False
)

Now I have an error:

File "C:....virtualenvs\pythonProject-XaZ9hdp4\lib\site-packages\requests\adapters.py", line 563, in send raise SSLError(e, request=request) requests.exceptions.SSLError: HTTPSConnectionPool(host='api.loganalytics.io', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:997)')))

I checked SSL certificate for api.loganalytics.io with third-party online service and it looks like everything is OK with its SSL certificate.

I created new Python project and re-install requests and certifi in new virtual environment.

What kind of another certificate can be meant in this error message? How can I find and update it? I work under Windows 10.

Diggy
  • 115
  • 8
  • The issue was resolved with solution from here: https://stackoverflow.com/questions/64224608/verify-ssl-certificate-with-requests?rq=1 – Diggy Jan 04 '23 at 14:45

1 Answers1

0
import requests 

resp = requests.get( 

        'https://api.loganalytics.io', 

        # verify=False 

) 

In this code we need change Verify = false to verify=ssl.CERT_NONE

import requests 
   
resp = requests.get( 

        'https://api.loganalytics.io', 

         verify=ssl.CERT_NONE 

) 

if you have any ssl certificate you can use this

s = requests.Session() 

s.cert = '/path/client.cert'
Naveen Sharma
  • 349
  • 2
  • 4
  • Thank you for your answer. It's commented # verify=False just to show I know about this possibility. Of course, in that case it works. But I need to understand what kind of SSL certificate I need and where should I place it to fix the issue? I do not want to modify my Python code. I need correct place to put correct SSL certificate or env variable. – Diggy Dec 29 '22 at 17:50
  • Depends on the priority we can chose different types of ssl certificates please refer below doc: https://serverguy.com/ssl/types-of-ssl-certificates/ – Naveen Sharma Jan 03 '23 at 08:54