# SSL: certificate\_verify\_failed

**URL:** <https://community.openai.com/t/ssl-certificate-verify-failed/32442>\
**Category:** API\
**Created:** [January 9, 2023, 4:20pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442 "2023-01-09T16:20:01Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 4:20pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/1 "2023-01-09T16:20:02Z")

</div>

Hello,

I am trying to connect to the OpenAI api from python, a simple test, but I am not succeeding as I always get the same error:

_MaxRetryError: HTTPSConnectionPool(host=‘[api.openai.com](http://api.openai.com)’, port=443): Max retries exceeded with url: /v1/engines/text-davinci-001/completions (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE\_VERIFY\_FAILED] certificate verify failed: unable to get local issuer certificate (\_ssl.c:1129)’)))_

I have tried to force it to ignore the certificate verification but I can’t, and I don’t know how to make it point to a correct certificate either.

Anyone knows how I can solve this?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 9, 2023, 4:30pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/2 "2023-01-09T16:30:22Z")

</div>

Welcome to the community.

Can you share the code you’re using with us? Are you hitting the API more than once in quick succession?

ETA: This might help, but we don’t know your OS and other details…

> **[Python API SDK SSL: CERTIFICATE\_VERIFY\_FAILED Error](https://community.smartsheet.com/discussion/94918/python-api-sdk-ssl-certificate-verify-failed-error)**
>
> I am running into this error trying to connect smartsheet api via python sdk and getting this error on a mac book pro: smartsheet.exceptions.HttpError:

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 4:44pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/3 "2023-01-09T16:44:07Z")

</div>

Of course. This is a simple example that I copied from one of the tutorials.

import pandas as pd  
import openai  
import certifi  
certifi.where()  
import requests

openai.api\_key = ‘MY\_API\_KEY’

response = openai.Completion.create(  
model=“text-davinci-003”,  
prompt=“I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with "Unknown".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:”,  
temperature=0,  
max\_tokens=100,  
top\_p=1,  
frequency\_penalty=0.0,  
presence\_penalty=0.0,  
stop=[“\n”]  
)

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 4:45pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/4 "2023-01-09T16:45:16Z")

</div>

Of course. This is a simple example that I copied from one of the tutorials.

```auto
import pandas as pd
import openai
import certifi
certifi.where()
import requests

openai.api_key = 'MY_API_KEY'

response = openai.Completion.create(
  model="text-davinci-003",
  prompt="I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:",
  temperature=0,
  max_tokens=100,
  top_p=1,
  frequency_penalty=0.0,
  presence_penalty=0.0,
  stop=["\n"]
)

```

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 4:47pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/5 "2023-01-09T16:47:28Z")

</div>

Of course. This is a simple example that I copied from one of the tutorials. I am working on Windows 10.

```auto
import pandas as pd
import openai
import certifi
certifi.where()
import requests

openai.api_key = 'MY_API_KEY'

response = openai.Completion.create(
  model="text-davinci-003",
  prompt="I am a highly intelligent question answering bot. If you ask me a question that is rooted in truth, I will give you the answer. If you ask me a question that is nonsense, trickery, or has no clear answer, I will respond with \"Unknown\".\n\nQ: What is human life expectancy in the United States?\nA: Human life expectancy in the United States is 78 years.\n\nQ: Who was president of the United States in 1955?\nA: Dwight D. Eisenhower was president of the United States in 1955.\n\nQ: Which party did he belong to?\nA: He belonged to the Republican Party.\n\nQ: What is the square root of banana?\nA: Unknown\n\nQ: How does a telescope work?\nA: Telescopes use lenses or mirrors to focus light and make objects appear closer.\n\nQ: Where were the 1992 Olympics held?\nA: The 1992 Olympics were held in Barcelona, Spain.\n\nQ: How many squigs are in a bonk?\nA: Unknown\n\nQ: Where is the Valley of Kings?\nA:",
  temperature=0,
  max_tokens=100,
  top_p=1,
  frequency_penalty=0.0,
  presence_penalty=0.0,
  stop=["\n"]
)

```

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 9, 2023, 4:54pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/6 "2023-01-09T16:54:33Z")

</div>

Hrm. All packages up to date?

Can you hit the API from the command line?

There’s been problems with text-davinci-003 the last few days as shown on the status page. Might be a temporary SSL cert problem on their end.

Does your code work with another model?

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 5:14pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/7 "2023-01-09T17:14:41Z")

</div>

Does not work with any model :S  
Always the same error…

