Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
govindarajan_d
Super User
Super User

SSL Verification failed when trying to use OpenAI library

I am using an Azure OpenAI model with Python notebook in Fabric. 

 

 

client = openai.AzureOpenAI( 
  api_key=AZURE_OPENAI_API_KEY, 
  azure_endpoint=AZURE_OPENAI_ENDPOINT, 
  api_version=API_VERSION
) 

response = client.chat.completions.create() 

 

 

 

 

The above code when run throws SSL issue, although if I try it in local environment it works fine. 

 

The error that appears is: 

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1006)
  

I tried the following installations to make sure SSL certificates are:

pip install -U openai
pip install pip-system-certs
pip install --upgrade certifi

 

 

 

1 ACCEPTED SOLUTION
nilendraFabric
Super User
Super User

Hello @govindarajan_d 

 

give it a try

 

import httpx

client = openai.AzureOpenAI(
api_key=AZURE_OPENAI_API_KEY,
azure_endpoint=AZURE_OPENAI_ENDPOINT,
api_version=API_VERSION,
http_client=httpx.Client(verify="/path/to/your/custom_certificate.pem")
)

 

not recommended for prod, but lets see if this works

View solution in original post

5 REPLIES 5
PPuente
New Member

Also works with 

  http_client=httpx.AsyncClient
nilendraFabric
Super User
Super User

Hello @govindarajan_d 

 

give it a try

 

import httpx

client = openai.AzureOpenAI(
api_key=AZURE_OPENAI_API_KEY,
azure_endpoint=AZURE_OPENAI_ENDPOINT,
api_version=API_VERSION,
http_client=httpx.Client(verify="/path/to/your/custom_certificate.pem")
)

 

not recommended for prod, but lets see if this works

Hi @nilendraFabric,

 

The code worked, I pointed it to the existing certificate. 

        client = openai.AzureOpenAI(
            api_key=AZURE_OPENAI_API_KEY,
            azure_endpoint=AZURE_OPENAI_ENDPOINT,
            api_version=API_VERSION,
            http_client=httpx.Client(verify="/etc/ssl/certs/ca-certificates.crt"),
        )

 

But why doesn't it work normally when other libraries like requests work without issues? Also, for production what would you suggest?

Great it worked @govindarajan_d 

 

I would suggest store pem in Key vault and then use it here. 

or store it in a place where it cant be accessed unauthorised. 
it often contains sensitive information such as private keys, which must be protected from unauthorized access.

 

if this is helpful please accept the solution 

@nilendraFabric We are not using custom key for certificate signing. Actually the above certificate is something that comes default with the spark environment (linux). I just pointed the http client to that certificate. 

 

I am just wondering why it doesn't cause issue with requests library when I am hitting HTTPS sites. Strange though!

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Fabric Update Carousel

Fabric Monthly Update - September 2025

Check out the September 2025 Fabric update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.