How the python 2.6.8 to connect the Elasticsearch?

The python version is 2.6.8 that ssl has not create_default_context.

how can i skip the ssl or another method to tansport the ssl certificates besides above

Python 2 sunset date was 1/1/2020, not that it still won't work, but if I were doing new development, I'd use Python 3.

Did you do any imports?

Here is my sample code, I don't recall any differences between Python 2 and 3 in this section.

from elasticsearch import *
from elasticsearch_dsl import *
from ssl import create_default_context
import getpass
context = create_default_context(cafile="es_ca.cer")
pw = getpass.getpass(prompt='Password for elastic stack')

# Get data from ES
es = Elasticsearch(["https://elastic.dns:9200"],http_auth=("user", pw), ssl_context=context)
aliases = es.indices.get_alias("*")

Thank you for your reply, the problem is fixed.

But meet another error as following:
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/client/", line 84, in _wrapped
return func(*args, params=params, **kwargs)
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/client/", line 510, in get_alias
"GET", _make_path(index, "_alias", name), params=params
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/", line 358, in perform_request
File "/opt/anaconda2/envs/py2/lib/python2.7/site-packages/elasticsearch/connection/", line 254, in perform_request
raise ConnectionError("N/A", str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(check_hostname requires server_hostname) caused by: ValueError(check_hostname requires server_hostname)

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