首页 > 解决方案 > 如何使用 PKI 身份验证来使用 Opensearch Dashboards API?

问题描述

我正在尝试使用 OpenSearch Dashboards API (Amazon Kibana fork) 添加搜索索引。我使用的是 1.0 版并且还设置了安全插件。我使用 TLS PKI 与 OpenSearch (Elasticsearch) 交互没有任何问题。但是,每当我尝试使用 TLS PKI 身份验证与 OpenSearch Dashboard API 交互时,都会收到错误消息。我能够在仪表板中设置 PKI 以向 OpenSearch 进行身份验证,而不会出现任何问题。这实际上是使用 curl 的 shell 上的命令,但我希望在完成后使用 python:

curl -X POST --cert MYCERT.crt --key MYKEY.key --cacert MY-CA-BUNDLE.crt https://HOSTNAME:5601/api/saved_objects/index-pattern/test-index -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'  { "attributes": {  "title": "test-index-*","timeFieldName": "@timestamp"  } }'

我收到以下 JSON 消息错误:

{"statusCode":401,"error":"Unauthorized","message":"Authentication required"}

如果我改为使用带有“简单”用户名/密码的 API,则相同的命令可以工作:

curl -X POST -u USERNAME:PASSWORD https://HOSTNAME:5601/api/saved_objects/index-pattern/test-index -H 'kbn-xsrf: true' -H 'Content-Type: application/json' -d'  { "attributes": {  "title": "test-index-*","timeFieldName": "@timestamp"  } }'

但是,我似乎无法找到一种方法来允许我的 ansible 使用 PKI 证书向 API 发出命令,我希望这样做,以便我可以禁用简单的身份验证。有谁知道我缺少什么设置或者我是否滥用了 API?我研究了插件文档,但找不到任何我丢失的项目。

标签: kibanaopensearchopensearch-dashboardsopensearch-security-plugin

解决方案


您是否尝试过对 Opensearch 服务进行简单查询,例如:

curl -XGET -k https://$(hostname):9200/ --key MYKEY.key --cert MYCERT.crt 

如果这个不起作用,可能您需要检查 opensearch.yml 文件中配置的证书。


推荐阅读