Graylog配置Beats输入TLS客户端认证后出现协议版本未知错误
解决Beats输入开启TLS客户端认证后无法正常工作的问题
需求
使Beats输入在开启TLS客户端认证后正常工作。
已执行的操作步骤
- 制作自定义Graylog镜像,添加自签名证书:
FROM graylog/graylog:4.3 USER root ADD beat.crt /usr/local/share/ca-certificates/beat.crt RUN chmod 644 /usr/local/share/ca-certificates/beat.crt && update-ca-certificate
- 配置Beats输入,要求TLS客户端认证:
bind_address: 0.0.0.0 no_beats_prefix: true number_worker_threads: 80 override_source: <empty> port: 5044 recv_buffer_size: 1048576 tcp_keepalive: false tls_cert_file: <empty> tls_client_auth: required tls_client_auth_cert_file: /usr/local/share/ca-certificates/beat.crt tls_enable: false tls_key_file: <empty> tls_key_password:********
- 在另一台机器配置Filebeat,挂载tls目录:
output.logstash: hosts: ["graylog_ip_here:5044"] ssl.certificate_authorities: ["/tls/beat.pem"] ssl.certificate: "/tls/beat.crt" ssl.key: "/tls/beat.key"
证书文件内容示例:
-----BEGIN CERTIFICATE----- MIIFVzCCAz+gAwIBAgIJALJI6zP
出现的错误
ERROR: org.graylog2.plugin.inputs.transports.AbstractTcpTransport - 输入发生错误,原因是io.netty.handler.codec.DecoderException: java.lang.IllegalStateException: 未知的Beats协议版本: 3)
问题分析与解决方案
问题根源
Graylog的Beats输入配置中tls_enable被设置为false,但Filebeat端已经配置了SSL/TLS加密连接参数。这导致双方通信协议不匹配:Filebeat发送的是加密后的TLS流量,而Graylog输入未启用TLS,无法解析加密内容,因此抛出了"未知Beats协议版本"的错误。
修复步骤
修改Graylog Beats输入配置,启用TLS
将配置中的tls_enable改为true,同时必须指定Graylog服务器的TLS证书和密钥文件路径(开启TLS需要服务器证书来完成握手):bind_address: 0.0.0.0 no_beats_prefix: true number_worker_threads: 80 override_source: <empty> port: 5044 recv_buffer_size: 1048576 tcp_keepalive: false tls_cert_file: /path/to/graylog-server.crt # 替换为你的服务器证书实际路径 tls_client_auth: required tls_client_auth_cert_file: /usr/local/share/ca-certificates/beat.crt tls_enable: true tls_key_file: /path/to/graylog-server.key # 替换为你的服务器密钥实际路径 tls_key_password: ******** # 密钥密码(若密钥未加密可留空)确保Graylog能访问服务器证书和密钥
- 可以将服务器证书和密钥添加到自定义Graylog镜像中,或者通过容器挂载的方式提供这些文件。
- 保证证书文件权限为
644,密钥文件权限为600,避免权限问题导致加载失败。
验证Filebeat的SSL配置一致性
- 确保
ssl.certificate_authorities中的证书是Graylog服务器证书的CA根证书,若使用自签名证书,可直接指定Graylog服务器证书路径。 - 检查证书和密钥文件路径是否正确,容器挂载的tls目录是否正常映射。
- 确保
内容的提问来源于stack exchange,提问作者Sultan Zhumatayev
相关产品推荐
相关产品推荐

