I am attempting to access some data from a website through python, but after my first attempt:

requests.get('https://website.com')

I was met with the following error:

HTTPSConnectionPool(host='www.website.com', port=443): Max retries exceeded with url: /file.php (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1129)')))

I switched to a wget command to test (wget website.com), and ran into a similar error message:

ERROR: cannot verify cruzit.com's certificate, issued by ‘CN=AlphaSSL CA - SHA256 - G4,O=GlobalSign nv-sa,C=BE’: Unable to locally verify the issuer's authority. To connect to cruzit.com insecurely, use `--no-check-certificate'.

After doing some research, I found that my issue could be solved by simply including the public SSL certificate that the site was using. I went to the site in my web browser and downloaded the public certificate. After testing it out with wget once again (wget --ca-certificate=certificate.crt https://website.com), the command was successful.

I implemented this change in my code:

requests.get('https://website.com', verify='/path/to/cert')

Despite the changes, I was getting the same error.

Note: I did use verify=False and --no-check-certificate for requests.get() and wget respectively, which did work. I do not want to implement this, as it is not secure.

0

There are 0 best solutions below