PHP SSL CERTIFICATE_VERIFY_FAILED Error

A user reported that a certain PHP script stopped working on the server. The error messages are:

Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 65, in get
    return request('get', url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/api.py", line 49, in request
    response = session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 461, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 573, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 431, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:726)

The error is from the requests module. I first tried to upgrade the requests module to the latest version. It fixed this particular problem. However, one other module does not work with the latest version of requests module. I had to uninstall the latest version of requests and install the same old version (2.5) that was installed before. Here are the commands that I used to reinstall requests.

pip uninstall requests
pip install 'requests>=2.5.0,<2.5.1' --force-reinstall


This post may contain affiliated links. When you click on the link and purchase a product, we receive a small commision to keep us running. Thanks.


Be the first to comment

Leave a Reply