我不相信这是一个logstash问题,但是在logstash ubuntu或转发器机器上不正确地处理证书或者没有设置正确的东西.
我生成了密钥:
sudo openssl req -x509 -batch -nodes -newkey rsa:2048 -keyout private/logstash-forwarder.key -out certs/logstash-forwarder.crt
我在logstash服务器上的输入conf:
input { lumberjack { port => 5000 type => "logs" ssl_certificate => "/etc/pki/tls/certs/logstash-forwarder.crt" ssl_key => "/etc/pki/tls/private/logstash-forwarder.key" } }
密钥已复制到转发器主机,该主机具有以下配置.
{ "network": { "servers": [ "192.168.2.107:5000" ],"timeout": 15,"ssl ca": "/etc/pki/tls/certs/logstash-forwarder.crt" "ssl key": "/etc/pki/tls/certs/logstash-forwarder.key" },"files": [ { "paths": [ "/var/log/syslog","/var/log/auth.log" ],"fields": { "type": "syslog" } } ] }
运行logstash服务器后,我在转发器机器上’sudo service logstash-forwarder start’,给出了以下重复错误:
Jul 9 05:06:21 ubuntu logstash-forwarder[1374]: 2014/07/09 05:06:21.589762 Connecting to [192.168.2.107]:5000 (192.168.2.107) Jul 9 05:06:21 ubuntu logstash-forwarder[1374]: 2014/07/09 05:06:21.595105 Failed to tls handshake with 192.168.2.107 x509: cannot validate certificate for 192.168.2.107 because it doesn't contain any IP SANs Jul 9 05:06:22 ubuntu logstash-forwarder[1374]: 2014/07/09 05:06:22.595971 Connecting to [192.168.2.107]:5000 (192.168.2.107) Jul 9 05:06:22 ubuntu logstash-forwarder[1374]: 2014/07/09 05:06:22.602024 Failed to tls handshake with 192.168.2.107 x509: cannot validate certificate for 192.168.2.107 because it doesn't contain any IP SANs
正如我之前提到的,我不相信这是一个logstash问题,而是证书/机器配置问题.问题是,我似乎无法解决它.希望这里一些聪明的人可以帮助我吗?
谢谢
… Failed to tls handshake with 192.168.2.107 x509: cannot validate certificate for 192.168.2.107 because it doesn’t contain any IP SANs
SSL需要识别对等体,否则您的连接可能是针对中间人的,这会解密嗅探/修改数据,然后再将其加密转发到真实目标.使用x509证书进行标识,需要针对受信任的CA进行验证,并且需要识别要连接的目标.
通常,目标作为主机名提供,并根据主题和证书的替代名称进行检查.在这种情况下,您的目标是IP.成功验证证书IP必须在主题备用名称部分内的证书中给出,但不能作为DNS条目(例如主机名)而是作为IP.
所以你需要的是:
>在logstash主机上编辑/etc/ssl/openssl.cnf – 在[v3_ca]部分中添加subjectAltName = IP:192.168.2.107.
>重新创建证书
>将证书和密钥复制到两台主机
PS考虑在证书创建命令行中添加-days 365或更多,因为默认证书有效期仅为30天,您可能不希望每个月重新创建它.