From 5a5095dda900dc7214b562704290f7ac60c9891f Mon Sep 17 00:00:00 2001 From: Alex Craig Date: Tue, 13 Feb 2024 16:48:24 -0800 Subject: [PATCH] Fix case where root CAs should inherit from host environment --- cmd/telemetrygen/internal/common/tls_utils.go | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) 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