SSL Certificate Error when Grabbing Pinecone Index

vectorstore = Pinecone.from_existing_index(index_name, embedding=get_embedding_function())

I get the following error when I run the above code. I am not sure what SSL Cert to sign. I have also upgraded any certi libraries.

During handling of the above exception, another exception occurred:

MaxRetryError                             Traceback (most recent call last)
Cell In[5], line 109
    106 index_name = "production"
    107 # retriever = Chroma.from_documents(bancworks_docs, get_embedding_function(), persist_directory="./storage/chroma_db")
    108 # vectorstore = Chroma(embedding_function = get_embedding_function(), persist_directory=f"./storage/{version}")
--> 109 vectorstore = Pinecone.from_existing_index(index_name, embedding=get_embedding_function())
    111 # retriever = load_parent_retriever("storage/deploy/pinecone-docs", "test")
    112 
    113 # UNCOMMENT THIS
    114 retriever = load_parent_retriever(f"storage/{index_name}/kv", "test")

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain_community\vectorstores\pinecone.py:456, in Pinecone.from_existing_index(cls, index_name, embedding, text_key, namespace, pool_threads)
    446 @classmethod
    447 def from_existing_index(
    448     cls,
   (...)
    453     pool_threads: int = 4,
    454 ) -> Pinecone:
    455     """Load pinecone vectorstore from index name."""
--> 456     pinecone_index = cls.get_pinecone_index(index_name, pool_threads)
    457     return cls(pinecone_index, embedding, text_key, namespace)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\langchain_community\vectorstores\pinecone.py:365, in Pinecone.get_pinecone_index(cls, index_name, pool_threads)
    361 if _is_pinecone_v3():
    362     pinecone_instance = pinecone.Pinecone(
    363         api_key=os.environ.get("PINECONE_API_KEY"), pool_threads=pool_threads
    364     )
--> 365     indexes = pinecone_instance.list_indexes()
    366     index_names = [i.name for i in indexes.index_list["indexes"]]
    367 else:

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\control\pinecone.py:298, in Pinecone.list_indexes(self)
    254 def list_indexes(self) -> IndexList:
    255     """Lists all indexes.
    256     
    257     The results include a description of all indexes in your project, including the 
   (...)
    296 
    297     """
--> 298     response = self.index_api.list_indexes()
    299     return IndexList(response)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\api_client.py:772, in Endpoint.__call__(self, *args, **kwargs)
    761 def __call__(self, *args, **kwargs):
    762     """ This method is invoked when endpoints are called
    763     Example:
    764 
   (...)
    770 
    771     """
--> 772     return self.callable(self, *args, **kwargs)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\api\manage_indexes_api.py:1100, in ManageIndexesApi.__init__.<locals>.__list_indexes(self, **kwargs)
   1096 kwargs['_check_return_type'] = kwargs.get(
   1097     '_check_return_type', True
   1098 )
   1099 kwargs['_host_index'] = kwargs.get('_host_index')
-> 1100 return self.call_with_http_info(**kwargs)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\api_client.py:834, in Endpoint.call_with_http_info(self, **kwargs)
    830     header_list = self.api_client.select_header_content_type(
    831         content_type_headers_list)
    832     params['header']['Content-Type'] = header_list
--> 834 return self.api_client.call_api(
    835     self.settings['endpoint_path'], self.settings['http_method'],
    836     params['path'],
    837     params['query'],
    838     params['header'],
    839     body=params['body'],
    840     post_params=params['form'],
    841     files=params['file'],
    842     response_type=self.settings['response_type'],
    843     auth_settings=self.settings['auth'],
    844     async_req=kwargs['async_req'],
    845     _check_type=kwargs['_check_return_type'],
    846     _return_http_data_only=kwargs['_return_http_data_only'],
    847     _preload_content=kwargs['_preload_content'],
    848     _request_timeout=kwargs['_request_timeout'],
    849     _host=_host,
    850     collection_formats=params['collection_format'])

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\api_client.py:409, in ApiClient.call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, async_req, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type)
    355 """Makes the HTTP request (synchronous) and returns deserialized data.
    356 
    357 To make an async_req request, set the async_req parameter.
   (...)
    406     then the method will return the response directly.
    407 """
    408 if not async_req:
--> 409     return self.__call_api(resource_path, method,
    410                            path_params, query_params, header_params,
    411                            body, post_params, files,
    412                            response_type, auth_settings,
    413                            _return_http_data_only, collection_formats,
    414                            _preload_content, _request_timeout, _host,
    415                            _check_type)
    417 return self.pool.apply_async(self.__call_api, (resource_path,
    418                                                method, path_params,
    419                                                query_params,
   (...)
    427                                                _request_timeout,
    428                                                _host, _check_type))

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\api_client.py:196, in ApiClient.__call_api(self, resource_path, method, path_params, query_params, header_params, body, post_params, files, response_type, auth_settings, _return_http_data_only, collection_formats, _preload_content, _request_timeout, _host, _check_type)
    192     url = _host + resource_path
    194 try:
    195     # perform request and return response
--> 196     response_data = self.request(
    197         method, url, query_params=query_params, headers=header_params,
    198         post_params=post_params, body=body,
    199         _preload_content=_preload_content,
    200         _request_timeout=_request_timeout)
    201 except PineconeApiException as e:
    202     e.body = e.body.decode('utf-8')

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\api_client.py:435, in ApiClient.request(self, method, url, query_params, headers, post_params, body, _preload_content, _request_timeout)
    433 """Makes the HTTP request using RESTClient."""
    434 if method == "GET":
