简体   繁体   中英

python elasticsearch elasticsearch.exceptions.SSLError: ConnectionError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056))

I'm trying to connect to an elasticsearch server using the elasticsearch package, but getting this error

  File "/Users/xxx/.local/share/virtualenvs/backend-J1KVvbjz/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 152, in _wrapped
    return func(*args, params=params, headers=headers, **kwargs)
  File "/Users/xxx/.local/share/virtualenvs/backend-J1KVvbjz/lib/python3.7/site-packages/elasticsearch/client/indices.py", line 331, in exists
    "HEAD", _make_path(index), params=params, headers=headers
  File "/Users/xxx/.local/share/virtualenvs/backend-J1KVvbjz/lib/python3.7/site-packages/elasticsearch/transport.py", line 390, in perform_request
    raise e
  File "/Users/xxx/.local/share/virtualenvs/backend-J1KVvbjz/lib/python3.7/site-packages/elasticsearch/transport.py", line 365, in perform_request
    timeout=timeout,
  File "/Users/xxx/.local/share/virtualenvs/backend-J1KVvbjz/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 255, in perform_request
    raise SSLError("N/A", str(e), e)
elasticsearch.exceptions.SSLError: ConnectionError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)) caused by: SSLError([SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056))

Any ideas what could be fixing the problem?

Check your's openssl version

run

openssl version

or from python

python -c "import ssl; print(ssl.OPENSSL_VERSION)"

Both commands need to output something like: LibreSSL 2.8.3

For connecting with this client you probably use something like in their docs:

https://elasticsearch-py.readthedocs.io/en/7.10.0/#ssl-and-authentication

and as you can see at the comment bellow the example you can set some of your own settings on Urllib3HttpConnection

See class Urllib3HttpConnection for detailed description of the options.

https://elasticsearch-py.readthedocs.io/en/7.10.0/connection.html#elasticsearch.Urllib3HttpConnection

There you will see the setting of ssl version

ssl_version – version of the SSL protocol to use. Choices are: SSLv23 (default) SSLv2 SSLv3 TLSv1 (see PROTOCOL_ constants in the ssl module for exact

Try to change this setting and see if it help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM