[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain

Greeting, I am trying to connect to the OpenAI api from python. but have failed. I have searched the openAI api documentations and openAI dev forums. My openAI version is 1.14.3. I cannot use lower version to use assistant model

import os
from openai import OpenAI
OPENAI_API_KEY = 'my-key'

os.environ['PYTHONHTTPSVERIFY'] = '0'
os.environ['REQUESTS_CA_BUNDLE'] = 'C:\MyProgram\python\certificate.crt'

client = OpenAI(api_key = OPENAI_API_KEY)

and I got the following error

File "C:\Users\Username\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpx\_transports\default.py", line 86, in map_httpcore_exceptions
    raise mapped_exc(message) from exc
httpx.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)

and

File "C:\Users\Username\AppData\Local\Programs\Python\Python312\Lib\site-packages\httpcore\_exceptions.py", line 14, in map_exceptions
    raise to_exc(exc) from exc
httpcore.ConnectError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1000)

I have tried the below solutions

  1. as shown above, I have downloaded certificate from https://api.openai.com/ manually and gave my cert to os. environ followed by hardkothari1988`s answer but not worked. I have set os.environ[‘PYTHONHTTPSVERIFY’] = ‘0’ to disable HTTPS verify but not worked either
os.environ['PYTHONHTTPSVERIFY'] = '0'
os.environ['REQUESTS_CA_BUNDLE'] = 'C:\MyProgram\python\certificate.crt'
  1. used pip install pip_system_certs to install certs in python itself. but not worked

  2. have used

import certifi
certifi.where()

not worked

  1. have tried

    1. Open api_requestor.py in a text editor. (site-packages/openai/api_requestor.py)
    2. Find the line: s = requests.Session()
    3. Add directly below: s.verify = False

but there was no api_requestory.py exists in current open api version.
Instead I have explored Python312\Lib\site-packages\httpx_transports\default.py
which makes error, and switched its verify flag but not worked

  1. set openai.verify_ssl_certs = false but not worked

and I have checked connection with open ai using Open Port Check Tool - Test Port Forwarding on Your Router
with openAI`s ip: 104.18.7.192 with 443 port it is opend

Yesterday I have used legacy openAI and worked well. In legacy version, there is no assistant model connection is provied so I have to use recent one. is anyone knows the solution?