keytoolエラー:java.io.IOException:無効なキーストア形式

keytoolエラー:java.io.IOException:無効なキーストア形式

3ノードELKスタック(Elasticsearch v7.17)があります。再起動後、Kibana Webインターフェースは「Kibanaサーバーがまだ準備されていません」というエラーを報告します。

SSL証明書が期限切れになって再作成されました(ELK CA、3つのノードすべて、KibanaおよびLogstashの場合)。ただし、エラーがまだ存在し、/var/log/kibana/kibana.logエラーが報告されます。

{"type":"log","@timestamp":"2023-03-29T17:19:39+02:00","tags":["error","elasticsearch-service"],"pid":8271,"message":"Unable to retrieve version information from Elasticsearch nodes. security_exception: [security_exception] Reason: unable to authenticate user [kibana] for REST request [/_nodes?filter_path=nodes.*.version%2Cnodes.*.http.publish_address%2Cnodes.*.ip]"}

このコマンドは、/usr/share/elasticsearch/bin/elasticsearch-setup-passwords interactive -v次の出力を生成します。

Running with configuration path: /etc/elasticsearch

Testing if bootstrap password is valid for http://10.0.0.1:9200/_security/_authenticate?pretty
{
  "username" : "elastic",
  "roles" : [
    "superuser"
  ],
  "full_name" : null,
  "email" : null,
  "metadata" : {
    "_reserved" : true
  },
  "enabled" : true,
  "authentication_realm" : {
    "name" : "reserved",
    "type" : "reserved"
  },
  "lookup_realm" : {
    "name" : "reserved",
    "type" : "reserved"
  },
  "authentication_type" : "realm"
}


Checking cluster health: http://10.0.0.1:9200/_cluster/health?pretty
{
  "error" : {
    "root_cause" : [
      {
        "type" : "master_not_discovered_exception",
        "reason" : null
      }
    ],
    "type" : "master_not_discovered_exception",
    "reason" : null
  },
  "status" : 503
}


Failed to determine the health of the cluster running at http://10.0.0.1:9200
Unexpected response code [503] from calling GET http://10.0.0.1:9200/_cluster/health?pretty
Cause: master_not_discovered_exception

Elasticsearchログは次のように言います。

[2023-03-30T13:50:58,432][WARN ][o.e.d.PeerFinder         ] [node1] address [10.0.0.2:9300], node [null], requesting [false] connection failed: [][10.0.0.2:9300] general node connection failure: handshake failed because connection reset
[2023-03-30T13:50:58,432][WARN ][o.e.t.TcpTransport       ] [node1] exception caught on transport layer [Netty4TcpChannel{localAddress=/10.0.0.1:60126, remoteAddress=node2.example.org/10.0.0.2:9300, profile=default}], closing connection
io.netty.handler.codec.DecoderException: javax.net.ssl.SSLHandshakeException: PKIX path validation failed: java.security.cert.CertPathValidatorException: Path does not chain with any of the trust anchors

パスワードが変更されていません。新しいSSL証明書に問題があるようです。だから、次のコマンドで新しいキーストアを作成しました。

/usr/share/elasticsearch/bin/elasticsearch-keystore create

CA証明書(および他の証明書)を追加しようとしています。

keytool -importcert -trustcacerts -noprompt -keystore /etc/elasticsearch/elasticsearch.keystore -file /etc/elasticsearch/certs/ca.crt

ただし、次のエラーが発生します。

keytool error: java.io.IOException: Invalid keystore format

CA証明書をPKCS12に変換し、キーストアがca.p12私の設定でPKCS12型として定義されているため、この形式()にインポートしようとしましたが、同じエラーが発生します。

何が問題なの?

ドキュメントからの抜粋/etc/elasticsearch/elasticsearch.yml

xpack.security.transport.ssl.keystore.path: elasticsearch.keystore
xpack.security.transport.ssl.keystore.type: PKCS12
xpack.security.transport.ssl.truststore.path: elasticsearch.keystore
xpack.security.transport.ssl.truststore.type: PKCS12
xpack.security.transport.ssl.verification_mode: certificate

ベストアンサー1

Elasticsearchクラスタが正しく設定されていない(master_not_discovered_exception)Kibanaはそれを使用できません。したがって、キバナは起動を完了できません。

Elasticsearchログフラグメントの表示(\明確にするために複数行に分けられています):

io.netty.handler.codec.DecoderException: \
javax.net.ssl.SSLHandshakeException: \
PKIX path validation failed: \ 
java.security.cert.CertPathValidatorException: \ 
Path does not chain with any of the trust anchors

したがって、ソフトウェアは現在信頼されているルートCA証明書と使用する必要があるサーバー証明書との間の証明書パスを見つけることができないようです。ルートCAとサーバー証明書の間に中間CA証明書がありませんか?

keytool error: java.io.IOException: Invalid keystore format

このkeytoolコマンドはJavaの汎用キーストアファイル(PKCS12およびJKS形式)で機能しますが、Elasticsearchは任意のElasticsearch設定およびJSON形式認証キーファイルも含めることができる独自のキーストア形式を使用しているようです。以下の専用ツールが必要ですelasticsearch-keystore

https://www.elastic.co/guide/en/elasticsearch/reference/current/elasticsearch-keystore.html

おすすめ記事