Create Python elasticsearch connection

Hi
I'm using python client:Python Elasticsearch Client — Elasticsearch 8.0.0 documentation to initiate API calls to my ES hosted behind AWS API gateway.
Can i use the SDK to talk to my ES stack if mTLS has been enabled?
I tried connecting using the snippet below but it failed:

es = Elasticsearch(
    url,
    client_cert=cert,
    client_key=key,
    verify_certs=False,
    headers={"x-api-key":  "mykey"}
)

My API gateway will require:
client cert,client key and x-api-key

I can confirm that initiating the below curl works perfectly:
curl -X GET '{host}:443/_cluster/health?pretty' --header "x-api-key: {}" --cert /home/ec2-user/{}.cer --key /home/ec2-user/{}.pem

Welcome to our community! :smiley:

You might be able to do this with Connection Layer API — Elasticsearch 8.0.0 documentation, but it's not something I have done myself.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.