I am trying to create a graphql client using python_graphql_client
package.
My graphQL endpoint is an https link.
But when i try to run a query, I get this error:
exc: HTTPSConnectionPool(host='<graphql endpoint>', port=443): Max retries exceeded with url: /graphql (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1131)')))
Here is my code snippet:
def Init( self, GRAPHQL_SERVER_ENDPOINT):
rv = False
error = ""
# Instantiate the client with an endpoint.
try:
header = { f"{self.xAPIKeyName}" : f"{self.xAPIKey}" }
self.gqlClient = GraphqlClient(endpoint=GRAPHQL_SERVER_ENDPOINT, verify=False, headers=header) #os.environ["SETI_GRAPHQL_SERVER_ENDPOINT"])
if(self.gqlClient != None):
rv = True
except Exception as e:
logger.critical("EXCEPTION connecting to GraphQL endpoint="+os.environ["GRAPHQL_SERVER_ENDPOINT"]+"; exc: "+str(e))
error="EXCEPTION connecting to GraphQL endpoint="+os.environ["GRAPHQL_SERVER_ENDPOINT"]+"; exc: "+str(e)
if( rv==False ):
self.Trace("eq_stats.Init() FAILED: "+error)
return rv
def ExecuteQuery( self, query):
rv = None
error = "UNKNOWN"
try:
response = self.gqlClient.execute(query=query)
rv = response["data"]
error = ""
except Exception as e:
logger.critical(f"ExecuteQuery EXCEPTION, query: {query}, exc: {str(e)}")
error=f"ExecuteQuery EXCEPTION, query: {query}, exc: {str(e)}"
if( rv==None ):
error=f"ExecuteQuery ERROR, query: {query}, exc: {error}"
self.Trace(error)
return rv, error
.....
.....
eqti, err = eqs.ExecuteQuery( equipmentTypeInfoQuery % (swArchitecture) )
if (err!=""):
logger.critical(f"EquipmentTypeInfo Query FAILED: {err}")
For now I have just added verify=False
. But I know it should not be done.
I have a certificate but not sure how to use it.
Need someone's help!!
Thanks in advance