我已经为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
如果您已使用正确的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
部署和享受。