Skip to content

Commit

Permalink
Only show deprecation warnings for CN-based verification once (elasti…
Browse files Browse the repository at this point in the history
…c#24948)

(cherry picked from commit 3b99e42)
  • Loading branch information
Andrew Stucki committed Apr 7, 2021
1 parent 182ed99 commit f2e64b9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion libbeat/common/transport/tlscommon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ package tlscommon

import (
"crypto/tls"
"sync"

"github.com/joeshaw/multierror"

"github.com/elastic/beats/v7/libbeat/common/cfgwarn"
)

var warnOnce sync.Once

// Config defines the user configurable options in the yaml file.
type Config struct {
Enabled *bool `config:"enabled" yaml:"enabled,omitempty"`
Expand Down Expand Up @@ -98,7 +101,9 @@ func LoadTLSConfig(config *Config) (*TLSConfig, error) {
// Validate values the TLSConfig struct making sure certificate sure we have both a certificate and
// a key.
func (c *Config) Validate() error {
cfgwarn.Deprecate("8.0.0", "Treating the CommonName field on X.509 certificates as a host name when no Subject Alternative Names are present is going to be removed. Please update your certificates if needed.")
warnOnce.Do(func() {
cfgwarn.Deprecate("8.0.0", "Treating the CommonName field on X.509 certificates as a host name when no Subject Alternative Names are present is going to be removed. Please update your certificates if needed.")
})

return c.Certificate.Validate()
}
Expand Down

0 comments on commit f2e64b9

Please sign in to comment.