Skip to content

Commit

Permalink
Fix case where root CAs should inherit from host environment
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexDCraig committed Feb 14, 2024
1 parent 591b428 commit 5a5095d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions cmd/telemetrygen/internal/common/tls_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 5a5095d

Please sign in to comment.