SSLCertVerificationError - HTTPSConnectionPool(host='api.pinecone.io', port=443): Max retries exceeded with url: /indexes/

I’ve been using my company’s noteboook and changed it for another one. Before the change, the code was running properly, when i tried running the script again with the new notebook I got this error:

urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘api.pinecone.io’, port=443): Max retries exceeded with url: /indexes/langchain-doc-index (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1010)’)))

INDEX_NAME = "langchain-doc-index"

def run_llm(query: str, chat_history: List[Dict[str, Any]] = []):
    embeddings = AzureOpenAIEmbeddings(
        model=os.getenv("AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME"),
        azure_endpoint=os.getenv("AZURE_OPENAI_EMBEDDINGS_ENDPOINT"),
        api_key=os.getenv("AZURE_OPENAI_EMBEDDINGS_API_KEY"),
        api_version=os.getenv("AZURE_OPENAI_EMBEDDINGS_API_VERSION"),
    )
    doc_search = PineconeVectorStore(index_name=INDEX_NAME, embedding=embeddings)
    chat = AzureChatOpenAI(
        azure_deployment=os.getenv("AZURE_OPENAI_CHAT_DEPLOYMENT_NAME"),
        azure_endpoint=os.getenv("AZURE_OPENAI_CHAT_ENDPOINT"),
        api_key=os.getenv("AZURE_OPENAI_CHAT_API_KEY"),
        api_version=os.getenv("AZURE_OPENAI_CHAT_API_VERSION")
    )

    retrieval_qa_chat_prompt = hub.pull("langchain-ai/retrieval-qa-chat")
    stuff_documents_chain = create_stuff_documents_chain(chat, retrieval_qa_chat_prompt)

    rephrase_prompt = hub.pull("langchain-ai/chat-langchain-rephrase")
    history_aware_retriever = create_history_aware_retriever(
        llm=chat, retriever=doc_search.as_retriever(), prompt=rephrase_prompt
    )

    qa = create_retrieval_chain(
        retriever=history_aware_retriever, combine_docs_chain=stuff_documents_chain
    )
    result = qa.invoke(input={"input": query, "chat_history": chat_history})
    return result

Any ideas what is going on?

Hi @gabriel.faria,

This sounds like it could be an outdated system trust store on the new machine. I’d suggest ensuring you have the latest OS patches and try again. If that doesn’t help, then you may need to look into the version of python you’re using to see where it’s resolving its trust store from and update as needed.

Hope this helps!

Silas

1 Like

Hey, Silas! Thank you for the support!

I managed the problem by installing the certifi package and bringing it to my script like this:

import os, certifi
os.environ["SSL_CERT_FILE"] = certifi.where()

I don’t think this is the best way but the code works again. I’ll try contacting IT to verify it better.

Thanks again for the response!

1 Like