I updated all the packages.

Could it have to do with the fact that I am working with a portable version of Python (WinPython)?

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 9, 2023, 5:36pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/8 "2023-01-09T17:36:12Z")

</div>

> [@aporelpan](#):
>
> /v1/engines/text-davinci-001/completions

That’s your problem, I believe…

`post https://api.openai.com/v1/completions`

Then send it a model parameter with a current model.

What version of openai package do you have?

[https://beta.openai.com/docs/api-reference/completions/create](https://beta.openai.com/docs/api-reference/completions/create)

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 5:49pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/9 "2023-01-09T17:49:11Z")

</div>

Version 0.25.0

I’m going to try to do what you said…

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 5:58pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/10 "2023-01-09T17:58:12Z")

</div>

A new error from command line…

 ![image](https://us1.discourse-cdn.com/openai1/original/3X/3/7/37757e38d6a82e1e68250b88a959ab3bfc5419c2.png)

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 9, 2023, 5:58pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/11 "2023-01-09T17:58:16Z")

</div>

> [@aporelpan](#):
>
> 0.25.0

Yeah, looks like 0.26.0 is current… Released: Jan 6, 2023

> **[openai](https://pypi.org/project/openai/)**
>
> The official Python library for the openai API

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 9, 2023, 5:59pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/12 "2023-01-09T17:59:21Z")

</div>

Is Playground working for you? Is your key valid?

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 6:07pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/13 "2023-01-09T18:07:55Z")

</div>

I just upgraded to version 0.26.0 and I get the same error…

I have tested Playground and it works correctly :S

![image](https://us1.discourse-cdn.com/openai1/original/3X/6/6/663f9a8008f32aa274bcfe8731ac98a314c52525.png)

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 6:12pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/14 "2023-01-09T18:12:40Z")

</div>

I can’t connect to the API, not even with the simple example in the download documentation…

 ![image](https://us1.discourse-cdn.com/openai1/original/3X/9/5/95af1514d243b04d2c9da42ab2013fbb209edd0f.png)

---

<div class="post-metadata">

**Author:** ![PaulBellow](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/paulbellow/32/597962_2.png) [@PaulBellow](https://community.openai.com/u/PaulBellow)\
**Post date:** [January 9, 2023, 6:19pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/15 "2023-01-09T18:19:31Z")

</div>

Going back to the original problem, I’m wondering if this is it…

> <https://stackoverflow.com/questions/42098126/mac-osx-python-ssl-sslerror-ssl-certificate-verify-failed-certificate-verify>

You’re not MacOSX, but maybe something similar is happening with your OS…

Sorry I couldn’t be of more help. Just trying to help you troubleshoot.

---

<div class="post-metadata">

**Author:** ![freelancer.nak](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/freelancer.nak/32/17934_2.png) [@freelancer.nak](https://community.openai.com/u/freelancer.nak)\
**Post date:** [January 9, 2023, 6:25pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/16 "2023-01-09T18:25:21Z")

</div>

@aporelpan Hope you will be fine.

You need to enable tls, tls1 and tls2 before requesting resources here is the C# snippet

`System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;`

If still any queries please ask. Thanks

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 6:34pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/17 "2023-01-09T18:34:22Z")

</div>

Thanks for all the help. I will keep trying!

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 9, 2023, 6:35pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/18 "2023-01-09T18:35:15Z")

</div>

Hi @freelancer.nak , I am not the administrator of my computer. As soon as I get it enabled I will let you know if it has worked.

Thanks!

---

<div class="post-metadata">

**Author:** ![aporelpan](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aporelpan/32/17802_2.png) [@aporelpan](https://community.openai.com/u/aporelpan)\
**Post date:** [January 10, 2023, 6:06pm UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/19 "2023-01-10T18:06:58Z")

</div>

Solved. I had to get the certificates from [www.api.openai.com](http://www.api.openai.com), copy them, and paste them into the Python cacert.pem file.

@PaulBellow, @freelancer.nak, thank you very much for the help.

---

<div class="post-metadata">

**Author:** ![mashish2509](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/mashish2509/32/17028_2.png) [@mashish2509](https://community.openai.com/u/mashish2509)\
**Post date:** [January 18, 2023, 8:19am UTC](https://community.openai.com/t/ssl-certificate-verify-failed/32442/20 "2023-01-18T08:19:32Z")

</div>

Hi … the link you shared to get certificates is not working.

[Next page](https://community.openai.com/t/ssl-certificate-verify-failed/32442.md?page=2)
