簡體   English   中英

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

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

我正在嘗試使用 elasticsearch package 連接到 elasticsearch 服務器,但出現此錯誤

  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))

有什么想法可以解決問題嗎?

檢查您的 openssl 版本

openssl version

或來自 python

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

這兩個命令都需要 output 類似: LibreSSL 2.8.3

為了與這個客戶端連接,您可能會在他們的文檔中使用類似的東西:

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

正如您在示例下方的評論中看到的那樣,您可以在Urllib3HttpConnection上設置一些您自己的設置

See class Urllib3HttpConnection for detailed description of the options.

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

在那里你會看到 ssl 版本的設置

ssl_version – 要使用的 SSL 協議的版本。 選項包括: SSLv23(默認) SSLv2 SSLv3 TLSv1(請參閱 ssl 模塊中的 PROTOCOL_ 常量以了解確切信息

嘗試更改此設置,看看是否有幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM