self.host="KibanaProxy"
self.Port="443"
self.user="test"
self.password="test"
I need to suppress certificate validation. It works with curl when using option -k
on command line. But while connecting using elasticsearch.Elasticsearch from Elasticsearch python module, it throws error.
_es2 = Elasticsearch([self.host], port=self.port, scheme="https", http_auth=(self.user, self.password), use_ssl=True, verify_certs=False)
_es2.info()
Error:
raise SSLError('N/A', str(e), e)
elasticsearch.exceptions.SSLError: ConnectionError([SSL: CERTIFICATE_VERIFY_FAILED]
certificate verify failed (_ssl.c:590)) caused by: SSLError([SSL:
CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:590))```
Found it. While reading this post https://github.com/elastic/elasticsearch-py/issues/275, i got to know about connection_class. Looked for some standard or predefined method related to it so found https://elasticsearch-py.readthedocs.io/en/master/transports.html
Solution:
from elasticsearch import RequestsHttpConnection
.....
_es2 = Elasticsearch([self.host], port=self.port, connection_class=RequestsHttpConnection, http_auth=(self.user, self.password), use_ssl=True, verify_certs=False)
print(es.ping())
$ ./sn.py
True
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With