SSL Certificate issue - suggestions if you are facing this issue

Hi, I had that SSL certificate error, like so many others here, when using OpenAI module and requests. Tried so many methods including adding certificate at the end of certifi\cacert.pem, installing certificates, uninstalling/re-installing/updating certifi, using httpx, etc.

One common suggestions everywhere was to use this:
response = requests.post(url, headers=headers, data=json.dumps(data), verify=True, cert = “path\to\certificate.cer”)

I tried this and did so many other things. Nothing worked. Then I tried this, and it worked for me:
response = requests.post(url, headers=headers, data=json.dumps(data), verify=“path\to\certificate.cer”)

Checked it again & again and only verify=“path\to\certificate.cer” works.

If you read the developer notes on requests/httpx, it says:

  • verify - (optional) SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either True (default CA bundle), a path to an SSL certificate file, an ssl.SSLContext, or False (which will disable verification).
  • cert - (optional) An SSL certificate used by the requested host to authenticate the client. Either a path to an SSL certificate file, or two-tuple of (certificate file, key file), or a three-tuple of (certificate file, key file, password).

Since the issue is to verify the host (and not the client), SSL certificate needs to be passed to “verify” and not “cert”