Open
Description
Elasticsearch version (bin/elasticsearch --version
): 8.x
elasticsearch-py
version (elasticsearch.__versionstr__
): 8.6.1
Please make sure the major version matches the Elasticsearch server you are running.
Description of the problem including expected versus actual behavior:
According to https://www.elastic.co/guide/en/elasticsearch/client/python-api/current/config.html#_using_an_sslcontext
we should be able to omit the verify_certs
parameter in the client constructor if we correctly setup an ssl context object.
Steps to reproduce:
- Start a local Elasticsearch cluster with SSL enabled and a self-signed certificate
- Execute this reproduction script
from elasticsearch import Elasticsearch
import ssl
import certifi
ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH, cafile=certifi.where())
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
# works, setting verify_certs means we don't verify the certificate
es = Elasticsearch(
hosts=["https://localhost:9200"],
ssl_context=ssl_context,
verify_certs=False,
basic_auth=("elastic", "changeme"),
)
print(es.info())
# fails, even though the SSL context object's verify_mode is set to NONE it still attempts to verify the certificate
es = Elasticsearch(
hosts=["https://localhost:9200"],
ssl_context=ssl_context,
basic_auth=("elastic", "changeme"),
)
print(es.info())