Filebeat无法连接到Logstash,因为证书不包含任何IP SAN

时间:2017-12-17 17:54:43

标签: ssl logstash elastic-stack filebeat

我已经为Filebeat(v6.1.0,ELK 5.6.4)生成了SSL证书,并将它们部署到客户端并配置了Filebeat以使用ssl.certificate_authorities中的filebeat.yml。但是,即使我在SSL配置中的subjectAlternateName中指定了[ v3_ca ],filebeat也无法验证SSL证书。

生成密钥:

$ sudo openssl req -config cert.cnf -x509 -batch -nodes -newkey rsa -keyout private/logstash-forwarder.key -out certs/logstash-forwarder.crt

cert.cnf

[ req ]
prompt = no
distinguished_name = req_distinguished_name

[ req_distinguished_name ]
countryName = BL
stateOrProvinceName = blah
localityName = blah
commonName = xxx.xxx.xxx.xxx

[ v3_ca ]
subjectAltName = IP:xxx.xxx.xxx.xxx

为什么我仍然收到以下错误?

ERR  Failed to connect: x509: cannot validate certificate for xxx.xxx.xxx.xxx because it doesn't contain any IP SANs

1 个答案:

答案 0 :(得分:0)

如果您使用正确的IP地址添加了subjectAltName并且仍然看到此错误,请验证证书是否实际从配置文件中获取此属性。

验证密钥:

$ openssl x509 -in certs/logstash-forwarder.crt -text -noout

寻找一个部分

X509v3 Subject Alternative Name:
            IP Address:xxx.xxx.xxx.xxx

如果缺少该部分,则由于某种原因,未为您的密钥生成subjectAlternateName。在这种情况下,虽然所有文档都说要将subjectAlternateName放在[ v3_ca ]部分下,但除非另有说明,否则不会读取此部分(如果您使用默认/etc/ssl/openssl.cnf可能不是问题)。对于CA:在certs.cnf中,请确保[ req ]部分将x509_extensions指向v3_ca。对于CSR:在certs.cnf中,请确保[ req ]部分将req_extensions指向v3_ca

<强> cert.cnf

[ req ]
prompt = no
distinguished_name = req_distinguished_name
req_extensions = v3_ca  # <----------- This one, if generating a CSR
x509_extensions = v3_ca  # <---------- This one, if generating a CA

[ req_distinguished_name ]
countryName = BL
stateOrProvinceName = blah
localityName = blah
commonName = xxx.xxx.xxx.xxx

[ v3_ca ]
subjectAltName = IP:xxx.xxx.xxx.xxx

重新生成密钥,验证,您应该在输出中看到以下部分:

X509v3 extensions:
    X509v3 Subject Alternative Name:
        IP Address:xxx.xxx.xxx.xxx

部署并享受。