I found the solution.
import certifi # pip install certifi
DGRAPH_ALPHA_SERVER = os.getenv('DGRAPH_ALPHA_SERVER') or 'localhost:9080'
def create_client_stub():
with open(certifi.where(), "rb") as f:
root_ca_cert = f.read()
creds = grpc.ssl_channel_credentials(root_certificates=root_ca_cert)
return pydgraph.DgraphClientStub(addr=DGRAPH_ALPHA_SERVER, credentials=creds)