--> 435     return self.rest_client.GET(url,
    436                                 query_params=query_params,
    437                                 _preload_content=_preload_content,
    438                                 _request_timeout=_request_timeout,
    439                                 headers=headers)
    440 elif method == "HEAD":
    441     return self.rest_client.HEAD(url,
    442                                  query_params=query_params,
    443                                  _preload_content=_preload_content,
    444                                  _request_timeout=_request_timeout,
    445                                  headers=headers)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\rest.py:267, in RESTClientObject.GET(self, url, headers, query_params, _preload_content, _request_timeout)
    265 def GET(self, url, headers=None, query_params=None, _preload_content=True,
    266         _request_timeout=None):
--> 267     return self.request("GET", url,
    268                         headers=headers,
    269                         _preload_content=_preload_content,
    270                         _request_timeout=_request_timeout,
    271                         query_params=query_params)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\pinecone\core\client\rest.py:224, in RESTClientObject.request(self, method, url, query_params, headers, body, post_params, _preload_content, _request_timeout)
    221             raise PineconeApiException(status=0, reason=msg)
    222     # For `GET`, `HEAD`
    223     else:
--> 224         r = self.pool_manager.request(method, url,
    225                                       fields=query_params,
    226                                       preload_content=_preload_content,
    227                                       timeout=timeout,
    228                                       headers=headers)
    229 except urllib3.exceptions.SSLError as e:
    230     msg = "{0}\n{1}".format(type(e).__name__, str(e))

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\request.py:77, in RequestMethods.request(self, method, url, fields, headers, **urlopen_kw)
     74 urlopen_kw["request_url"] = url
     76 if method in self._encode_url_methods:
---> 77     return self.request_encode_url(
     78         method, url, fields=fields, headers=headers, **urlopen_kw
     79     )
     80 else:
     81     return self.request_encode_body(
     82         method, url, fields=fields, headers=headers, **urlopen_kw
     83     )

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\request.py:99, in RequestMethods.request_encode_url(self, method, url, fields, headers, **urlopen_kw)
     96 if fields:
     97     url += "?" + urlencode(fields)
---> 99 return self.urlopen(method, url, **extra_kw)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\poolmanager.py:376, in PoolManager.urlopen(self, method, url, redirect, **kw)
    374     response = conn.urlopen(method, url, **kw)
    375 else:
--> 376     response = conn.urlopen(method, u.request_uri, **kw)
    378 redirect_location = redirect and response.get_redirect_location()
    379 if not redirect_location:

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py:827, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    822 if not conn:
    823     # Try again
    824     log.warning(
    825         "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    826     )
--> 827     return self.urlopen(
    828         method,
    829         url,
    830         body,
    831         headers,
    832         retries,
    833         redirect,
    834         assert_same_host,
    835         timeout=timeout,
    836         pool_timeout=pool_timeout,
    837         release_conn=release_conn,
    838         chunked=chunked,
    839         body_pos=body_pos,
    840         **response_kw
    841     )
    843 # Handle redirect?
    844 redirect_location = redirect and response.get_redirect_location()

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py:827, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    822 if not conn:
    823     # Try again
    824     log.warning(
    825         "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    826     )
--> 827     return self.urlopen(
    828         method,
    829         url,
    830         body,
    831         headers,
    832         retries,
    833         redirect,
    834         assert_same_host,
    835         timeout=timeout,
    836         pool_timeout=pool_timeout,
    837         release_conn=release_conn,
    838         chunked=chunked,
    839         body_pos=body_pos,
    840         **response_kw
    841     )
    843 # Handle redirect?
    844 redirect_location = redirect and response.get_redirect_location()

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py:827, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    822 if not conn:
    823     # Try again
    824     log.warning(
    825         "Retrying (%r) after connection broken by '%r': %s", retries, err, url
    826     )
--> 827     return self.urlopen(
    828         method,
    829         url,
    830         body,
    831         headers,
    832         retries,
    833         redirect,
    834         assert_same_host,
    835         timeout=timeout,
    836         pool_timeout=pool_timeout,
    837         release_conn=release_conn,
    838         chunked=chunked,
    839         body_pos=body_pos,
    840         **response_kw
    841     )
    843 # Handle redirect?
    844 redirect_location = redirect and response.get_redirect_location()

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\connectionpool.py:799, in HTTPConnectionPool.urlopen(self, method, url, body, headers, retries, redirect, assert_same_host, timeout, pool_timeout, release_conn, chunked, body_pos, **response_kw)
    796 elif isinstance(e, (SocketError, HTTPException)):
    797     e = ProtocolError("Connection aborted.", e)
--> 799 retries = retries.increment(
    800     method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
    801 )
    802 retries.sleep()
    804 # Keep track of the error for the retry warning.

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\urllib3\util\retry.py:592, in Retry.increment(self, method, url, response, error, _pool, _stacktrace)
    581 new_retry = self.new(
    582     total=total,
    583     connect=connect,
   (...)
    588     history=history,
    589 )
    591 if new_retry.is_exhausted():
--> 592     raise MaxRetryError(_pool, url, error or ResponseError(cause))
    594 log.debug("Incremented Retry for (url='%s'): %r", url, new_retry)
    596 return new_retry

MaxRetryError: HTTPSConnectionPool(host='api.pinecone.io', port=443): Max retries exceeded with url: /indexes (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1002)')))

Hi @jonsnguyening, you may be using a deprecated version of the PineconeVectorStore package offered by LangChain. Please see the LangChain documentation and API Reference for further details.

To connect to an existing Pinecone index using the LangChain package, you’ll want to run the following code:

from langchain_pinecone import PineconeVectorStore

index_name = "<YOUR_INDEX_NAME>"

vectorstore = PineconeVectorStore(index_name=index_name, embedding=embeddings)

You can view an example in Adding More Text to an Existing Index in the LangChain documentation.