I tried the following code:-
# connect to ES on localhost on port 9200
from ssl import create_default_context
import ssl
# from elasticsearch.connection import create_ssl_context
es = Elasticsearch([{'host': '34.133.230.90', 'port': 9200,'scheme':'https'}],basic_auth=('username', 'password'),
verify_certs=False, ssl_show_warn=True)
if es.ping():
print('Connected to ES!')
else:
print('Could not connect!')
# sys.exit()
print("*********************************************************************************");
Output is:-
Could not connect!
*********************************************************************************
Another Code ---
# connect to ES on localhost on port 9200
from ssl import create_default_context
import ssl
# from elasticsearch.connection import create_ssl_context
es = Elasticsearch([{'host': '34.133.230.90', 'port': 9200,'scheme':'https'}],basic_auth=('username', 'password'),
use_ssl=True,verify_certs=False, ssl_show_warn=True)
if es.ping():
print('Connected to ES!')
else:
print('Could not connect!')
# sys.exit()
print("*********************************************************************************");
Output -
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-28-2ef570288f0b> in <module>
5
6 es = Elasticsearch([{'host': '34.133.230.90', 'port': 9200,'scheme':'https'}],basic_auth=('username', 'password'),
----> 7 use_ssl=True,verify_certs=False, ssl_show_warn=True)
8
9 if es.ping():
TypeError: __init__() got an unexpected keyword argument 'use_ssl'
Adding CA_path"-
# connect to ES on localhost on port 9200
from ssl import create_default_context
import ssl
# from elasticsearch.connection import create_ssl_context
es = Elasticsearch([{'host': '34.133.230.90', 'port': 9200,'scheme':'https'}],basic_auth=('username', 'password'),
verify_certs=False, ssl_show_warn=True,ca_certs='/path/to/CA_certs')
if es.ping():
print('Connected to ES!')
else:
print('Could not connect!')
# sys.exit()
print("*********************************************************************************");
output:-
Could not connect!
*********************************************************************************