Add intermediates when verifying cert in x509 input (#6159)
This commit is contained in:
parent
ef4f4eed3a
commit
004b2cf578
|
@ -176,9 +176,16 @@ func (c *X509Cert) Gather(acc telegraf.Accumulator) error {
|
|||
|
||||
// The first certificate is the leaf/end-entity certificate which needs DNS
|
||||
// name validation against the URL hostname.
|
||||
opts := x509.VerifyOptions{}
|
||||
opts := x509.VerifyOptions{
|
||||
Intermediates: x509.NewCertPool(),
|
||||
}
|
||||
if i == 0 {
|
||||
opts.DNSName = u.Hostname()
|
||||
for j, cert := range certs {
|
||||
if j != 0 {
|
||||
opts.Intermediates.AddCert(cert)
|
||||
}
|
||||
}
|
||||
}
|
||||
if c.tlsCfg.RootCAs != nil {
|
||||
opts.Roots = c.tlsCfg.RootCAs
|
||||
|
|
Loading…
Reference in New Issue