close

[Solved] certificate verify failed: unable to get local issuer certificate

To Solve certificate verify failed: unable to get local issuer certificate error You need to either install certifi or update certifi will resolve this error.

How certificate verify failed: unable to get local issuer certificate Error Occurs?

I am just trying to use the request package but I am facing the following error.

requests.exceptions.SSLError:

HTTPSConnectionPool(host='www.xxxxxx.com', port=443):

Max retries exceeded with url: xxxxxxxx (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED]

certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)')))

Solution 1: Add the certificates in cacert.pem

  1. First of all Find the path where cacert.pem is located
  2. Just use certifi.where() and it will give you full path.
  3. Then Open the URL on a browser. Download the chain of certificates from the URL and save as Base64 encoded .cer files
  4. Now you have to open the cacert.pem in a notepad and just add every downloaded certificate contents (---Begin Certificate--- *** ---End Certificate---) at the end.

Solution 2: update the Certificate using pip

You just need to update the Certificate using pip. Just use this command.

pip install --upgrade certifi

Solution 3: Install Python certifi

Open Your terminal OR Cmd and Just run this command.

python3 -m pip install certifi

#OR
pip3 install certifi

#OR
python -m pip install certifi

Hope Now, your error might be solved

Frequently Asked Questions

  1. How To Solve certificate verify failed: unable to get local issuer certificate Error ?

    To Solve certificate verify failed: unable to get local issuer certificate Error First of all Find the path where cacert.pem is located Just use certifi.where() and it will give you full path. Then Open the URL on a browser. Download the chain of certificates from the URL and save as Base64 encoded .cer files Now you have to open the cacert.pem in a notepad and just add every downloaded certificate contents (—Begin Certificate— *** —End Certificate—) at the end.

  2. certificate verify failed: unable to get local issuer certificate

    To Solve certificate verify failed: unable to get local issuer certificate Error First of all Find the path where cacert.pem is located Just use certifi.where() and it will give you full path. Then Open the URL on a browser. Download the chain of certificates from the URL and save as Base64 encoded .cer files Now you have to open the cacert.pem in a notepad and just add every downloaded certificate contents (—Begin Certificate— *** —End Certificate—) at the end.

Summary

Just installing certifi or upgrading certifi will resolve this error. Comment below which solution worked for you. Thanks.

Also, Read

Leave a Comment