簡體   English   中英

Elasticsearch:安裝防護罩后無法使用python連接

[英]Elasticsearch : Cannot connect using python when shield is installed

我正在使用Elasticsearch 2.3.1和python 2.7。 我正在嘗試創建一個簡單的實例並進行測試

esInstance = Elasticsearch(['https://'+shield_uname+":"+shield_pass+"@"+server+":"+port])

print esInstance.info()

但我明白了

elasticsearch.exceptions.SSLError: ConnectionError(EOF occurred in violation of protocol (_ssl.c:590)) caused by: SSLError(EOF occurred in violation of protocol (_ssl.c:590))

我究竟做錯了什么 ? 我嘗試時遇到相同的錯誤

requests.get("https://"+shield_uname+":"+shield_pass+"@"+server+":"+port, verify=False)

我怎樣才能解決這個問題?

我認為最好將字段作為參數傳遞 ,因為已經將它們作為單獨的變量了。

這是身份驗證示例的“最完整”版本,其中插入了變量:

# SSL client authentication using client_cert and client_key

es = Elasticsearch(
    [server],
    http_auth=(shield_uname, shield_pass),
    port=port,
    use_ssl=True,
    verify_certs=True,
    ca_certs='/path/to/cacert.pem',
    client_cert='/path/to/client_cert.pem',
    client_key='/path/to/client_key.pem',
)

請注意port全部處理SSL之后的參數。 如果您實際使用的是證書,則需要確保已將其告知Python。 如果您使用的是標准證書,則可以使用上面鏈接中所示的certifi

暫無
暫無

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

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