# Error SSL Certificate Python

**URL:** <https://community.openai.com/t/error-ssl-certificate-python/614041>\
**Category:** API\
**Tags:** api\
**Created:** [February 4, 2024, 6:58pm UTC](https://community.openai.com/t/error-ssl-certificate-python/614041 "2024-02-04T18:58:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![vittoriogrossi87](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/vittoriogrossi87/32/146506_2.png) [@vittoriogrossi87](https://community.openai.com/u/vittoriogrossi87)\
**Post date:** [February 4, 2024, 6:58pm UTC](https://community.openai.com/t/error-ssl-certificate-python/614041/1 "2024-02-04T18:58:04Z")

</div>

Hello, I got this error when I try to lunch my test script in Phyhon on my **Mac os** :

This is the error in my terminal:

File " in \_wrap\_create\_connection  
raise ClientConnectorCertificateError(req.connection\_key, exc) from exc  
aiohttp.client\_exceptions.ClientConnectorCertificateError: Cannot connect to host api. openai. com:443 ssl:True [SSLCertVerificationError: (1, ‘[SSL: CERTIFICATE\_VERIFY\_FAILED] certificate verify failed: unable to get local issuer certificate (\_ssl.c:1000)’)]

_My script try to generate a random username:_

```auto
import aiohttp
import json
import asyncio

async def generate_username_with_chatgpt(prompt, api_key):
    url = "https://api . openai . com/v1/completions" # Verifica che questo sia l'URL corretto
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json",
    }
    payload = {
        "model": "gpt-3.5-turbo", # Assicurati che il modello sia disponibile
        "prompt": prompt,
        "max_tokens": 60,
        "n": 1,
        "stop": None,
        "temperature": 0.5,
    }

    async with aiohttp.ClientSession() as session:
        async with session.post(url, headers=headers, data=json.dumps(payload)) as response:
            if response.status == 200:
                resp_json = await response.json()
                username = resp_json['choices'][0]['text'].strip()
                return username
            else:
                print(f"Errore nella richiesta API: {response.status}")
                return None

async def main():
    api_key = ' *********' # Sostituisci con il tuo vero API key
    prompt = ('Genera un nome utente che include una combinazione casuale di lettere e numeri, '
              'con una parola specifica seguita da un numero casuale, e che sia lungo complessivamente '
              'tra 8 e 12 caratteri.')

    username = await generate_username_with_chatgpt(prompt, api_key)
    print(f"Nome utente generato: {username}")

if __name__ == " __main__":
    asyncio.run(main())

```

I don’t know why

---

<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:** [February 4, 2024, 8:06pm UTC](https://community.openai.com/t/error-ssl-certificate-python/614041/3 "2024-02-04T20:06:08Z")

</div>

> [@vittoriogrossi87](#):
>
> ` url = "https://api . openai . com/v1/completions" # Verifica che questo sia l'URL corretto`

Maybe the spaces in the domain name?
