橡皮、老虎皮、狮子皮哪一个最不好?

python https连接ES 失败

Elasticsearch | 作者 qq89267388 | 发布于2019年09月04日 | 阅读数:5598

我的ELK版本为7.2  使用免费的xpack做了TLS加密
 
我使用elasticsearch的CA签发的证书,
 
现在我用curl命令加载ca.crt证书是可以连接ES并获取数据的
 
但是当我用python的elasticsearch模块调用这个证书的时候却报如下错误:
 
elasticsearch.exceptions.ConnectionError: ConnectionError(check_hostname requires server_hostname) caused by: ValueError(check_hostname requires server_hostname)
 
下面是我的代码
 
ca.crt证书是放在和脚本相同文件夹下的
from elasticsearch
from ssl import create_default_context
 

context = create_default_context(cafile="ca.crt")
ES = Elasticsearch(["x.x.x.x"],http_auth=('账号', '密码'),scheme="https",port=9200,ssl_context=context,timeout=30)
 
请问问题出下哪里呢 。。 我的证书是用的ip地址签发的
 
已邀请:

qq89267388

赞同来自:

我通过
context = create_default_context(cafile="ca.crt").get_ca_certs()
方法看了下证书
[{'subject': ((('commonName', 'Elastic Certificate Tool Autogenerated CA'),),), 'issuer': ((('commonName', 'Elastic Certificate Tool Autogenerated CA'),),), 'version': 3, 'serialNumber': '0192374661482DE6103233854CA8CD4FB143FBA2', 'notBefore': 'Sep  3 05:25:26 2019 GMT', 'notAfter': 'Sep  2 05:25:26 2022 GMT'}]

可是 并没有hostname这个参数啊
 
我用的是下面的命令签发的证书
 
/usr/share/elasticsearch/bin/elasticsearch-certutil cert ca --pem --in ~/instance.yml --out ~/elk-stack-certs.zip

zhuwb

赞同来自:

可以分享一下你的解决方法么?

要回复问题请先登录注册