我正在使用预先配置有自签名证书的Elastic Search 7.1(Open Distro docker映像)。因此,根据Elastic Search PHP文档,我需要传递根CA证书,以便Elastic Search客户端可以验证SSL连接。因此,我将ca-root.pem从docker映像复制到了我的Web服务器,并将其传递给ClientBuilder。
$host = 'https://admin:admin@elasticsearch:9200';
$caBundle = './aws/dockerdevbox/certs/root-ca.pem';
$this->client = ClientBuilder::create()
->setHosts([$host])
->setSSLVerification($caBundle)
->build();
这会导致错误:
Elasticsearch\Common\Exceptions\NoNodesAvailableException: No alive nodes found in your cluster.
通过查看Elastic Search日志,我看到以下内容:
[elasticsearch] SSL Problem Received fatal alert: unknown_ca
但是在同一主机上,如果我使用curl并通过CA证书,则不会有任何问题:
curl --cacert aws/dockerdevbox/certs/root-ca.pem -X GET "https://admin:admin@elasticsearch:9200/_cluster/health?pretty"
{
"cluster_name" : "cluster",
"status" : "yellow",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 210,
"active_shards" : 210,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 202,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 50.970873786407765
}
我已经尝试了所有方法,甚至尝试使用自己的自签名证书(与服务器附带的证书相反),结果仍然相同。从字面上看,我一直在努力使这一工作正常进行,这应该很简单。
希望有人遇到了这个问题,可以为我提供帮助!