diff --git a/cmd/opampsupervisor/supervisor/supervisor.go b/cmd/opampsupervisor/supervisor/supervisor.go index 2c4d132fc88f..87ad84ba543e 100644 --- a/cmd/opampsupervisor/supervisor/supervisor.go +++ b/cmd/opampsupervisor/supervisor/supervisor.go @@ -361,7 +361,7 @@ func (s *Supervisor) Capabilities() protobufs.AgentCapabilities { func (s *Supervisor) startOpAMP() error { s.opampClient = client.NewWebSocket(newLoggerFromZap(s.logger)) - tlsConfig, err := s.config.Server.TLSSetting.LoadTLSConfig() + tlsConfig, err := s.config.Server.TLSSetting.LoadTLSConfigContext(context.Background()) if err != nil { return err } diff --git a/exporter/elasticsearchexporter/elasticsearch_bulk.go b/exporter/elasticsearchexporter/elasticsearch_bulk.go index 9885b70a4127..fbce80a583d4 100644 --- a/exporter/elasticsearchexporter/elasticsearch_bulk.go +++ b/exporter/elasticsearchexporter/elasticsearch_bulk.go @@ -65,7 +65,7 @@ func (*clientLogger) ResponseBodyEnabled() bool { } func newElasticsearchClient(logger *zap.Logger, config *Config) (*esClientCurrent, error) { - tlsCfg, err := config.ClientConfig.LoadTLSConfig() + tlsCfg, err := config.ClientConfig.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/exporter/prometheusexporter/prometheus_test.go b/exporter/prometheusexporter/prometheus_test.go index ca1b5f5522e9..d3628413a790 100644 --- a/exporter/prometheusexporter/prometheus_test.go +++ b/exporter/prometheusexporter/prometheus_test.go @@ -125,7 +125,7 @@ func TestPrometheusExporter_WithTLS(t *testing.T) { }, ServerName: "localhost", } - tls, err := tlscs.LoadTLSConfig() + tls, err := tlscs.LoadTLSConfigContext(context.Background()) assert.NoError(t, err) httpClient := &http.Client{ Transport: &http.Transport{ diff --git a/exporter/signalfxexporter/exporter.go b/exporter/signalfxexporter/exporter.go index c0d4cc3cd6bd..915aaa161fb0 100644 --- a/exporter/signalfxexporter/exporter.go +++ b/exporter/signalfxexporter/exporter.go @@ -125,7 +125,7 @@ func (se *signalfxExporter) start(ctx context.Context, host component.Host) (err sendOTLPHistograms: se.config.SendOTLPHistograms, } - apiTLSCfg, err := se.config.APITLSSettings.LoadTLSConfig() + apiTLSCfg, err := se.config.APITLSSettings.LoadTLSConfigContext(ctx) if err != nil { return fmt.Errorf("could not load API TLS config: %w", err) } diff --git a/exporter/signalfxexporter/exporter_test.go b/exporter/signalfxexporter/exporter_test.go index d81236b80cf8..cd133febc86d 100644 --- a/exporter/signalfxexporter/exporter_test.go +++ b/exporter/signalfxexporter/exporter_test.go @@ -1522,7 +1522,7 @@ func TestTLSAPIConnection(t *testing.T) { t.Run(tt.name, func(t *testing.T) { observedZapCore, observedLogs := observer.New(zap.DebugLevel) logger := zap.New(observedZapCore) - apiTLSCfg, err := tt.config.APITLSSettings.LoadTLSConfig() + apiTLSCfg, err := tt.config.APITLSSettings.LoadTLSConfigContext(context.Background()) require.NoError(t, err) serverURL, err := url.Parse(tt.config.APIURL) assert.NoError(t, err) diff --git a/exporter/syslogexporter/exporter.go b/exporter/syslogexporter/exporter.go index 890b1071559e..04db23a3f2eb 100644 --- a/exporter/syslogexporter/exporter.go +++ b/exporter/syslogexporter/exporter.go @@ -30,7 +30,7 @@ func initExporter(cfg *Config, createSettings exporter.CreateSettings) (*sysloge var loadedTLSConfig *tls.Config if cfg.Network == "tcp" { var err error - loadedTLSConfig, err = cfg.TLSSetting.LoadTLSConfig() + loadedTLSConfig, err = cfg.TLSSetting.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/extension/oauth2clientauthextension/extension.go b/extension/oauth2clientauthextension/extension.go index 2c2e80fdef25..54b46ca321d9 100644 --- a/extension/oauth2clientauthextension/extension.go +++ b/extension/oauth2clientauthextension/extension.go @@ -38,7 +38,7 @@ var errFailedToGetSecurityToken = fmt.Errorf("failed to get security token from func newClientAuthenticator(cfg *Config, logger *zap.Logger) (*clientAuthenticator, error) { transport := http.DefaultTransport.(*http.Transport).Clone() - tlsCfg, err := cfg.TLSSetting.LoadTLSConfig() + tlsCfg, err := cfg.TLSSetting.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/extension/oauth2clientauthextension/extension_test.go b/extension/oauth2clientauthextension/extension_test.go index a24d869705e9..1db51e02fc59 100644 --- a/extension/oauth2clientauthextension/extension_test.go +++ b/extension/oauth2clientauthextension/extension_test.go @@ -98,7 +98,7 @@ func TestOAuthClientSettings(t *testing.T) { // test tls settings transport := rc.client.Transport.(*http.Transport) tlsClientConfig := transport.TLSClientConfig - tlsTestSettingConfig, err := test.settings.TLSSetting.LoadTLSConfig() + tlsTestSettingConfig, err := test.settings.TLSSetting.LoadTLSConfigContext(context.Background()) assert.NoError(t, err) assert.Equal(t, tlsClientConfig.Certificates, tlsTestSettingConfig.Certificates) }) @@ -190,7 +190,7 @@ func TestOAuthClientSettingsCredsConfig(t *testing.T) { // test tls settings transport := rc.client.Transport.(*http.Transport) tlsClientConfig := transport.TLSClientConfig - tlsTestSettingConfig, err := test.settings.TLSSetting.LoadTLSConfig() + tlsTestSettingConfig, err := test.settings.TLSSetting.LoadTLSConfigContext(context.Background()) assert.NoError(t, err) assert.Equal(t, tlsClientConfig.Certificates, tlsTestSettingConfig.Certificates) }) diff --git a/extension/opampextension/opamp_agent.go b/extension/opampextension/opamp_agent.go index 99156d790d05..42096711120f 100644 --- a/extension/opampextension/opamp_agent.go +++ b/extension/opampextension/opamp_agent.go @@ -43,13 +43,13 @@ type opampAgent struct { opampClient client.OpAMPClient } -func (o *opampAgent) Start(_ context.Context, _ component.Host) error { +func (o *opampAgent) Start(ctx context.Context, _ component.Host) error { header := http.Header{} for k, v := range o.cfg.Server.GetHeaders() { header.Set(k, string(v)) } - tls, err := o.cfg.Server.GetTLSSetting().LoadTLSConfig() + tls, err := o.cfg.Server.GetTLSSetting().LoadTLSConfigContext(ctx) if err != nil { return err } diff --git a/internal/kafka/authentication.go b/internal/kafka/authentication.go index a05edc6486c5..ca3fdbf03a26 100644 --- a/internal/kafka/authentication.go +++ b/internal/kafka/authentication.go @@ -4,6 +4,7 @@ package kafka // import "github.com/open-telemetry/opentelemetry-collector-contrib/internal/kafka" import ( + "context" "crypto/sha256" "crypto/sha512" "fmt" @@ -135,7 +136,7 @@ func configureSASL(config SASLConfig, saramaConfig *sarama.Config) error { } func configureTLS(config configtls.ClientConfig, saramaConfig *sarama.Config) error { - tlsConfig, err := config.LoadTLSConfig() + tlsConfig, err := config.LoadTLSConfigContext(context.Background()) if err != nil { return fmt.Errorf("error loading tls config: %w", err) } diff --git a/internal/kafka/authentication_test.go b/internal/kafka/authentication_test.go index 8761115290b8..64004e824ec2 100644 --- a/internal/kafka/authentication_test.go +++ b/internal/kafka/authentication_test.go @@ -4,6 +4,7 @@ package kafka import ( + "context" "testing" "github.com/IBM/sarama" @@ -47,7 +48,7 @@ func TestAuthentication(t *testing.T) { saramaTLSCfg := &sarama.Config{} saramaTLSCfg.Net.TLS.Enable = true tlsClient := configtls.ClientConfig{} - tlscfg, err := tlsClient.LoadTLSConfig() + tlscfg, err := tlsClient.LoadTLSConfigContext(context.Background()) require.NoError(t, err) saramaTLSCfg.Net.TLS.Config = tlscfg diff --git a/pkg/stanza/operator/input/tcp/config.go b/pkg/stanza/operator/input/tcp/config.go index 81ee1b21d0ed..2db374b2dec3 100644 --- a/pkg/stanza/operator/input/tcp/config.go +++ b/pkg/stanza/operator/input/tcp/config.go @@ -5,6 +5,7 @@ package tcp // import "github.com/open-telemetry/opentelemetry-collector-contrib import ( "bufio" + "context" "fmt" "net" "time" @@ -139,7 +140,7 @@ func (c Config) Build(logger *zap.SugaredLogger) (operator.Operator, error) { } if c.TLS != nil { - tcpInput.tls, err = c.TLS.LoadTLSConfig() + tcpInput.tls, err = c.TLS.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/processor/resourcedetectionprocessor/internal/openshift/openshift.go b/processor/resourcedetectionprocessor/internal/openshift/openshift.go index 76da89e9ba61..b239ac970f78 100644 --- a/processor/resourcedetectionprocessor/internal/openshift/openshift.go +++ b/processor/resourcedetectionprocessor/internal/openshift/openshift.go @@ -30,7 +30,7 @@ func NewDetector(set processor.CreateSettings, dcfg internal.DetectorConfig) (in return nil, err } - tlsCfg, err := userCfg.TLSSettings.LoadTLSConfig() + tlsCfg, err := userCfg.TLSSettings.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/receiver/aerospikereceiver/config.go b/receiver/aerospikereceiver/config.go index 3ebed5363b84..2c199de97dd0 100644 --- a/receiver/aerospikereceiver/config.go +++ b/receiver/aerospikereceiver/config.go @@ -4,6 +4,7 @@ package aerospikereceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/aerospikereceiver" import ( + "context" "errors" "fmt" "net" @@ -80,7 +81,7 @@ func (c *Config) Validate() error { } if c.TLS != nil { - _, err := c.TLS.LoadTLSConfig() + _, err := c.TLS.LoadTLSConfigContext(context.Background()) if err != nil { allErrs = multierr.Append(allErrs, fmt.Errorf("%w: %s", errFailedTLSLoad, err.Error())) } diff --git a/receiver/aerospikereceiver/scraper.go b/receiver/aerospikereceiver/scraper.go index 402973872ecb..40945b791675 100644 --- a/receiver/aerospikereceiver/scraper.go +++ b/receiver/aerospikereceiver/scraper.go @@ -43,7 +43,7 @@ func newAerospikeReceiver(params receiver.CreateSettings, cfg *Config, consumer var err error var tlsCfg *tls.Config if cfg.TLS != nil { - tlsCfg, err = cfg.TLS.LoadTLSConfig() + tlsCfg, err = cfg.TLS.LoadTLSConfigContext(context.Background()) if err != nil { return nil, fmt.Errorf("%w: %s", errFailedTLSLoad, err.Error()) } diff --git a/receiver/cloudflarereceiver/logs.go b/receiver/cloudflarereceiver/logs.go index f8f260770d06..9bedce853999 100644 --- a/receiver/cloudflarereceiver/logs.go +++ b/receiver/cloudflarereceiver/logs.go @@ -57,7 +57,7 @@ func newLogsReceiver(params rcvr.CreateSettings, cfg *Config, consumer consumer. } if recv.cfg.TLS != nil { - tlsConfig, err := recv.cfg.TLS.LoadTLSConfig() + tlsConfig, err := recv.cfg.TLS.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/receiver/mongodbatlasreceiver/alerts.go b/receiver/mongodbatlasreceiver/alerts.go index 1aae71729e59..8eb51459ef46 100644 --- a/receiver/mongodbatlasreceiver/alerts.go +++ b/receiver/mongodbatlasreceiver/alerts.go @@ -89,7 +89,7 @@ func newAlertsReceiver(params rcvr.CreateSettings, baseConfig *Config, consumer if cfg.TLS != nil { var err error - tlsConfig, err = cfg.TLS.LoadTLSConfig() + tlsConfig, err = cfg.TLS.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/receiver/mongodbreceiver/config.go b/receiver/mongodbreceiver/config.go index 38f6f1868b0a..bd86f7ce41e8 100644 --- a/receiver/mongodbreceiver/config.go +++ b/receiver/mongodbreceiver/config.go @@ -4,6 +4,7 @@ package mongodbreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mongodbreceiver" import ( + "context" "errors" "fmt" "strings" @@ -49,7 +50,7 @@ func (c *Config) Validate() error { err = multierr.Append(err, errors.New("password provided without user")) } - if _, tlsErr := c.LoadTLSConfig(); tlsErr != nil { + if _, tlsErr := c.LoadTLSConfigContext(context.Background()); tlsErr != nil { err = multierr.Append(err, fmt.Errorf("error loading tls configuration: %w", tlsErr)) } @@ -65,7 +66,7 @@ func (c *Config) ClientOptions() *options.ClientOptions { clientOptions.SetConnectTimeout(c.Timeout) } - tlsConfig, err := c.LoadTLSConfig() + tlsConfig, err := c.LoadTLSConfigContext(context.Background()) if err == nil && tlsConfig != nil { clientOptions.SetTLSConfig(tlsConfig) } diff --git a/receiver/mysqlreceiver/client.go b/receiver/mysqlreceiver/client.go index 6fb000566b1c..776a7dfe0cd8 100644 --- a/receiver/mysqlreceiver/client.go +++ b/receiver/mysqlreceiver/client.go @@ -4,6 +4,7 @@ package mysqlreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/mysqlreceiver" import ( + "context" "database/sql" "fmt" "strings" @@ -164,7 +165,7 @@ type ReplicaStatusStats struct { var _ client = (*mySQLClient)(nil) func newMySQLClient(conf *Config) (client, error) { - tls, err := conf.TLS.LoadTLSConfig() + tls, err := conf.TLS.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/receiver/redisreceiver/redis_scraper.go b/receiver/redisreceiver/redis_scraper.go index aee7cff55b24..1f36ded85bbf 100644 --- a/receiver/redisreceiver/redis_scraper.go +++ b/receiver/redisreceiver/redis_scraper.go @@ -42,7 +42,7 @@ func newRedisScraper(cfg *Config, settings receiver.CreateSettings) (scraperhelp } var err error - if opts.TLSConfig, err = cfg.TLS.LoadTLSConfig(); err != nil { + if opts.TLSConfig, err = cfg.TLS.LoadTLSConfigContext(context.Background()); err != nil { return nil, err } return newRedisScraperWithClient(newRedisClient(opts), settings, cfg) diff --git a/receiver/saphanareceiver/client.go b/receiver/saphanareceiver/client.go index 0462fa0d1bfc..3b4fb0d25378 100644 --- a/receiver/saphanareceiver/client.go +++ b/receiver/saphanareceiver/client.go @@ -107,7 +107,7 @@ func (c *sapHanaClient) Connect(ctx context.Context) error { return fmt.Errorf("error generating DSN for SAP HANA connection: %w", err) } - tls, err := c.receiverConfig.ClientConfig.LoadTLSConfig() + tls, err := c.receiverConfig.ClientConfig.LoadTLSConfigContext(ctx) if err != nil { return fmt.Errorf("error generating TLS config for SAP HANA connection: %w", err) } diff --git a/receiver/sapmreceiver/trace_receiver_test.go b/receiver/sapmreceiver/trace_receiver_test.go index 9fd434dff616..f643b0510f78 100644 --- a/receiver/sapmreceiver/trace_receiver_test.go +++ b/receiver/sapmreceiver/trace_receiver_test.go @@ -182,7 +182,7 @@ func sendSapm( }, ServerName: "localhost", } - tls, errTLS := tlscs.LoadTLSConfig() + tls, errTLS := tlscs.LoadTLSConfigContext(context.Background()) if errTLS != nil { return nil, fmt.Errorf("failed to send request to receiver %w", err) } diff --git a/receiver/signalfxreceiver/receiver_test.go b/receiver/signalfxreceiver/receiver_test.go index c6b237e9cf29..1195dbacb453 100644 --- a/receiver/signalfxreceiver/receiver_test.go +++ b/receiver/signalfxreceiver/receiver_test.go @@ -674,7 +674,7 @@ func Test_sfxReceiver_TLS(t *testing.T) { }, ServerName: "localhost", } - tls, errTLS := tlscs.LoadTLSConfig() + tls, errTLS := tlscs.LoadTLSConfigContext(context.Background()) assert.NoError(t, errTLS) client := &http.Client{ Transport: &http.Transport{ diff --git a/receiver/simpleprometheusreceiver/receiver.go b/receiver/simpleprometheusreceiver/receiver.go index 63877a497b94..ea985b2c2d4f 100644 --- a/receiver/simpleprometheusreceiver/receiver.go +++ b/receiver/simpleprometheusreceiver/receiver.go @@ -87,7 +87,7 @@ func getPrometheusConfig(cfg *Config) (*prometheusreceiver.Config, error) { scheme := "http" - tlsConfig, err := cfg.TLSSetting.LoadTLSConfig() + tlsConfig, err := cfg.TLSSetting.LoadTLSConfigContext(context.Background()) if err != nil { return nil, fmt.Errorf("tls config is not valid: %w", err) } diff --git a/receiver/solacereceiver/messaging_service.go b/receiver/solacereceiver/messaging_service.go index 96a114a7a729..7ee973f224da 100644 --- a/receiver/solacereceiver/messaging_service.go +++ b/receiver/solacereceiver/messaging_service.go @@ -37,7 +37,7 @@ func newAMQPMessagingServiceFactory(cfg *Config, logger *zap.Logger) (messagingS // Use the default load config for TLS. Note that in the case where "insecure" is true and no // ca file is provided, tlsConfig will be nil representing a plaintext connection. - loadedTLSConfig, err := cfg.TLS.LoadTLSConfig() + loadedTLSConfig, err := cfg.TLS.LoadTLSConfigContext(context.Background()) if err != nil { return nil, err } diff --git a/receiver/splunkhecreceiver/receiver_test.go b/receiver/splunkhecreceiver/receiver_test.go index dd8df4887905..ba84fe047480 100644 --- a/receiver/splunkhecreceiver/receiver_test.go +++ b/receiver/splunkhecreceiver/receiver_test.go @@ -502,7 +502,7 @@ func Test_splunkhecReceiver_TLS(t *testing.T) { }, ServerName: "localhost", } - tls, errTLS := tlscs.LoadTLSConfig() + tls, errTLS := tlscs.LoadTLSConfigContext(context.Background()) assert.NoError(t, errTLS) client := &http.Client{ Transport: &http.Transport{ diff --git a/receiver/vcenterreceiver/client.go b/receiver/vcenterreceiver/client.go index c6d14a5e68b3..8424019bb03d 100644 --- a/receiver/vcenterreceiver/client.go +++ b/receiver/vcenterreceiver/client.go @@ -52,7 +52,7 @@ func (vc *vcenterClient) EnsureConnection(ctx context.Context) error { if err != nil { return fmt.Errorf("unable to connect to vSphere SDK on listed endpoint: %w", err) } - tlsCfg, err := vc.cfg.LoadTLSConfig() + tlsCfg, err := vc.cfg.LoadTLSConfigContext(ctx) if err != nil { return err } diff --git a/receiver/vcenterreceiver/config.go b/receiver/vcenterreceiver/config.go index 5a4c40779559..1ea95e233a4b 100644 --- a/receiver/vcenterreceiver/config.go +++ b/receiver/vcenterreceiver/config.go @@ -4,6 +4,7 @@ package vcenterreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/vcenterreceiver" import ( + "context" "errors" "fmt" "net/url" @@ -51,7 +52,7 @@ func (c *Config) Validate() error { err = multierr.Append(err, errors.New("password not provided and is required")) } - if _, tlsErr := c.LoadTLSConfig(); err != nil { + if _, tlsErr := c.LoadTLSConfigContext(context.Background()); err != nil { err = multierr.Append(err, fmt.Errorf("error loading tls configuration: %w", tlsErr)) }