Elasticsearch(实践2)链接库产生TLS验证安全性报错

2024-01-08 11:31:07

问题:

? File "/home/server/miniconda3/envs/rag/lib/python3.8/site-packages/elastic_transport/_transport.py", line 328, in perform_request
? ? meta, raw_data = node.perform_request(
? File "/home/server/miniconda3/envs/rag/lib/python3.8/site-packages/elastic_transport/_node/_http_urllib3.py", line 202, in perform_request
? ? raise err from None
elastic_transport.TlsError: TLS error caused by: TlsError(TLS error caused by: SSLError([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1131)))

当前,ElasticVectorSearch和?ElasticKNNSearch 为旧版 ,这里直接使用新版ElasticsearchStore

修改前:

    es_connection = ElasticsearchStore(
        embedding=embedings_h,
        index_name="hello-index",
        es_url = "https://192.168.0.133:9200",
        es_user = "elastic",
        es_password = "cwr9De0nHWPT27QyJMf+",
        distance_strategy = 'COSINE',
   
    )

添加?es_params = {"ca_certs":False,"verify_certs" : False} 字段即可

    es_connection = ElasticsearchStore(
        embedding=embedings_h,
        index_name="hello-index",
        es_url = "https://192.168.0.133:9200",
        es_user = "elastic",
        es_password = "cwr9De0nHWPT27QyJMf+",
        distance_strategy = 'COSINE',
        es_params = {"ca_certs":False,"verify_certs" : False},
    )
    

当前为快速验证阶段,不想看警告信息,可添加到头部

import urllib3
urllib3.disable_warnings()

文章来源:https://blog.csdn.net/ckq707718837/article/details/135452386
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。