diff --git a/cmd/telemetrygen/internal/common/tls_utils.go b/cmd/telemetrygen/internal/common/tls_utils.go index d9678079a188..7daf39fdeabd 100644 --- a/cmd/telemetrygen/internal/common/tls_utils.go +++ b/cmd/telemetrygen/internal/common/tls_utils.go @@ -35,9 +35,15 @@ func GetTLSCredentialsForGRPCExporter(caFile string, cAuth ClientAuth) (credenti return nil, err } - creds := credentials.NewTLS(&tls.Config{ - RootCAs: pool, - }) + var creds credentials.TransportCredentials + + if caFile != "" { + creds = credentials.NewTLS(&tls.Config{ + RootCAs: pool, + }) + } else { + creds = credentials.NewTLS(&tls.Config{}) + } // Configuration for mTLS if cAuth.Enabled { @@ -60,8 +66,14 @@ func GetTLSCredentialsForHTTPExporter(caFile string, cAuth ClientAuth) (*tls.Con return nil, err } - tlsCfg := tls.Config{ - RootCAs: pool, + var tlsCfg tls.Config + + if caFile != "" { + tlsCfg = tls.Config{ + RootCAs: pool, + } + } else { + tlsCfg = tls.Config{} } // Configuration for mTLS