繁体   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