taraslayshchuk / es2csv

Export from an Elasticsearch into a CSV file
Apache License 2.0
511 stars 190 forks source link

Remove SSL warnings when not veryfing certs #43

Open maaaaz opened 6 years ago

maaaaz commented 6 years ago

Hello @taraslayshchuk,

By default, certs are not verified and a lot of warnings are displayed and spam the console.

Could you just print at the beginning of the execution a simple warning like "[!] certs are not verified, use --verify-certs instead" and disable original warnings with the directive like urllib3.disable_warnings()

Cheers !

nwhobart commented 6 years ago

@maaaaz I had a similar problem and sudo pip install certifi.

ikonst commented 6 years ago

Since the library is using urllib3, the main workaround is to use pyopenssl when available.

To do this, add this to the beginning of the code:

try:
  import urllib3.contrib.pyopenssl
  urllib3.contrib.pyopenssl.inject_into_urllib3()
except ImportError:
  pass

This will allow interested parties to pip install urllib3[secure] in addition to es2csv and ensure they can validate certificates.

See https://urllib3.readthedocs.io/en/latest/user-guide.html#certificate-verification-in-python-2