简体   繁体   中英

Elasticsearch : Cannot connect using python when shield is installed

I am using elasticsearch 2.3.1 and python 2.7. I am trying to create a simple instance and testing as

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

print esInstance.info()

but i get

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

what am i doing wrong ? I get the same error when i try

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

how can i fix this?

I think you're better off just passing the fields as arguments , given that you have them as separate variables already.

This the "fullest" version of the authentication example, with your variables plugged in:

# 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',
)

Note the parameters after port all deal with SSL. If you're actually using certificates, then you need to be sure that you have told Python about them. If you're using standard certificates, then you can use certifi as shown in the link above.

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