简体   繁体   English

Filebeat Kafka 客户端与 AWS MSK 的 SSL 握手失败

[英]Filebeat Kafka client failing SSL handshake with AWS MSK

We are trying to send logs using Filebeat to AWS MSK (Provisioned) using kafka configuration available.我们正在尝试使用可用的 kafka 配置将使用 Filebeat 的日志发送到 AWS MSK(已配置)。 We're using mTLS authentication with the setup of Root CA and Intermediate CA with Vault.我们将 mTLS 身份验证与 Root CA 和带 Vault 的中间 CA 的设置一起使用。 The intermediate CA is available in AWS PCA which is assigned to AWS MSK cluster which in turn issues the certs to the brokers on AWS MSK.中间 CA 在 AWS PCA 中可用,它被分配给 AWS MSK 集群,后者又将证书颁发给 AWS MSK 上的代理。

We are able to do mTLS authentication using Kafka client with the Admin setup (Kafka client with required certificates), however filebeat kafka is failing to do SSL handshake.我们可以使用带有管理员设置的 Kafka 客户端(具有所需证书的 Kafka 客户端)进行 mTLS 身份验证,但是 filebeat kafka 无法进行 SSL 握手。 All the certs provided in the handshake are valid.握手中提供的所有证书均有效。

Filebeat docker image : docker.elastic.co/beats/filebeat:8.5.1 Filebeat docker 图片docker.elastic.co/beats/filebeat:8.5.1 :8.5.1

Our Filebeat config looks like我们的 Filebeat 配置看起来像

filebeat.yaml filebeat.yaml

---
filebeat.shutdown_timeout: 0
fields_under_root: false
logging.level: debug
.
.
.


output.kafka:
  hosts: 'XXXXMSK_BOOTSTRAP_HOSTSXXXX'
  ssl.enabled: true
  ssl.verification_mode: 'certificate'
  ssl.certificate: /path/to/obained-cert.crt'
  ssl.key: /path/to/obained-key.pki.key'
  ssl.authorities: [/path/to/root/int/ca/combined-file/msk_ca_chain.pem']
  topic: 'XXXXKAFKA_TOPICXXXX'
  codec.format:
    string: '{"timestamp": "%{[@timestamp]}", "message": %{[message]}, "host": %{[host]}}'
  close_inactive: 10m
  required_acks: 1
  partition.round_robin:
    reachable_only: false
  keep-alive: 30000ms

obained-cert.crt获得证书.crt

-----BEGIN CERTIFICATE-----
MIIXXXXX
#Obtained Cert#
-----END CERTIFICATE-----

obained-key.pki.key获得的密钥.pki.key

-----BEGIN RSA PRIVATE KEY-----
MIIXXXXX
#Obtained private key#
-----END RSA PRIVATE KEY-----

msk_ca_chain.pem msk_ca_chain.pem

-----BEGIN CERTIFICATE-----
MIIXXXXX
#Intermediate CA Cert#
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIXXXXX
#Root CA Cert#
-----END CERTIFICATE-----

The error in Filebeat log is: Filebeat 日志中的错误是:

{"log.level":"error","@timestamp":"2023-01-06T10:59:48.701Z","log.logger":"kafka","log.origin":{"file.name":"kafka/client.go","file.line":337},"message":"Kafka (topic=XXXXKAFKA_TOPICXXXX): kafka: client has run out of available brokers to talk to (Is your cluster reachable?)","service.name":"filebeat","ecs.version":"1.6.0"}

The error on AWS Cloudwatch for the brokers is:代理的 AWS Cloudwatch 上的错误是:

[2023-01-06 12:48:07,716] INFO [SocketServer listenerType=ZK_BROKER, nodeId=3] Failed authentication with /INTERNAL_IP (SSL handshake failed) (org.apache.kafka.common.network.Selector)
[2023-01-06 12:48:08,004] INFO [SocketServer listenerType=ZK_BROKER, nodeId=2] Failed authentication with /INTERNAL_IP (SSL handshake failed) (org.apache.kafka.common.network.Selector)
[2023-01-06 12:48:08,016] INFO [SocketServer listenerType=ZK_BROKER, nodeId=1] Failed authentication with /INTERNAL_IP (SSL handshake failed) (org.apache.kafka.common.network.Selector)

I've enabled debug logs on Filebeat, but I'm not seeing any information regarding why SSL handshake has failed.我在 Filebeat 上启用了调试日志,但我没有看到任何有关 SSL 握手失败原因的信息。

Is there any way we could see any debug logs on Filebeat Kafka or AWS MSK Broker side to identify why SSL handshake is failing?有什么方法可以让我们在 Filebeat Kafka 或 AWS MSK Broker 端看到任何调试日志,以确定 SSL 握手失败的原因? Also, any pointers around possible problems in filebeat.yaml config are also appreciated.此外,还感谢有关 filebeat.yaml 配置中可能出现的问题的任何指示。

Thanks in advance!!!提前致谢!!!

Sorry for answering my own question.很抱歉回答我自己的问题。 I have resolved this issue now by appending intermediate CA cert to the certificate obtained by root CA and then supplying only root CA in authorities section.我现在通过将中间 CA 证书附加到根 CA 获得的证书然后在权限部分仅提供根 CA 来解决此问题。

The changes I made:我所做的改变:

  1. Appended intermediate CA cert to the file /path/to/obained-cert.crt for the parameter ssl.certificate为参数ssl.certificate将中间 CA 证书附加到文件/path/to/obained-cert.crt
  2. Provided only the root certificate instead of chain of certificates for the parameter ssl.authorities ie ['/path/to/root/ca/msk_root_ca.pem']仅提供根证书而不是参数ssl.authorities的证书链,即['/path/to/root/ca/msk_root_ca.pem']

This has done the trick!!这已经成功了!

So, if you've intermidiate CA in the PKI, always append that to the obtained cert in order to carry out SSL handshake.所以,如果你在 PKI 中有中间 CA,总是 append 到获得的证书,以便执行 SSL 握手。

I hope this helps others.我希望这对其他人有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM